axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <mgai...@hotmail.com>
Subject Re: Axis client and .NET Web Service using NTLM security
Date Mon, 24 Jul 2006 18:58:43 GMT
In the 1.4 case pull in Martins code ..
(make sure to use v3.x commons-httpclient code)

package com.mrwpro.vsts.play;

import java.io.IOException;

import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.NTCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;

/**
 * Get a NTLM secured page. 
 * @author martinwoodward
 */
public class NTLMHttpTest {

  public static void main(String[] args) {
		
    HttpClient httpClient = new HttpClient();
    Credentials credentials =  new NTCredentials("username",
"password", "remoteMachine", "MY_DOMAIN");
    httpClient.getState().setCredentials(AuthScope.ANY,credentials);
    HttpMethodBase method = new
GetMethod("http://remoteMachine/WebService/MyService.asmx/WhoAmI");
	
    try {
      int returnCode = httpClient.executeMethod(method);
      String response = method.getResponseBodyAsString();
      System.out.println("Response: " + response);
    } catch (HttpException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  
  }
}

reference
http://mail-archives.apache.org/mod_mbox/ws-axis-user/200506.mbox/%3c598d83ad05062807053ac0111a@mail.gmail.com%3e

-M
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: <andrew.j.hahn@wellsfargo.com>
To: <axis-user@ws.apache.org>; <mgainty@hotmail.com>
Sent: Monday, July 24, 2006 1:31 PM
Subject: RE: Axis client and .NET Web Service using NTLM security


I am writing an axis client using axis 1.4 to call a .NET web service.
I am not sure where I might find those files.. 




This message may contain confidential and/or privileged information.  If
you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based on
this message or any information herein.  If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message.  Thank you for your cooperation.



-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Monday, July 24, 2006 12:08 PM
To: axis-user@ws.apache.org
Subject: Re: Axis client and .NET Web Service using NTLM security

Cant hazard a guess unless I see what is the assigned value for scope=
(from your services.xml) in other words  please send services.xml

concerning 3 requests-
I would need to see axis2.xml
phaseOrder phase..specifically type="inflow"

M-
*********************************************************************
This email message and any files transmitted with it contain
confidential information intended only for the person(s) to whom this
email message is addressed.  If you have received this email message in
error, please notify the sender immediately by telephone or email and
destroy the original message without making a copy.  Thank you.



----- Original Message -----
From: <andrew.j.hahn@wellsfargo.com>
To: <axis-user@ws.apache.org>; <mgainty@hotmail.com>
Sent: Monday, July 24, 2006 12:29 PM
Subject: RE: Axis client and .NET Web Service using NTLM security


Hi Martin,
I am not sure if the first link to the Martin Woodward article is
correct?  Also, do you know why one SOAP call makes 3 requests?
Thanks,
Andy



This message may contain confidential and/or privileged information.  If
you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based on
this message or any information herein.  If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message.  Thank you for your cooperation.



-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Monday, July 24, 2006 11:24 AM
To: axis-user@ws.apache.org
Subject: Re: Axis client and .NET Web Service using NTLM security

Hello Andrew-

Check out this article by Martin Woodward on configuring Axis client to
use NTLM Authentication
http://jakarta.apache.org/commons/httpclient/downloads.html

which specifically using V3.x+ (V3.01) download of commons-httpclient
http://jakarta.apache.org/site/downloads/downloads_commons-httpclient.cg
i

HTH
Martin
*********************************************************************
This email message and any files transmitted with it contain
confidential information intended only for the person(s) to whom this
email message is addressed.  If you have received this email message in
error, please notify the sender immediately by telephone or email and
destroy the original message without making a copy.  Thank you.



----- Original Message -----
From: <andrew.j.hahn@wellsfargo.com>
To: <axis-user@ws.apache.org>; <dims@apache.org>
Sent: Monday, July 24, 2006 11:54 AM
Subject: RE: Axis client and .NET Web Service using NTLM security


Hi, sorry for the delay in my response but I was on vacation :)  

Ok so I have upgraded to the latest version of axis (1.4) and commons
http client jar (3.1 alpha 1) and regeenerated the axis code using
wsdl2java.  This is now what I am getting in the TCPMON tool when I make
the SOAP call.  I'm not sure why it is making 3 requests/responses.  It
is still saying Unauthorized.  Any ideas?
Thanks!


REQUEST:
======================================================================
POST /imgservice.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://wellsfargo.com/provide/image/performView/2005/"
User-Agent: Axis/1.4
Host: localhost:9001
Transfer-Encoding: chunked

22f
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>...<
/soapenv:Body></soapenv:Envelope>
0

