-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Ayman,

As Sanjiva said Axis2 or any other Axis2 modules built on top of it
(e.g. Sandesha2 - ws reliable messaging implementation,  Rampart - ws
security implementation do not support any proprietary  policy
assertions like MSFT assertions you've quoted. So if you want
experiment WS Policy scenarios with Axis2, pls make sure that they adhere
the standards [1],[2]

If you want enable the stub to support WS Security Policy. the you
need to create the stub specifying a Axis2 repository that has the
rampart module in it. That allows the stub to dynamically engage the
required modules that are necessary to support the specified policies.

ConfigurationContext configCtx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("<path-to-repo>",

VechilePolicyStub stub = new VechilePolicyStub(configCtx,
"<target-endpoint>");

The way you set the policy in the stub is correct. After setting the
policy, you need to call axisService.applyPolicy() that makes the
AxisDescription hierarchy self configured to support the set policies.


e.g.

ServiceClient serviceClient = stub.getServiceClient();
AxisService axisService = serviceClient.getAxisService();

FileInputStream fis = ...
Policy policy = ...

axisService.getPolicyInclude().setPolicy(policy);
axisService.applyPolicy();

Now when invoke the service using the stub, it should do the correct
things that are
expected in set policies. For instance encrypt the outgoing messages
if that is specified in the policy.

Hope this will help.

Best,
Sanka


[1] http://specs.xmlsoap.org/ws/2004/09/policy/ws-policy.pdf
[2] ftp://www6.software.ibm.com/software/developer/library/ws-secpol.pdf


Ayman Yasin wrote:
> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal,
> div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt;
>  font-family:"Times New Roman";} a:link, span.MsoHyperlink
> {color:blue; text-decoration:underline;} a:visited,
> span.MsoHyperlinkFollowed {color:purple;
> text-decoration:underline;} span.EmailStyle17
> {mso-style-type:personal; font-family:Arial; color:windowtext;}
> span.EmailStyle18 {mso-style-type:personal; font-family:Arial;
> color:navy;} span.EmailStyle19 {mso-style-type:personal;
> font-family:Arial; color:navy;} span.EmailStyle20
> {mso-style-type:personal-reply; font-family:Arial; color:navy;}
> @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in
> 1.25in;} div.Section1 {page:Section1;} -->
>
> OK I tried modifying the main method of the client to the
> following:
>
>
>
> public static void main(java.lang.String args[]){
>
> try{
>
> VehiclePolicyStub stub =
>
> new VehiclePolicyStub();
>
>
>
>
>
> ServiceClient serviceClient=stub._getServiceClient();
>
> AxisService axisService=serviceClient.getAxisService();
>
> FileInputStream fis=new FileInputStream("c:\\policy.xml");
>
> Policy policy=PolicyEngine.getPolicy(fis);
>
> axisService.getPolicyInclude().setPolicy(policy);
>
>
>
>
>
>
>
> deleteVehicle(stub);
>
>
>
>
>
> } catch(Exception e){
>
> e.printStackTrace();
>
> System.err.println("\n\n\n");
>
> }
>
> }
>
>
>
>
>
> I am still getting the same error. Is this the correct way to use
> the policy file?
>
> Thank you
>
>
>
>
>
> ---------------------------------------------------------------------
>
>
>
> ---------------------------------------------------------------------
>
>
>
>
>
> Hi
>
> I have been given the following policy file for a dotnet web
> service which i want to write a client to.
>
> "
>
> <policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy";>
>
> <extensions>
>
> <extension name="usernameForCertificateSecurity"
> type="Microsoft.Web.Services3.Design.UsernameForCertificateAssertion,
>  Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
> PublicKeyToken=31bf3856ad364e35" />
>
> <extension name="x509"
> type="Microsoft.Web.Services3.Design.X509TokenProvider,
> Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
> PublicKeyToken=31bf3856ad364e35" />
>
> <extension name="requireActionHeader"
> type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion,
>  Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
> PublicKeyToken=31bf3856ad364e35" />
>
> <extension name="usernameOverTransportSecurity"
> type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion,
>  Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
> PublicKeyToken=31bf3856ad364e35" />
>
> </extensions>
>
> <policy name="ClientPolicy">
>
> <usernameOverTransportSecurity />
>
> <requireActionHeader />
>
> </policy>
>
> </policies>
>
> "
>
> first: is this kind of policy files supported in axis2?
>
> second: how to make the client adheres to this policy file?
>
> I have posted the following question in some forum:
>
> "
>
> I am trying to access a dot net web service and i want to make use
>  of the policy file they gave me. i read that AXIS2 supports
> WS-Policy in the client side but i still can not figure out how to
>  tell the client to use the file. I searched thoroughly for
> examples and searched through different forums with no success. I
> found only similar questions with no answer. if somebody could help
> it would be appreciated.
>
> Thank you
>
>
>
> "
>
> I got the following answer from Sanka Samaranayake :
>
> "
>
> When you codegen a Policy annotated WSDL, the policies are get
> included in the stub. Hence you don't have to specify a separate
> Policy file.
>
>
>
> But if you need to use a separate policy then you need to set them
>  in the AxisDescription object that you use in the ServiceClient
> and OperationClient.
>
>
>
> e.g.
>
>
>
> ServiceClient serviceClient = new ServiceClient();
>
> OperationClient operationClient = serviceClient
>
> .createClient(ServiceClient.ANON_OUT_IN_OP);
>
>
>
> FileInputStream fis = new FileInputStream("path-to-policy.xml");
>
> Policy servicePolicy = PolicyEngine.getPolicy(fis);
>
>
>
> AxisService axisService = serviceClient.getAxisService();
>
> axisService.getPolicyInclude().setPolicy(servicePolicy);
>
>
>
>
>
> If you need more information please repost this to
> [email protected] with a [AXIS2] subject prefix.
>
>
>
> "
>
>
>
> I can see no mention to the policy file in the WSDL so i want to
> use it separately. I generated a proxy to the service using
> xmlbeans and wrote the following client based on the getting
> started guide
>
> "
>
> public class Client{
>
>
>
> public static void main(java.lang.String args[]){
>
> try{
>
> VehiclePolicyStub stub =
>
> new VehiclePolicyStub();
>
>
>
>
>
> deleteVehicle(stub);
>
>
>
>
>
> } catch(Exception e){
>
> e.printStackTrace();
>
> System.err.println("\n\n\n");
>
> }
>
> }
>
>
>
> public static void deleteVehicle(VehiclePolicyStub stub){
>
> try{
>
> DeleteVehicleDocument reqDoc =
> DeleteVehicleDocument.Factory.newInstance();
>
> DeleteVehicleDocument.DeleteVehicle req =
> reqDoc.addNewDeleteVehicle();
>
>
>
>
>
>
>
> Vehicle vehicle=VehicleDocument.Vehicle.Factory.newInstance();
>
>
>
>
> vehicle.setVehicleRegTypeCode((short)2);
>
>
> vehicle.setVehiclePlateNumber((short)777);
>
> vehicle.setVehiclePlateText1("a");
>
> vehicle.setVehiclePlateText2("b");
>
> vehicle.setVehiclePlateText3("c");
>
>
>
> req.setVehicle(vehicle);
>
>
>
> DeleteVehicleResponseDocument res =
>
> stub.DeleteVehicle(reqDoc);
>
>
>
>
> System.err.println(res.getDeleteVehicleResponse().getDeleteVehicleResult());
>
>
>
> } catch(Exception e){
>
> e.printStackTrace();
>
> System.err.println("\n\n\n");
>
> }
>
> }
>
> }
>
>
>
> "
>
>
>
> I get the following error when I run it indicating the missing
> security options
>
> "
>
> org.apache.axis2.AxisFault: Security requirements are not satisfied
>  because the security header is not present in the incoming
> message.
>
> "
>
> I do not know how to integrate the code sanka suggested to use the
>  policy file manually into my client. can somebody help?
>
> Thank you
>
>
>
>
>


- --
Sanka Samaranayake
WSO2 Inc.

T:+94-77-3506382
F:+94-11-2424304

http://sankas.blogspot.com/
http://www.wso2.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (GNU/Linux)

iD8DBQFFYe60/Hd0ETKdgNIRAhqZAKCOxtSeotWYCtDhkznbQs57Y3FcLACbBeqq
KVQrXLCLxZr9JCJKp73nRxU=
=9J1V
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to