You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jim Collins <ja...@blueyonder.co.uk> on 2007/09/27 22:09:43 UTC

[Axis2] WS-Policy

Hi,

I am trying to write a Web Service client that accesses a Service that uses WS-Policy. The WSDL is correctly configured with the policy and I was able to generate the client stub and I can see from the source that it is adding the policy.

What I am not sure is what I need to do when calling methods on the on the client stub to make sure that it carries out what is in the policy e.g.  sending a token.

Any help would be appreciated.

Thanks

Jim

Re: [Axis2] WS-Policy

Posted by Jim Collins <ja...@blueyonder.co.uk>.
Hi Sanka,

I will send the WSDL tomorrow.

Thanks for your help.

Jim
----- Original Message ----- 
From: "Sanka Samaranayke" <ss...@gmail.com>
To: <ax...@ws.apache.org>
Cc: <pz...@gmail.com>
Sent: Wednesday, October 03, 2007 12:35 PM
Subject: Re: [Axis2] WS-Policy


>
> Hi Jim,
>
> I would be great if you can post the WSDL which you used to generate the 
> stub so that we see whether we can reproduce the problem.
>
> Thanks,
> Sanka
>
>
> Jim Collins wrote:
>> Hi Paul/Sanka,
>>
>> Thanks for the reply and apologies for taking so long in getting back to 
>> you.
>>   I have looked at the Rampart examples and they have a separate policy. 
>> The policy that I use is part of the WSDL.
>>
>> I can see in the generated stub that the policy is being set e.g.
>>
>> (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicyInclude().setPolicy(getPolicy("<wsp:Policy 
>> xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">...</wsp:Policy>"));
>>
>> After generating the Stub I then installed Rampart and was then getting 
>> errors when I tried to generate the stub again. I got a 
>> CodeGenerationException
>>
>> java.lang.RuntimeException: can't serialize the policy ..
>>
>> I have used Axis1 in the past but I am new to Axis2 and not sure how I 
>> use the rampart module for just the client  and specify the policy if it 
>> is part of an existing WSDL.
>>
>> Thanks
>>
>> Jim
>>
>>
>> ----- Original Message ----- From: "Paul Fremantle" <pz...@gmail.com>
>> To: <ax...@ws.apache.org>
>> Sent: Friday, September 28, 2007 8:00 AM
>> Subject: Re: [Axis2] WS-Policy
>>
>>
>>> Probably the best thing would be to look at some of the Rampart
>>> samples that are driven by policy. If you can give us some idea of the
>>> policy that is being used it might help.
>>>
>>> Basically, each public policy provided by the remote service requires
>>> some config locally. For example, if the policy says "encrypt" then
>>> you need to config the keystore. If the policy says
>>> "username/password" you need to let rampart have those.
>>>
>>> Now here's the freaky bit. Rampart also uses policy to *configure* the
>>> local items. So you need to give Rampart the local policy as well as
>>> the remote policy which is already burnt into your stub. Both will be
>>> merged to make a master policy which will make Rampart do the right
>>> thing.
>>>
>>> Paul
>>>
>>> On 9/28/07, Sanka Samaranayke <ss...@gmail.com> wrote:
>>>>
>>>> Hi Jim,
>>>>
>>>> 1) If you want to get WS-Security policy being supported in the stub, 
>>>> you need to instantiate the stub by giving a ConfigurationContext obj
>>>> which points a repository which contains a rampart mar.
>>>>
>>>> 2) Then you need to attach rampart specific policies to the AxisService 
>>>> obj which is used internally by the stub. You can do that as follows.
>>>>
>>>> ServiceClient _serviceClient = stub._getServiceClient();
>>>> AxisService service = _serviceClient.getAxisService();
>>>> service.getPolicyInclude().addPolicy(policy);
>>>>
>>>> Here the policy object should contain configuration policies of rampart 
>>>> which are needed to provides security requirements specified by
>>>> policy expressions in the service wsdl document.
>>>>
>>>> For example, if the service requires username token then you need to 
>>>> attach a policy expression with rampart assertions which specify
>>>> Password callback class.
>>>>
>>>>
>>>>
>>>> HTH,
>>>> Sanka
>>>>
>>>> 1) First you need to instantiate the stub giving a configuration 
>>>> context
>>>>
>>>> Jim Collins wrote:
>>>> > Hi,
>>>> >
>>>> > I am trying to write a Web Service client that accesses a Service
>>>> that
>>>> > uses WS-Policy. The WSDL is correctly configured with the policy
>>>> and I
>>>> > was able to generate the client stub and I can see from the source
>>>> > that it is adding the policy.
>>>> >
>>>> > What I am not sure is what I need to do when calling methods on
>>>> the on
>>>> > the client stub to make sure that it carries out what is in the
>>>> policy
>>>> > e.g.  sending a token.
>>>> >
>>>> > Any help would be appreciated.
>>>> >
>>>> > Thanks
>>>> >
>>>> > Jim
>>>>
>>>>
>>>> -- 
>>>> Sanka Samaranayake
>>>> WSO2 Inc.
>>>>
>>>> http://www.bloglines.com/blog/sanka
>>>> http://www.wso2.org/
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>>
>>>>
>>>
>>>
>>> -- 
>>> Paul Fremantle
>>> Co-Founder and VP of Technical Sales, WSO2
>>> OASIS WS-RX TC Co-chair
>>>
>>> blog: http://pzf.fremantle.org
>>> paul@wso2.com
>>>
>>> "Oxygenating the Web Service Platform", www.wso2.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
>>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>
>
> -- 
> Sanka Samaranayake
> WSO2 Inc.
>
> http://www.bloglines.com/blog/sanka
> http://www.wso2.org/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
> 




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