POST /imgservice.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://wellsfargo.com/provide/image/performView/2005/"
User-Agent: Axis/1.4
Transfer-Encoding: chunked
Authorization: NTLM
TlRMTVNTUAABAAAABlIAAAYABgAvAAAADwAPACAAAABEVEMxMTAwNTgxMkIxQjdBRC1FTlQ=
Host: localhost:9001

22f
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>...<
/soapenv:Body></soapenv:Envelope>
0

POST /imgservice.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://wellsfargo.com/provide/image/performView/2005/"
User-Agent: Axis/1.4
Transfer-Encoding: chunked
Authorization: NTLM
TlRMTVNTUAADAAAAGAAYAFoAAAAAAAAAcgAAAAYABgBAAAAABQAFAEYAAAAPAA8ASwAAAAAA
AAByAAAABlIAAEFELUVOVEFORFlIRFRDMTEwMDU4MTJCMUI3snfutWtCk33agqsvcAo0Ihcr
/mJhCvb1
Host: localhost:9001

22f
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>...<
/soapenv:Body></soapenv:Envelope>
0


RESPONSE:
======================================================================
HTTP/1.1 401 Unauthorized
Content-Length: 1656
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Mon, 24 Jul 2006 15:22:39 GMT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html;
charset=Windows-1252">
<STYLE type="text/css">
  BODY { font: 8pt/12pt verdana }
  H1 { font: 13pt/15pt verdana }
  H2 { font: 8pt/12pt verdana }
  A:link { color: red }
  A:visited { color: maroon }
</STYLE>
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>

<h1>You are not authorized to view this page</h1>
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.
<hr>
<p>Please try the following:</p>
<ul>
<li>Contact the Web site administrator if you believe you should be able
to view this directory or page.</li>
<li>Click the <a href="javascript:location.reload()">Refresh</a> button
to try again with different credentials.</li>
</ul>
<h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server
configuration.<br>Internet Information Services (IIS)</h2>
<hr>
<p>Technical Information (for support personnel)</p>
<ul>
<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>
<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr),
 and search for topics titled <b>About Security</b>,
<b>Authentication</b>, and <b>About Custom Error Messages</b>.</li>
</ul>

</TD></TR></TABLE></BODY></HTML>
HTTP/1.1 401 Unauthorized
Content-Length: 1539
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: NTLM
TlRMTVNTUAACAAAABgAGADgAAAAGAoECcZfOedx3sAEAAAAAAAAAAJwAnAA+AAAABQLODgAA
AA9BRC1FTlQCAAwAQQBEAC0ARQBOAFQAAQAQAEwAUwBNAEQTHHAxADEAOQAEACIAZQBuAHQA
LgB3AGYAYgAuAGIAYQBuFEsALgBjAG8AcgBwAAMANABMAFMATQBEADUAMQAxADkALgGlAG4A
dAAuAHcAZgBiAC4AYgBhAG4AawAuAGMAbwByAHAABQASAGIAYQBuAGsALgBjAG8AcgBwAAAA
AAA=
X-Powered-By: ASP.NET
Date: Mon, 24 Jul 2006 15:22:39 GMT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html;
charset=Windows-1252">
<STYLE type="text/css">
  BODY { font: 8pt/12pt verdana }
  H1 { font: 13pt/15pt verdana }
  H2 { font: 8pt/12pt verdana }
  A:link { color: red }
  A:visited { color: maroon }
</STYLE>
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>

<h1>You are not authorized to view this page</h1>
You do not have permission to view this directory or page using the
credentials that you supplied.
<hr>
<p>Please try the following:</p>
<ul>
<li>Contact the Web site administrator if you believe you should be able
to view this directory or page.</li>
<li>Click the <a href="javascript:location.reload()">Refresh</a> button
to try again with different credentials.</li>
</ul>
<h2>HTTP Error 401.1 - Unauthorized: Access is denied due to invalid
credentials.<br>Internet Information Services (IIS)</h2>
<hr>
<p>Technical Information (for support personnel)</p>
<ul>
<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>
<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr),
 and search for topics titled <b>Authentication</b>, <b>Access
Control</b>, and <b>About Custom Error Messages</b>.</li>
</ul>

</TD></TR></TABLE></BODY></HTML>
HTTP/1.1 401 Unauthorized
Content-Length: 1539
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Mon, 24 Jul 2006 15:22:39 GMT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html;
charset=Windows-1252">
<STYLE type="text/css">
  BODY { font: 8pt/12pt verdana }
  H1 { font: 13pt/15pt verdana }
  H2 { font: 8pt/12pt verdana }
  A:link { color: red }
  A:visited { color: maroon }
</STYLE>
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>

