tags:

views:

364

answers:

1

I am using JAX-WS. I am connecting to .NET webservice that requires authentication. I first call the Authentication.asmx so that I can be authenticated. The call returns me a LoginResult that contains a cookie name. Then I call another webservice and I need to somehow pass this cookie or a cookie name. and I don't know how. Here is the code:

//first service that returns login information
    Authentication auth = new Authentication(new URL("the_url"),
                new QName("http://schemas.microsoft.com/sharepoint/soap/", "Authentication"));

        LoginResult result = auth.getAuthenticationSoap().login(HTTPuserName,
                HTTPpassword);
//i need to pass cookie or cookie name or any other login information to call to this service
        Copy copyService = new Copy(new URL("service_url"), new QName("http://schemas.microsoft.com/sharepoint/soap/", "Copy"));
        BindingProvider p = (BindingProvider) copyService.getCopySoap();
A: 

The JAX-WS client will use the standard mechanisms for cookie management. Take a look at the CookieHandler, CookieManager and CookieStore classes in the java.net package. They will also allow you to add your own cookies, which will later be used for the relevant HTTP requests.

jarnbjo