users@jax-rpc.java.net

Re: Callback Handler only being called once.

From: V B Kumar Jayanti <Vbkumar.Jayanti_at_Sun.COM>
Date: Wed, 28 Sep 2005 10:17:49 +0530

David Sharp wrote:

> I am using JWSDP-1.5 and XWS to implement a web service. Everything
> works fine so long as I only call a single web service. However, if I
> call two different web services, things break because the
> CallbackHandler is not called on every web service call. When I
> switch try to call the second web service it is using the username and
> password from the first service.
>
> The sequence of events goes something like this:
>
> ServicePort.setUsername("test"); //sets a static thread-local
> variable to the proper username
> ServicePort.setPassword("testpw"); //sets a static
> thread-local variable to the proper password
> //The callback handler will retrieve the username and password
> from these static variables
>
> myStub = (ReceivershipServicePortType_Stub) new
> ReceivershipService_Impl().getReceivershipPort();
>
> myStub._setProperty(com.sun.xml.rpc.client.StubBase.ENDPOINT_ADDRESS_PROPERTY,myEndpoint);
>
> ServicePing sp = new ServicePing();
> sp.setEcho(echo);
> ServicePingReturn rc = myStub.servicePing(sp);
>
> //now ping the second service
> ServicePort.setUsername("test"); //sets a static thread-local
> variable to the proper username
> ServicePort.setPassword("testpw"); //sets a static
> thread-local variable to the proper password

Not sure if this is sample code or real code. If it is real code that
you are using then please note that you have set the same username and
password even while invoking the second endpoint.

>
>
> myStub._setProperty(com.sun.xml.rpc.client.StubBase.ENDPOINT_ADDRESS_PROPERTY,myOtherEndpoint);
>
> sp = new ServicePing();
> sp.setEcho(echo);
>
> //call the new web service, should invoke the CallbackHandler,
> but it does not. Instead it attempts to re-use the
> //values from teh old webservice.
> ServicePingReturn rc2 = myStub.servicePing(sp);

If you have configured a <xwss:UsernameToken/> policy in the security
configuration then the CallbackHandler should always be called on every
invocation of the method servicePing.


>
>
> // end-code
>
> How can I force the security framework to invoke the callback on every
> webservice call?
>
> Thanks,
> Dave