Re: [Axis2] WS-Policy

Posted by Sanka Samaranayke <ss...@gmail.com>.
Hi Jim,

I would be great if you can post the WSDL which you used to generate the stub 
so that we see whether we can reproduce the problem.

Thanks,
Sanka


Jim Collins wrote:
> Hi Paul/Sanka,
>
> Thanks for the reply and apologies for taking so long in getting back 
> to you.
>   
> I have looked at the Rampart examples and they have a separate policy. 
> The policy that I use is part of the WSDL.
>
> I can see in the generated stub that the policy is being set e.g.
>
> (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicyInclude().setPolicy(getPolicy("<wsp:Policy 
> xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">...</wsp:Policy>")); 
>
>
> After generating the Stub I then installed Rampart and was then 
> getting errors when I tried to generate the stub again. I got a 
> CodeGenerationException
>
> java.lang.RuntimeException: can't serialize the policy ..
>
> I have used Axis1 in the past but I am new to Axis2 and not sure how I 
> use the rampart module for just the client  and specify the policy if 
> it is part of an existing WSDL.
>
> Thanks
>
> Jim
>
>
> ----- Original Message ----- From: "Paul Fremantle" <pz...@gmail.com>
> To: <ax...@ws.apache.org>
> Sent: Friday, September 28, 2007 8:00 AM
> Subject: Re: [Axis2] WS-Policy
>
>
>> Probably the best thing would be to look at some of the Rampart
>> samples that are driven by policy. If you can give us some idea of the
>> policy that is being used it might help.
>>
>> Basically, each public policy provided by the remote service requires
>> some config locally. For example, if the policy says "encrypt" then
>> you need to config the keystore. If the policy says
>> "username/password" you need to let rampart have those.
>>
>> Now here's the freaky bit. Rampart also uses policy to *configure* the
>> local items. So you need to give Rampart the local policy as well as
>> the remote policy which is already burnt into your stub. Both will be
>> merged to make a master policy which will make Rampart do the right
>> thing.
>>
>> Paul
>>
>> On 9/28/07, Sanka Samaranayke <ss...@gmail.com> wrote:
>>>
>>> Hi Jim,
>>>
>>> 1) If you want to get WS-Security policy being supported in the 
>>> stub, you need to instantiate the stub by giving a 
>>> ConfigurationContext obj
>>> which points a repository which contains a rampart mar.
>>>
>>> 2) Then you need to attach rampart specific policies to the 
>>> AxisService obj which is used internally by the stub. You can do 
>>> that as follows.
>>>
>>> ServiceClient _serviceClient = stub._getServiceClient();
>>> AxisService service = _serviceClient.getAxisService();
>>> service.getPolicyInclude().addPolicy(policy);
>>>
>>> Here the policy object should contain configuration policies of 
>>> rampart which are needed to provides security requirements specified by
>>> policy expressions in the service wsdl document.
>>>
>>> For example, if the service requires username token then you need to 
>>> attach a policy expression with rampart assertions which specify
>>> Password callback class.
>>>
>>>
>>>
>>> HTH,
>>> Sanka
>>>
>>> 1) First you need to instantiate the stub giving a configuration 
>>> context
>>>
>>> Jim Collins wrote:
>>> > Hi,
>>> >
>>> > I am trying to write a Web Service client that accesses a Service 
>>> that
>>> > uses WS-Policy. The WSDL is correctly configured with the policy 
>>> and I
>>> > was able to generate the client stub and I can see from the source
>>> > that it is adding the policy.
>>> >
>>> > What I am not sure is what I need to do when calling methods on 
>>> the on
>>> > the client stub to make sure that it carries out what is in the 
>>> policy
>>> > e.g.  sending a token.
>>> >
>>> > Any help would be appreciated.
>>> >
>>> > Thanks
>>> >
>>> > Jim
>>>
>>>
>>> -- 
>>> Sanka Samaranayake
>>> WSO2 Inc.
>>>
>>> http://www.bloglines.com/blog/sanka
>>> http://www.wso2.org/
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
>>
>>
>> -- 
>> Paul Fremantle
>> Co-Founder and VP of Technical Sales, WSO2
>> OASIS WS-RX TC Co-chair
>>
>> blog: http://pzf.fremantle.org
>> paul@wso2.com
>>
>> "Oxygenating the Web Service Platform", www.wso2.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Sanka Samaranayake
WSO2 Inc.

