If it's just basic auth authentication, you just need to do:
((BindingProvider)port).getRequestContext().put(
BindingProvider.USERNAME_PROPERTY, username);
((BindingProvider)port).getRequestContext().put(
BindingProvider.PASSWORD_PROPERTY, password);
Dan
On Tuesday 06 January 2009 9:58:24 am smox wrote:
> Hi,
>
> I'm trying to write a small client to access a webservice written in .Net
> but I'm having trouble doing this successfully.
>
> I've generated the client code using wsdl2java - when running the auto
> generated main() function I get:
>
> Exception in thread "main"
> com.sun.xml.internal.ws.client.ClientTransportException: request requires
> HTTP authentication: Unauthorized
>
> The problem obvious is that I somehow need to add the username and
> password.
>
> I see the following at the top of the wsdl file from which the client code
> is generated:
>
> <wsp:Policy wsu:Id="BasicHttpBinding_MyCustomerService_policy">
> <wsp:ExactlyOne>
> <wsp:All>
> <http:NegotiateAuthentication/>
> </wsp:All>
> </wsp:ExactlyOne>
> </wsp:Policy>
>
> What steps do I have to go through to enable the NegotiateAuthentication in
> the client code?
>
> I've of course googled for some time now, but not many hits come up when I
> search for NegotiateAuthentication.
>
> Any help is much appreciated,
>
> Thanks
>
> Simon
--
Daniel Kulp
[email protected]
http://dankulp.com/blog