You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by smox <si...@oxenvad.dk> on 2009/01/06 15:58:24 UTC
Accessing webservice written in .Net using CXF client with
http:NegotiateAuthentication
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
--
View this message in context: http://www.nabble.com/Accessing-webservice-written-in-.Net-using-CXF-client-with-http%3ANegotiateAuthentication-tp21311978p21311978.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Accessing webservice written in .Net using CXF client with
http:NegotiateAuthentication
Posted by smox <si...@oxenvad.dk>.
Thanks for the tip, but I'm not quite getting there.
I've done more research and it turns out that the service is using NTLM
Autherization...
I've searched the mailing list and found the following:
http://www.nabble.com/NTLM-Support--td16447079.html#a19486039
http://www.nabble.com/NTLM-Support--td16447079.html#a19486039
In this thread, benjwarner claims to have successfully used a service with
NTLM.
When I try to incorporate his code into the generated code, the only result
I can get is a IIS 401 HTML error message.
I've tried to set the http headers directly onto requestContext (used
soap-ui 2.5 to get those headers) - this results in the following:
Invoking readCustomer...
08-01-2009 00:43:40 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.ClassCastException: java.lang.String cannot be cast to
org.w3c.dom.Element
at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:120)
at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:76)
at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:57)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
at $Proxy41.readCustomer(Unknown Source)
at
test.client.MyCustomerService_BasicHttpBindingMyCustomerService_Client.main(MyCustomerService_BasicHttpBindingMyCustomerService_Client.java:89)
Does this mean that it has actually called the service, or does this happen
when serializing the request object to XML?
Any thoughts on this are very appreciated.
dkulp wrote:
>
>
> 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
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>
>
--
View this message in context: http://www.nabble.com/Accessing-webservice-written-in-.Net-using-CXF-client-with-http%3ANegotiateAuthentication-tp21311978p21343034.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Accessing webservice written in .Net using CXF client with http:NegotiateAuthentication
Posted by Daniel Kulp <dk...@apache.org>.
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
dkulp@apache.org
http://dankulp.com/blog