You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Ayman Yasin <ya...@elm.com.sa> on 2006/11/20 12:02:22 UTC

[AXIS2] client to a dotnet service with policy

 

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
axis-dev@ws.apache.org 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

 

 


RE: [AXIS2] client to a dotnet service with policy

Posted by Ayman Yasin <ya...@elm.com.sa>.
Thank you for the response. When I tried loading this policy (the code
is in my other email I sent before I read your reply) the strange thing
axis does not complain about it!
Do you know of any shortcut other than waiting for the dotnet guys to
change their way like a conversion tool or something?



-----Original Message-----
From: Sanjiva Weerawarana [mailto:sanjiva@opensource.lk] 
Sent: 20/Nov/2006 2:32 PM
To: axis-dev@ws.apache.org
Subject: Re: [AXIS2] client to a dotnet service with policy

On Mon, 2006-11-20 at 14:02 +0300, Ayman Yasin wrote:
>  
> 
> 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">
....

> first: is this kind of policy files supported in axis2?

No- these are proprietary MSFT policies.

> second: how to make the client adheres to this policy file?

ServiceClient.setPolicy().

> 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.

First thing is to get MSFT to give you some standard policy assertions.
We're not going to support proprietary assertions from any vendor.

Sanjiva.
-- 
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [AXIS2] client to a dotnet service with policy

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Mon, 2006-11-20 at 14:02 +0300, Ayman Yasin wrote:
>  
> 
> 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">
....

> first: is this kind of policy files supported in axis2?

No- these are proprietary MSFT policies.

> second: how to make the client adheres to this policy file?

ServiceClient.setPolicy().

> 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.

First thing is to get MSFT to give you some standard policy assertions.
We're not going to support proprietary assertions from any vendor.

Sanjiva.
-- 
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


RE: [AXIS2] client to a dotnet service with policy

Posted by Ayman Yasin <ya...@elm.com.sa>.
Thanks for the help again Sanka. You and Sanjiva are very kind and
helpful people :)
One thing is still unclear to me: although the docs say axis2 comes with
the rampart module I can not see it in the axis2-1.1\repository\modules.
Do I need to get it and put it there? Do I need to put  <module
ref="rampart"/> in axis2.xml? Or it is enough only to add the lines of
code to the client? 

 
-----Original Message-----
From: Sanka Samaranayke [mailto:ssanka@gmail.com] 
Sent: 20/Nov/2006 9:07 PM
To: axis-dev@ws.apache.org
Subject: Re: [AXIS2] client to a dotnet service with policy

-----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("<p
ath-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
> axis-dev@ws.apache.org 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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [AXIS2] client to a dotnet service with policy

Posted by Sanka Samaranayke <ss...@gmail.com>.
-----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
> axis-dev@ws.apache.org 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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


RE: [AXIS2] client to a dotnet service with policy

Posted by Ayman Yasin <ya...@elm.com.sa>.
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
axis-dev@ws.apache.org 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