You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by David Mansfield <cx...@dm.cobite.com> on 2013/05/03 19:22:10 UTC

set the endpoint address of a STSClient created from WSDL

Hi All:

I'm using an STSClient configured from spring XML.  I have put the 
BindingProvider.ENDPOINT_ADDRESS_PROPERTY into the requestContext of the 
STSClient, and confirmed it sets this on the ClientImpl (in the 
debugger), but it seems this is not enough to change the actual URL used 
in the transport.

Here's the xml that configures it (unsuccessfully):

     <bean id="myStsClient" class="org.apache.cxf.ws.security.trust.STSClient">
         <constructor-arg ref="myStsCxfBus" />
	...
         <property name="requestContext[javax.xml.ws.service.endpoint.address]" value="https://blah.blah.blah/blah" />
     </bean>

I'm willing to do this programmatically.  So given a ClientImpl, how 
could one programmatically set the endpoint address?

Thanks,
David

Re: set the endpoint address of a STSClient created from WSDL

Posted by Glen Mazza <gl...@gmail.com>.
Setting BindingProvider.ENDPOINT_ADDRESS_PROPERTY as shown here might 
work for you: http://www.jroller.com/gmazza/entry/soap_client_tutorial

Glen


On 05/03/2013 01:22 PM, David Mansfield wrote:
> Hi All:
>
> I'm using an STSClient configured from spring XML.  I have put the 
> BindingProvider.ENDPOINT_ADDRESS_PROPERTY into the requestContext of 
> the STSClient, and confirmed it sets this on the ClientImpl (in the 
> debugger), but it seems this is not enough to change the actual URL 
> used in the transport.
>
> Here's the xml that configures it (unsuccessfully):
>
>     <bean id="myStsClient" 
> class="org.apache.cxf.ws.security.trust.STSClient">
>         <constructor-arg ref="myStsCxfBus" />
>     ...
>         <property 
> name="requestContext[javax.xml.ws.service.endpoint.address]" 
> value="https://blah.blah.blah/blah" />
>     </bean>
>
> I'm willing to do this programmatically.  So given a ClientImpl, how 
> could one programmatically set the endpoint address?
>
> Thanks,
> David



RE: set the endpoint address of a STSClient created from WSDL

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

It is correct, If you use wsdlLocation property, than location will be ignored.

STSClient directly instantiates ClientImpl and calls his invoke() method. Therefore WrappedMessageContext is bypassed and BindingProvider.ENDPOINT_ADDRESS_PROPERTY is not mapped to Message.ENDPOINT_ADDRESS property in the message for STSClient (as normally happens by service proxy invocation). 

You can set Message.ENDPOINT_ADDRESS in request context directly, it should work:

stsClient.getClient().getRequestContext().put(Message.ENDPOINT_ADDRESS, "custom address");

Regards,
Andrei.

> -----Original Message-----
> From: David Mansfield [mailto:cxf@dm.cobite.com]
> Sent: Samstag, 4. Mai 2013 19:33
> To: Andrei Shakirin
> Cc: users@cxf.apache.org
> Subject: Re: set the endpoint address of a STSClient created from WSDL
> 
> This method is only used when a WSDL is not used to created the client
> afaict.
> 
> Thanks,
> David
> 
> On 05/04/2013 11:13 AM, Andrei Shakirin wrote:
> > Hi,
> >
> > Why you don't just use location property of STSClient?
> >
> > STS client endpoint will be initialized using location property in STSUtils:
> >      private static Endpoint createSTSEndpoint(Bus bus,
> >                                               String namespace,
> >                                               String transportId,
> >                                               String location,
> >                                               String soapVersion,
> >                                               Policy policy,
> >                                               QName epName,
> >                                               boolean sc) throws BusException,
> EndpointException {
> >          ...
> >          EndpointInfo ei = new EndpointInfo(si, transportId);
> >          ei.setBinding(bi);
> >          ei.setName(epName == null ? iName : epName);
> >          ei.setAddress(location);
> >          si.addEndpoint(ei);
> >          if (policy != null) {
> >              ei.addExtensor(policy);
> >          }
> >          ...
> > }
> >
> > Regards,
> > Andrei.
> >
> >> -----Original Message-----
> >> From: David Mansfield [mailto:cxf@dm.cobite.com]
> >> Sent: Freitag, 3. Mai 2013 19:22
> >> To: users@cxf.apache.org
> >> Subject: set the endpoint address of a STSClient created from WSDL
> >>
> >> Hi All:
> >>
> >> I'm using an STSClient configured from spring XML.  I have put the
> >> BindingProvider.ENDPOINT_ADDRESS_PROPERTY into the
> requestContext of
> >> the STSClient, and confirmed it sets this on the ClientImpl (in the
> >> debugger), but it seems this is not enough to change the actual URL
> >> used in the transport.
> >>
> >> Here's the xml that configures it (unsuccessfully):
> >>
> >>       <bean id="myStsClient"
> >> class="org.apache.cxf.ws.security.trust.STSClient">
> >>           <constructor-arg ref="myStsCxfBus" />
> >> 	...
> >>           <property
> >> name="requestContext[javax.xml.ws.service.endpoint.address]"
> >> value="https://blah.blah.blah/blah" />
> >>       </bean>
> >>
> >> I'm willing to do this programmatically.  So given a ClientImpl, how
> >> could one programmatically set the endpoint address?
> >>
> >> Thanks,
> >> David


