You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Saminda Abeyruwan <sa...@gmail.com> on 2007/08/21 03:48:34 UTC

Re: [Axis2] temp fix for NTML authentication & axiom serialization erro

Axis2 uses HttpClient's NTLM support. Your code snippet looks good, and
wonder if you have given the credentials according to
http://commons.apache.org/httpclient/authentication.html#NTLM

In addition to the above, you've need to set
auth.setAllowedRetry(true);

Please comment out
auth.setHost("hostname");
auth.setPort(80);

Saminda

On 8/20/07, hs <ha...@yahoo.com> wrote:
>
>
> Hi
>
> I am trying to use a webservice written in .net, for Sharepoint Portal.
> Am using axis2-1.3
> Have generated WebService client using eclipse pluggin
> In the generated class ServiceServiceSoapStub looks like this,
> //.....snippet
> OperationClient _operationClient =
> _serviceClient.createClient(_operations[0].getName())
>
> //.....
>
>     _serviceClient.addHeadersToEnvelope(env);
> _messageContext.setEnvelope(env);
>     HttpTransportProperties.Authenticator auth = new
> HttpTransportProperties.Authenticator();
>     auth.setUsername("username");
>     auth.setPassword("password");
>     auth.setDomain("domain");
>     auth.setHost("hostname");
>     auth.setPort(80);
>
> _operationClient.getOptions().setProperty(
> org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,auth);
>
>     _operationClient.addMessageContext(_messageContext);
>
> System.out.println(((HttpTransportProperties.Authenticator
> )_operationClient.getOptions().getProperty(
> org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE
> )).getUsername());
>        //execute the operation client
>         _operationClient.execute(true);
> // .....
>
> I am getting 401 exception
> org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
>         at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(
> CommonsHTTPTransportSender.java:221)
>         at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)
>         at
> org.apache.axis2.description.OutInAxisOperationClient.send(
> OutInAxisOperation.java:330)
>         at
> org.apache.axis2.description.OutInAxisOperationClient.execute(
> OutInAxisOperation.java:294)
>         at
> com.microsoft.webservices.ServiceServiceSoapStub.FileUpload(
> ServiceServiceSoapStub.java:226)
>         at com.microsoft.webservices.SPSClient.main(SPSClient.java:99)
> Caused by: org.apache.axis2.AxisFault: Transport error: 401 Error:
> Unauthorized
>         at
>
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons
> (CommonsHTTPTransportSender.java:314)
>         at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(
> CommonsHTTPTransportSender.java:201)
>
>
> Can we use options for NTML authentication and set it to OperationClient
> object?
> Or is there something I am missing out here :(
>
> Thanks,
> Harleen
>
>
> Saminda Abeyruwan wrote:
> >
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi Jeff, Dims, Paul and all,
> >
> > To do NTLM Authentication one has to do the following now,
> >
> > ...
> > <snippet/>
> >
> > HttpTransportProperties.NTLMAuthentication ntlmAuthentication =
> >                     new HttpTransportProperties().new
> > NTLMAuthentication();
> >
> >             ntlmAuthentication.setUsername("axis2");
> >             // other credentials.
> >
> >             options.setProperty(
> >
> > org.apache.axis2.transport.http.HTTPConstants.NTLM_AUTHENTICATION,
> >                     ntlmAuthentication);
> >
> > ...
> >
> > To do Basic Authentication one has to do the following,
> >
> > ...
> > <snippet/>
> >
> > HttpTransportProperties.BasicAuthentication basicAuthentication =
> >                     new HttpTransportProperties().new
> > BasicAuthentication();
> >
> >             basicAuthentication.setUsername("axis2");
> >             basicAuthentication.setPassword("axis2");
> >             options.setProperty(
> >
> > org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATION,
> >                     basicAuthentication);
> > ...
> >
> > Jeff, please try it and let us know the results. Will update the docs
> > asap.
> >
> > Thank you
> >
> > Saminda
> >
> > Jeff Ling wrote:
> >> Hi Dims,
> >>
> >> Thanks a lot!
> >>
> >> When would it be patched? And what's the plan for the next stable
> >> release?
> >>
> >> Thanks!
> >>
> >> Jeff
> >>
> >> On 6/8/06, *Davanum Srinivas * <davanum@gmail.com
> >> <ma...@gmail.com>> wrote:
> >>
> >>     Jeff,
> >>
> >>     Yep. that's the one. Basically http client tries to send the data
> and
> >>     when it fails tries to send it again. serializeAndConsume by design
> >>     does not cache the information (does not build the om tree). This
> is
> >>     good news just replacing one for the other. We'll take this account
> >>     and may be add a flag for this behavior.
> >>
> >>     Thanks,
> >>     dims
> >>
> >>     On 6/8/06, Jeff Ling <jeffling@google.com
> >>     <ma...@google.com>> wrote:
> >>     > Hi Paul,
> >>     >
> >>     > I assume you meant the
> >>     >                     element.serializeAndConsume(bytesOut,
> format);
> >>     > in         public byte[] writeBytes()
> >>     >
> >>     > right? No, that didn't work. However, following your lead, I
> >>     changed the
> >>     > same function in
> >>     >
> >>     >         private void handleOMOutput(OutputStream out, boolean
> >>     doingMTOM)
> >>     > throws XMLStreamException {
> >>     >             format.setDoOptimize(doingMTOM);
> >>     >
> >>     >             element.serializeAndConsume (out, format);
> >>     >         }
> >>     >
> >>     > to
> >>     >
> >>     >         private void handleOMOutput(OutputStream out, boolean
> >>     doingMTOM)
> >>     > throws XMLStreamException {
> >>     >              format.setDoOptimize(doingMTOM);
> >>     >              element.serialize(out, format);
> >>     >          }
> >>     >
> >>     > That fixed it. Maybe we are using different versions so the line
> >>     count is
> >>     > different? Please confirm.
> >>     >
> >>     > This is great!
> >>     >
> >>     > Jeff
> >>     >
> >>     >
> >>     > On 6/8/06, Paul Fremantle <pzfreo@gmail.com
> >>     <ma...@gmail.com>> wrote:
> >>     > > Jeff
> >>     > >
> >>     > > We have an idea :-) Can you help us test if its any good?
> >>     > >
> >>     > > Can you please try this fix:
> >>     > >
> >>     > > At line 194 in
> >>     > org.apache.axis2.transport.http.SOAPOverHTTPSender.
> >>     > >
> >>     > > Please change
> >>     > > element.serializeAndConsume (out, format); to
> >>     > > element.serialize(out, format);
> >>     > >
> >>     > > If that works for you then we can craft a proper fix around
> this.
> >>     > >
> >>     > > Thanks
> >>     > >
> >>     > > Paul
> >>     > >
> >>     > > --
> >>     > > Paul Fremantle
> >>     > > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
> >>     > >
> >>     > > http://bloglines.com/blog/paulfremantle
> >>     <http://bloglines.com/blog/paulfremantle>
> >>     > > paul@wso2.com <ma...@wso2.com>
> >>     > >
> >>     > > "Oxygenating the Web Service Platform", www.wso2.com
> >>     <http://www.wso2.com>
> >>     > >
> >>     >
> >>     >
> >>
> >>
> >>     --
> >>     Davanum Srinivas : http://wso2.com/blogs/
> >>
> >>
> ---------------------------------------------------------------------
> >>     To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> >>     <ma...@ws.apache.org>
> >>     For additional commands, e-mail: axis-dev-help@ws.apache.org
> >>     <ma...@ws.apache.org>
> >>
> >>
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.1 (GNU/Linux)
> > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> >
> > iD4DBQFEiVBdYmklbLuW6wYRAuTXAJwK6LPFvAduT/GMRraFAA8EIRh0iwCY3DBi
> > rnkK5RBPaT0ZdGDSlJTRVw==
> > =S+ml
> > -----END PGP SIGNATURE-----
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-dev-help@ws.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/temp-fix-for-NTML-authentication---axiom-serialization-error-tf1720881.html#a12232670
> Sent from the Axis - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Saminda Abeyruwan

Software Engineer
WSO2 Inc. - www.wso2.org