Exchange Server TechCenter > Exchange Server Forums > Development > Problem with Exchange Web Service NTLM authentication using Axis 2
Ask a questionAsk a question
 

QuestionProblem with Exchange Web Service NTLM authentication using Axis 2

  • Thursday, November 05, 2009 1:36 PMMailnitin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I am trying to access Exchange Web Service 2007 from a Java client using Axis2 framework.

    Following are the System details

    Axis version: 1.5.1

    Java Version: 1.5.0_13

    Authentication: NTLM

    Protocol: HTTPS

    Platform: Windows XP

    I have tried everything I could possibly find but still I keep getting stuck at an "401 Unauthorised" message from Service.

    Following is a part of trace

    ***************************************************************

    2009/11/05 16:42:16:244 IST [DEBUG] HttpMethodDirector - Authorization required

    2009/11/05 16:42:16:244 IST [DEBUG] AuthChallengeProcessor - Supported authentication schemes in the order of preference: [ntlm, digest, basic]

    2009/11/05 16:42:16:244 IST [INFO] AuthChallengeProcessor - ntlm authentication scheme selected

    2009/11/05 16:42:16:244 IST [DEBUG] AuthChallengeProcessor - Using authentication scheme: ntlm

    2009/11/05 16:42:16:276 IST [DEBUG] AuthChallengeProcessor - Authorization challenge processed

    2009/11/05 16:42:16:276 IST [DEBUG] HttpMethodDirector - Authentication scope: NTLM <any realm>@eumail.rbsres07.net:443

    2009/11/05 16:42:16:291 IST [DEBUG] HttpMethodDirector - Credentials required

    2009/11/05 16:42:16:291 IST [DEBUG] HttpMethodDirector - Credentials provider not available

    2009/11/05 16:42:16:307 IST [INFO] HttpMethodDirector - No credentials available for NTLM <any realm>@eumail.rbsres07.net:443

    2009/11/05 16:42:16:307 IST [INFO] HTTPSender - Unable to sendViaPost to url[https://server/EWS/Exchange.asmx] <org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized>org.ap

    ache.axis2.AxisFault: Transport error: 401 Error: Unauthorized

    at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)

    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:200)

    at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)

    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)

    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)

    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)

    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)

    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)

    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)

    at com.microsoft.schemas.exchange.services._2006.messages.ExchangeServicesStub.findItem(ExchangeServicesStub.java:13820)

    at com.rbsfm.exchangewebservices.ExchangeWSTest.getAllMessageIds(ExchangeWSTest.java:115)

    at com.rbsfm.exchangewebservices.ExchangeWSTest.main(ExchangeWSTest.java:86)

    ***************************************************************

    Does this mean I am not providing valid Credentials or does this mean I am not able to send NTLM credentials correctly ?

    Thanks
    Nitin Gupta