Re: set the endpoint address of a STSClient created from WSDL

Posted by David Mansfield <cx...@dm.cobite.com>.
This method is only used when a WSDL is not used to created the client 
afaict.

Thanks,
David

On 05/04/2013 11:13 AM, Andrei Shakirin wrote:
> Hi,
>
> Why you don't just use location property of STSClient?
>
> STS client endpoint will be initialized using location property in STSUtils:
>      private static Endpoint createSTSEndpoint(Bus bus,
>                                               String namespace,
>                                               String transportId,
>                                               String location,
>                                               String soapVersion,
>                                               Policy policy,
>                                               QName epName,
>                                               boolean sc) throws BusException, EndpointException {
>          ...
>          EndpointInfo ei = new EndpointInfo(si, transportId);
>          ei.setBinding(bi);
>          ei.setName(epName == null ? iName : epName);
>          ei.setAddress(location);
>          si.addEndpoint(ei);
>          if (policy != null) {
>              ei.addExtensor(policy);
>          }
>          ...
> }
>
> Regards,
> Andrei.
>
>> -----Original Message-----
>> From: David Mansfield [mailto:cxf@dm.cobite.com]
>> Sent: Freitag, 3. Mai 2013 19:22
>> To: users@cxf.apache.org
>> Subject: set the endpoint address of a STSClient created from WSDL
>>
>> Hi All:
>>
>> I'm using an STSClient configured from spring XML.  I have put the
>> BindingProvider.ENDPOINT_ADDRESS_PROPERTY into the requestContext of
>> the STSClient, and confirmed it sets this on the ClientImpl (in the debugger),
>> but it seems this is not enough to change the actual URL used in the
>> transport.
>>
>> Here's the xml that configures it (unsuccessfully):
>>
>>       <bean id="myStsClient"
>> class="org.apache.cxf.ws.security.trust.STSClient">
>>           <constructor-arg ref="myStsCxfBus" />
>> 	...
>>           <property
>> name="requestContext[javax.xml.ws.service.endpoint.address]"
>> value="https://blah.blah.blah/blah" />
>>       </bean>
>>
>> I'm willing to do this programmatically.  So given a ClientImpl, how could one
>> programmatically set the endpoint address?
>>
>> Thanks,
>> David


RE: set the endpoint address of a STSClient created from WSDL

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

Why you don't just use location property of STSClient?

STS client endpoint will be initialized using location property in STSUtils:
    private static Endpoint createSTSEndpoint(Bus bus, 
                                             String namespace,
                                             String transportId,
                                             String location,
                                             String soapVersion,
                                             Policy policy,
                                             QName epName,
                                             boolean sc) throws BusException, EndpointException {
        ...
        EndpointInfo ei = new EndpointInfo(si, transportId);
        ei.setBinding(bi);
        ei.setName(epName == null ? iName : epName);
        ei.setAddress(location);
        si.addEndpoint(ei);
        if (policy != null) {
            ei.addExtensor(policy);
        }
        ...
}

Regards,
Andrei.

> -----Original Message-----
> From: David Mansfield [mailto:cxf@dm.cobite.com]
> Sent: Freitag, 3. Mai 2013 19:22
> To: users@cxf.apache.org
> Subject: set the endpoint address of a STSClient created from WSDL
> 
> Hi All:
> 
> I'm using an STSClient configured from spring XML.  I have put the
> BindingProvider.ENDPOINT_ADDRESS_PROPERTY into the requestContext of
> the STSClient, and confirmed it sets this on the ClientImpl (in the debugger),
> but it seems this is not enough to change the actual URL used in the
> transport.
> 
> Here's the xml that configures it (unsuccessfully):
> 
>      <bean id="myStsClient"
> class="org.apache.cxf.ws.security.trust.STSClient">
>          <constructor-arg ref="myStsCxfBus" />
> 	...
>          <property
> name="requestContext[javax.xml.ws.service.endpoint.address]"
> value="https://blah.blah.blah/blah" />
>      </bean>
> 
> I'm willing to do this programmatically.  So given a ClientImpl, how could one
> programmatically set the endpoint address?
> 
> Thanks,
> David