http://www.bloglines.com/blog/sanka
http://www.wso2.org/


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


Re: [Axis2] WS-Policy

Posted by Jim Collins <ja...@blueyonder.co.uk>.
Hi Paul/Sanka,

Thanks for the reply and apologies for taking so long in getting back to 
you.

I have looked at the Rampart examples and they have a separate policy. The 
policy that I use is part of the WSDL.

I can see in the generated stub that the policy is being set e.g.

(__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicyInclude().setPolicy(getPolicy("<wsp:Policy 
xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\">...</wsp:Policy>"));

After generating the Stub I then installed Rampart and was then getting 
errors when I tried to generate the stub again. I got a 
CodeGenerationException

java.lang.RuntimeException: can't serialize the policy ..

I have used Axis1 in the past but I am new to Axis2 and not sure how I use 
the rampart module for just the client  and specify the policy if it is part 
of an existing WSDL.

Thanks

Jim


----- Original Message ----- 
From: "Paul Fremantle" <pz...@gmail.com>
To: <ax...@ws.apache.org>
Sent: Friday, September 28, 2007 8:00 AM
Subject: Re: [Axis2] WS-Policy


> Probably the best thing would be to look at some of the Rampart
> samples that are driven by policy. If you can give us some idea of the
> policy that is being used it might help.
>
> Basically, each public policy provided by the remote service requires
> some config locally. For example, if the policy says "encrypt" then
> you need to config the keystore. If the policy says
> "username/password" you need to let rampart have those.
>
> Now here's the freaky bit. Rampart also uses policy to *configure* the
> local items. So you need to give Rampart the local policy as well as
> the remote policy which is already burnt into your stub. Both will be
> merged to make a master policy which will make Rampart do the right
> thing.
>
> Paul
>
> On 9/28/07, Sanka Samaranayke <ss...@gmail.com> wrote:
>>
>> Hi Jim,
>>
>> 1) If you want to get WS-Security policy being supported in the stub, you 
>> need to instantiate the stub by giving a ConfigurationContext obj
>> which points a repository which contains a rampart mar.
>>
>> 2) Then you need to attach rampart specific policies to the AxisService 
>> obj which is used internally by the stub. You can do that as follows.
>>
>> ServiceClient _serviceClient = stub._getServiceClient();
>> AxisService service = _serviceClient.getAxisService();
>> service.getPolicyInclude().addPolicy(policy);
>>
>> Here the policy object should contain configuration policies of rampart 
>> which are needed to provides security requirements specified by
>> policy expressions in the service wsdl document.
>>
>> For example, if the service requires username token then you need to 
>> attach a policy expression with rampart assertions which specify
>> Password callback class.
>>
>>
>>
>> HTH,
>> Sanka
>>
>> 1) First you need to instantiate the stub giving a configuration context
>>
>> Jim Collins wrote:
>> > Hi,
>> >
>> > I am trying to write a Web Service client that accesses a Service that
>> > uses WS-Policy. The WSDL is correctly configured with the policy and I
>> > was able to generate the client stub and I can see from the source
>> > that it is adding the policy.
>> >
>> > What I am not sure is what I need to do when calling methods on the on
>> > the client stub to make sure that it carries out what is in the policy
>> > e.g.  sending a token.
>> >
>> > Any help would be appreciated.
>> >
>> > Thanks
>> >
>> > Jim
>>
>>
>> --
>> Sanka Samaranayake
>> WSO2 Inc.
>>
>> http://www.bloglines.com/blog/sanka
>> http://www.wso2.org/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>
>
> -- 
> Paul Fremantle
> Co-Founder and VP of Technical Sales, WSO2
> OASIS WS-RX TC Co-chair
>
> blog: http://pzf.fremantle.org
> paul@wso2.com
>
> "Oxygenating the Web Service Platform", www.wso2.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
> 




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