All Replies

  • Friday, November 06, 2009 9:49 AMHenning KrauseMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    the line

    2009/11/05 16:42:16:291 IST [DEBUG] HttpMethodDirector - Credentials provider not available

    tells me, that your axis2 package does not support NTLM authentication...

    But I don't know if such a provider exists for axis2...

    Kind regards,
    Henning Krause
  • Monday, November 09, 2009 7:22 AMMailnitin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Henning

    Thanks for replying.
    Axis2 package I am using does support NTLM authentication. I was making a mistake in the hostname field that i provided. Now, I am past the error above and facing a new error. 
    This looks more like a configuration error. But I am not sure. Can you please help ?


    2009/11/09 12:42:13:995 IST [DEBUG] HttpMethodDirector - Authorization required
    2009/11/09 12:42:14:010 IST [DEBUG] AuthChallengeProcessor - Supported authentication schemes in the order of preference: [ntlm, digest, basic]
    2009/11/09 12:42:14:010 IST [INFO] AuthChallengeProcessor - ntlm authentication scheme selected
    2009/11/09 12:42:14:010 IST [DEBUG] AuthChallengeProcessor - Using authentication scheme: ntlm
    2009/11/09 12:42:14:010 IST [DEBUG] AuthChallengeProcessor - Authorization challenge processed
    2009/11/09 12:42:14:010 IST [DEBUG] HttpMethodDirector - Authentication scope: NTLM <any realm>@eumail.rbsres07.net:443
    2009/11/09 12:42:14:010 IST [DEBUG] HttpMethodDirector - Retry authentication
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<STYLE type="text/css">[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "  BODY { font: 8pt/12pt verdana }[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "  H1 { font: 13pt/15pt verdana }[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "  H2 { font: 8pt/12pt verdana }[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "  A:link { color: red }[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "  A:visited { color: maroon }[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "</STYLE>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<h1>You are not authorized to view this page</h1>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept.[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<hr>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<p>Please try the following:</p>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<ul>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<li>Contact the Web site administrator if you believe you should be able to view this directory or page.</li>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<li>Click the <a href="javascript:location.reload()">Refresh</a> button to try again with different cred"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "entials.</li>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "</ul>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.<br>Internet Information Services (IIS)</h2>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<hr>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<p>Technical Information (for support personnel)</p>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<ul>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>401</b>.</li>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr),[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << " and search for topics titled <b>About Security</b>, <b>Authentication</b>, and <b>About Custom Error Messages</b>.</li>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "</ul>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - << "</TD></TR></TABLE></BODY></HTML>[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] HttpMethodBase - Resorting to protocol version default close connection policy
    2009/11/09 12:42:14:010 IST [DEBUG] HttpMethodBase - Should NOT close connection, using HTTP/1.1
    2009/11/09 12:42:14:010 IST [DEBUG] HttpMethodDirector - Authenticating with NTLM <any realm>@eumail.rbsres07.net:443
    2009/11/09 12:42:14:010 IST [DEBUG] HttpMethodParams - Credential charset not configured, using HTTP element charset
    2009/11/09 12:42:14:010 IST [DEBUG] header - >> "POST /EWS/Services.wsdl HTTP/1.1[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] HttpMethodBase - Adding Host request header
    2009/11/09 12:42:14:010 IST [DEBUG] header - >> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] header - >> "SOAPAction: "http://schemas.microsoft.com/exchange/services/2006/messages/FindItem"[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] header - >> "User-Agent: Axis2[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] header - >> "Transfer-Encoding: chunked[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] header - >> "Authorization: NTLM TlRMTVNTUAABAAAABlIAAAIAAgAzAAAAEwATACAAAABFVU1BSUwuUkJTUkVTMDcuTkVURk0=[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] header - >> "Host: eumail.rbsres07.net[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] header - >> "[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - >> "225[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - >> "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns2:FindItem xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" Traversal="Shallow"><ns2:ItemShape><BaseShape>IdOnly</BaseShape></ns2:ItemShape><ns2:IndexedPageItemView BasePoint="Beginning" Offset="0" /><ns2:ParentFolderIds><DistinguishedFolderId Id="inbox" /></ns2:ParentFolderIds></ns2:FindItem></soapenv:Body></soapenv:Envelope>"
    2009/11/09 12:42:14:010 IST [DEBUG] content - >> "[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - >> "0"
    2009/11/09 12:42:14:010 IST [DEBUG] content - >> "[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] content - >> "[\r][\n]"
    2009/11/09 12:42:14:010 IST [DEBUG] EntityEnclosingMethod - Request body sent
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "HTTP/1.1 500 Internal Server Error[\r][\n]"
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "HTTP/1.1 500 Internal Server Error[\r][\n]"
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "Content-Length: 100[\r][\n]"
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "Content-Type: text/html[\r][\n]"
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "Server: Microsoft-IIS/6.0[\r][\n]"
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "X-Powered-By: ASP.NET[\r][\n]"
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "Date: Mon, 09 Nov 2009 07:12:14 GMT[\r][\n]"
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "Connection: close[\r][\n]"
    2009/11/09 12:42:14:214 IST [DEBUG] header - << "[\r][\n]"
    2009/11/09 12:42:14:229 IST [DEBUG] content - << "<html><head><title>Error</title></head><body>The function requested is not supported[\r][\n]"
    2009/11/09 12:42:14:229 IST [DEBUG] content - << "</body></html>"
    2009/11/09 12:42:14:229 IST [INFO] BuilderUtil - OMException in getSOAPBuilder <org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found html>org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found html
     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:267)
     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:214)
     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:196)
     at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:207)
     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:161)
     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:110)
     at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:682)
     at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:215)
     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
     at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
     at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
     at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
     at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
     at com.microsoft.schemas.exchange.services._2006.messages.ExchangeServicesStub.findItem(ExchangeServicesStub.java:13820)
     at com.rbsfm.exchangewebservices.ExchangeWSTest.getAllMessageIds(ExchangeWSTest.java:116)
     at com.rbsfm.exchangewebservices.ExchangeWSTest.main(ExchangeWSTest.java:87)

    2009/11/09 12:42:14:229 IST [DEBUG] HttpMethodBase - Should close connection in response to directive: close.

    Thanks and Regards
    Nitin Gupta