<h1>You are not authorized to view this page</h1>
You do not have permission to view this directory or page using the
credentials that you supplied.
<hr>
<p>Please try the following:</p>
<ul>
<li>Contact the Web site administrator if you believe you should be able
to view this directory or page.</li>
<li>Click the <a href="javascript:location.reload()">Refresh</a> button
to try again with different credentials.</li>
</ul>
<h2>HTTP Error 401.1 - Unauthorized: Access is denied due to invalid
credentials.<br>Internet Information Services (IIS)</h2>
<hr>
<p>Technical Information (for support personnel)</p>
<ul>
<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>
<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr),
 and search for topics titled <b>Authentication</b>, <b>Access
Control</b>, and <b>About Custom Error Messages</b>.</li>
</ul>

</TD></TR></TABLE></BODY></HTML> 




This message may contain confidential and/or privileged information.  If
you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based on
this message or any information herein.  If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message.  Thank you for your cooperation.



-----Original Message-----
From: Davanum Srinivas [mailto:davanum@gmail.com] 
Sent: Wednesday, July 19, 2006 2:09 PM
To: axis-user@ws.apache.org
Subject: Re: Axis client and .NET Web Service using NTLM security

Can you please try Axis1.4 and also download latest commons http client
jar?

-- dims

On 7/19/06, andrew.j.hahn@wellsfargo.com <andrew.j.hahn@wellsfargo.com>
wrote:
>
>
>
> Hi,
> I have spent about a week researching this and google just isn't 
> getting me a viable working solution.  Please advise if possible.
>
> I am using Axis code which I generated using wsdl2java.  I need to 
> communicate with a .NET web service that uses the ntlm authentication 
> scheme.  I do not want to go the client-config.wsdd route.  I would 
> rather specify that I want to use the CommonsHTTPSender class
programatically.
>
> In my generated axis stub (and I wish I didn't have to modify a 
> stub..) I have added the following lines of code to the createCall() 
> method (it is surrounded by comments):
>
>
> <CODE>
> protected org.apache.axis.client.Call createCall() throws 
> java.rmi.RemoteException {
>    try {
>        org.apache.axis.client.Call _call = 
> (org.apache.axis.client.Call) super.service.createCall();
>
>        // Use HttpClient for ntlm. - start
>        org.apache.axis.transport.http.CommonsHTTPSender
> reqConnectionHandler = new
> org.apache.axis.transport.http.CommonsHTTPSender();
>
>        org.apache.axis.transport.http.CommonsHTTPSender
> respConnectionHandler = new
> org.apache.axis.transport.http.CommonsHTTPSender();
>
>
> _call.setClientHandlers(reqConnectionHandler,respConnectionHandler);
>
>        super.setUsername("QA-DOMAIN\\andyh");
>        super.setPassword("VikesDominatePackers");
>        // Use HttpClient for ntlm. - end
>
>        if (super.maintainSessionSet) {
>            _call.setMaintainSession(super.maintainSession);
>        }
>
>        ...
> </CODE>
>
>
> The resulting POST from TCPMON is this:
>
> POST /imgservice.asmx HTTP/1.1
> Content-Type: text/xml; charset=utf-8
> SOAPAction:
> "http://wellsfargo.com/provide/image/performView/2005/"
> Authorization: Basic QUQfGN5UXGFJeUdIldhdGVyMTImQPA==
> User-Agent: Jakarta Commons-HttpClient/3.0.1
> Host: localhost:9001
> Content-Length: 559
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
>
> This is the resulting error from my java console:
>
> - Unable to find required classes (javax.activation.DataHandler and 
> javax.mail.internet.MimeMultipart). Attachment support is disabled.
>
> - ntlm authentication scheme selected
> - Failure authenticating with NTLM <any realm>@localhost:9001
> - Error in ezimg service.  AxisFault caught.  MessageId: null 
> AxisFault
>  faultCode: {http://xml.apache.org/axis/}HTTP
>  faultSubcode:
>  faultString: (401)Unauthorized
>  faultActor:
>  faultNode:
>  faultDetail:
>         {}:return code:  401
>
>
> So it appears NTLM is being used because of the second line output 
> above, however the TCPMON output states that BASIC authentication is 
> being used.  I am very confused by this.  Thanks for helping!!!!
>
> Andy
>
>
>
>
> Andrew Hahn
> HCFTG - Sales Technology Group
> Technology Information Group
>
>
> This message may contain confidential and/or privileged information.  
> If you are not the addressee or authorized to receive this for the 
> addressee, you must not use, copy, disclose, or take any action based 
> on this message or any information herein.  If you have received this 
> message in error, please advise the sender immediately by reply e-mail
and delete this message.
> Thank you for your cooperation.
>
>


--
Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service
Developers)

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org

Mime
View raw message