Re: [Axis2] WS-Policy

Posted by Paul Fremantle <pz...@gmail.com>.
Probably the best thing would be to look at some of the Rampart
samples that are driven by policy. If you can give us some idea of the
policy that is being used it might help.

Basically, each public policy provided by the remote service requires
some config locally. For example, if the policy says "encrypt" then
you need to config the keystore. If the policy says
"username/password" you need to let rampart have those.

Now here's the freaky bit. Rampart also uses policy to *configure* the
local items. So you need to give Rampart the local policy as well as
the remote policy which is already burnt into your stub. Both will be
merged to make a master policy which will make Rampart do the right
thing.

Paul

On 9/28/07, Sanka Samaranayke <ss...@gmail.com> wrote:
>
> Hi Jim,
>
> 1) If you want to get WS-Security policy being supported in the stub, you need to instantiate the stub by giving a ConfigurationContext obj
> which points a repository which contains a rampart mar.
>
> 2) Then you need to attach rampart specific policies to the AxisService obj which is used internally by the stub. You can do that as follows.
>
> ServiceClient _serviceClient = stub._getServiceClient();
> AxisService service = _serviceClient.getAxisService();
> service.getPolicyInclude().addPolicy(policy);
>
> Here the policy object should contain configuration policies of rampart which are needed to provides security requirements specified by
> policy expressions in the service wsdl document.
>
> For example, if the service requires username token then you need to attach a policy expression with rampart assertions which specify
> Password callback class.
>
>
>
> HTH,
> Sanka
>
> 1) First you need to instantiate the stub giving a configuration context
>
> Jim Collins wrote:
> > Hi,
> >
> > I am trying to write a Web Service client that accesses a Service that
> > uses WS-Policy. The WSDL is correctly configured with the policy and I
> > was able to generate the client stub and I can see from the source
> > that it is adding the policy.
> >
> > What I am not sure is what I need to do when calling methods on the on
> > the client stub to make sure that it carries out what is in the policy
> > e.g.  sending a token.
> >
> > Any help would be appreciated.
> >
> > Thanks
> >
> > Jim
>
>
> --
> Sanka Samaranayake
> WSO2 Inc.
>
> http://www.bloglines.com/blog/sanka
> http://www.wso2.org/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair

blog: http://pzf.fremantle.org
paul@wso2.com

"Oxygenating the Web Service Platform", www.wso2.com

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


Re: [Axis2] WS-Policy

Posted by Sanka Samaranayke <ss...@gmail.com>.
Hi Jim,

1) If you want to get WS-Security policy being supported in the stub, you need to instantiate the stub by giving a ConfigurationContext obj
which points a repository which contains a rampart mar. 

2) Then you need to attach rampart specific policies to the AxisService obj which is used internally by the stub. You can do that as follows.

ServiceClient _serviceClient = stub._getServiceClient();
AxisService service = _serviceClient.getAxisService();
service.getPolicyInclude().addPolicy(policy);

Here the policy object should contain configuration policies of rampart which are needed to provides security requirements specified by 
policy expressions in the service wsdl document. 

For example, if the service requires username token then you need to attach a policy expression with rampart assertions which specify 
Password callback class.



HTH,
Sanka

1) First you need to instantiate the stub giving a configuration context  

Jim Collins wrote:
> Hi,
>  
> I am trying to write a Web Service client that accesses a Service that 
> uses WS-Policy. The WSDL is correctly configured with the policy and I 
> was able to generate the client stub and I can see from the source 
> that it is adding the policy.
>  
> What I am not sure is what I need to do when calling methods on the on 
> the client stub to make sure that it carries out what is in the policy 
> e.g.  sending a token.
>  
> Any help would be appreciated.
>  
> Thanks
>  
> Jim


-- 
Sanka Samaranayake
WSO2 Inc.

http://www.bloglines.com/blog/sanka
http://www.wso2.org/


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