Martin

FYI, I googled some more, It could be because of some flags on your Win2K box:

http://www.google.com/search?q=NTLMv2+HTTPClient
http://support.microsoft.com/kb/239869/EN-US/
http://support.microsoft.com/default.aspx?scid=kb;en-us;272129

-- dims

On 6/30/05, Martin Woodward <[EMAIL PROTECTED]> wrote:
> Thanks all,
> 
> When I take my same web service and deploy it on a Windows Server 2003
> box (running IIS 6) rather than the Windows 2000 workstation server
> that is was running on it works fine!!  This is not a problem for me
> as the service I want to talk to will be running on a Windows 2003
> environment, I had just been using a local workstation to play with.
> 
> I'll still dig around, see if I can see what the problem is, but it
> looks to be some odd behaviour with IIS5 running on the workstation -
> which sounds plausible.
> 
> Thanks for all your help, good to see that NTLM authentication does
> indeed work and thanks to Dexter for clearly documenting all the steps
> taken to get it working.
> 
> Regards,
> 
> Martin.
> 
> On 29/06/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > your mileage might be different but I got the following to
> >
> > work.
> >
> > Server:
> >
> > windows 2003, .net web service with a single helloWorld method,
> >
> > Service1.asmx Properties the "Enable anonymous access" is
> >
> > unchecked and only "Integrated Windows authentication" is enabled.
> >
> > Client:
> >
> > same box, axis 1.2, java 1.5.0_01-b08. Able to call the .net
> >
> > web service.
> >
> > I did the following
> >
> > 0. Ran WSDL2Java to build the stub classes
> >
> > 1. In one of the generated classes I added my username, password
> >
> >  Service1SoapStub.java
> >
> >  ...
> >
> >  _call.setUsername("<domain>\\<username>");
> >
> >  _call.setPassword("<my password>");
> >
> > 3. compiled the files
> >
> > 4. created a client-config.wsdd file, I got this from the
> >
> >  axis.jar file. Updated
> >
> >  http ... http.CommonsHTTPSender
> >
> > 5. add this to CLASSPATH before the axis.jar
> >
> > 6. also added commons-httpclient-3.0-rc3.jar
> >
> >   and commons-codec-1.3.jar
> >
> > Cheers
> >
> > --- On Tue 06/28, Martin Woodward < [EMAIL PROTECTED] > wrote:
> >
> > From: Martin Woodward [mailto: [EMAIL PROTECTED]
> >
> > To: [email protected]
> >
> > Date: Tue, 28 Jun 2005 15:05:37 +0100
> >
> > Subject: Re: NTLM Authentication (again)
> >
> > The latest version (3.0 RC3) of the Commons HttpClient works just 
> > fine<br>with NTLM.  Which suggests to me that something is going funny in 
> > the<br>org.apache.axis.transport.http.CommonsHTTPSender class.  I'll 
> > dig<br>around in the CommonsHTTPSender class, but I was wondering if 
> > anyone<br>had come across this before or actually got NTLM 
> > working...<br><br>Below is the code I used that just used the Commons 
> > HTTPClient class<br>to get an NTLM protected message (changed slightly to 
> > protect the<br>innocent).  I tried it against the same web service method 
> > that my<br>WDSL2Java generated call eventually winds up 
> > calling...<br><br>-----<br><br>package com.mrwpro.vsts.play;<br><br>import 
> > java.io.IOException;<br><br>import 
> > org.apache.commons.httpclient.Credentials;<br>import 
> > org.apache.commons.httpclient.HttpClient;<br>import 
> > org.apache.commons.httpclient.HttpException;<br>import 
> > org.apache.commons.httpclient.HttpMethodBase;<br>import
> > org.apache.commons.httpclient.NTCredentials;<br>import 
> > org.apache.commons.httpclient.auth.AuthScope;<br>import 
> > org.apache.commons.httpclient.methods.GetMethod;<br><br>/**<br> * Get a 
> > NTLM secured page. <br> * @author martinwoodward<br> */<br>public class 
> > NTLMHttpTest {<br><br>  public static void main(String[] args) {<br>        
> >      <br>    HttpClient httpClient = new HttpClient();<br>    Credentials 
> > credentials =  new NTCredentials("username",<br>"password", 
> > "remoteMachine", "MY_DOMAIN");<br>    
> > httpClient.getState().setCredentials(AuthScope.ANY,credentials);<br>    
> > HttpMethodBase method = 
> > new<br>GetMethod("http://remoteMachine/WebService/MyService.asmx/WhoAmI";);<br>
> >    <br>    try {<br>      int returnCode = 
> > httpClient.executeMethod(method);<br>      String response = 
> > method.getResponseBodyAsString();<br>      System.out.println("Response: " 
> > + response);<br>    } catch (HttpException e) {<br>      
> > e.printStackTrace();<br>    } catch (IOException e) {<br>      
> > e.printStackTrace();<br>
> > }<br>  <br>  
> > }<br>}<br><br>-----<br><br>Thanks,<br><br>Martin.<br><br><br><br><br><br>On 
> > 28/06/05, Evgeny Beskrovny <[EMAIL PROTECTED]> wrote:<br>> I suggest you to 
> > write the code using the classes of Apache that connect to<br>> the NTLM 
> > server and see if it works. There is a big chance that it won't<br>> work 
> > since as far as I remember they don't support different parameters<br>> 
> > that can be set in NTLM for example usage of NTLM2 that server during 
> > the<br>> NTLM handshake might prescribe client to do.<br>> Evgeny<br>> 
> > <br>>             Martin Woodward<br>>             <martin.woodward@<br>>   
> >           gmail.com>                                                 
> > To<br>>                                       [email protected]<br>>  
> >            06/28/2005 01:30                                           
> > cc<br>>             PM<br>>                                                 
> >                   Subject<br>>                                       Re: 
> > NTLM Authentication
> > (again)<br>>             Please respond to<br>>             [EMAIL 
> > PROTECTED]<br>>                  he.org<br>> <br>> I'm pretty sure that 
> > that the Commons HTTPClient implementation (used<br>> by CommonsHTTPSender) 
> > has an implementation of NTLM in 3.0-RC3.  If I<br>> take out my 
> > credentials from the call then I get the following error<br>> when talking 
> > via the proxy<br>> <br>> No credentials available for NTLM <any 
> > realm>@mymachine:80<br>> <br>> Which would suggest that it is the Commons 
> > HTTPClient code that<br>> negotiating, not TCPMon.<br>> <br>> I am not 
> > creating the HTTP connection directly.  I am using a<br>> WSDL2Java 
> > generated stub which I have added a couple of lines to add<br>> my 
> > credentials to the _call in the createCall method.  I have then<br>> used 
> > the client-config.wsdd to override the default transport<br>> implementaion 
> > to the Commons one (which has NTLM support)<br>> <br>> Below if the 
> > contents of my client-config.msdd file...<br>> <br>> <?xml version="1.0"
> > encoding="UTF-8"?><br>> <deployment name="defaultClientConfig"<br>> 
> > xmlns="http://xml.apache.org/axis/wsdd/";<br>> 
> > xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";><br>>  
> > <globalConfiguration><br>>    <parameter name="disablePrettyXML" 
> > value="true"/><br>>  </globalConfiguration><br>>  <transport 
> > name="http"<br>> 
> > pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/><br>>  <!-- 
> > transport name="http"<br>> 
> > pivot="java:org.apache.axis.transport.http.HTTPSender"/ --><br>>  
> > <transport name="local"<br>> 
> > pivot="java:org.apache.axis.transport.local.LocalSender"/><br>>  <transport 
> > name="java"<br>> 
> > pivot="java:org.apache.axis.transport.java.JavaSender"/><br>> 
> > </deployment><br>> <br>> I think it is actually the<br>> 
> > org.apache.axis.transport.http.CommonsHTTPSender class that creates<br>> 
> > the URL connection - please let me know if I doing something daft or<br>> 
> > have mis-understood your point.<br>> <br>> Cheers,<br>> <br>> Martin.<br>> 
> > <br>> On 28/06/05, Evgeny Beskrovny
> > <[EMAIL PROTECTED]> wrote:<br>> > Hi,<br>> > I think the reason it doesn't 
> > work for you is because in order to make it<br>> > work you need to have a 
> > Sun implementation of HTTPUrlConnection on a<br>> > client, while here as I 
> > understand you use HttpClient of Apache that<br>> might<br>> > have no 
> > implementation of NTLM. When you connect to a proxy it internally<br>> > 
> > uses Sun implementation of HTTPUrlConnection so it works.<br>> > When you 
> > create a URL on your client you would better use it this way<br>> ><br>> > 
> > handler = new sun.net.www.protocol.http.Handler();<br>> > urlToConnect    = 
> > new URL (null, urlPath.toString(),handler);<br>> > URLConnection connection 
> > = urlToConnect.openConnection();<br>> > Try this and see if it works.<br>> 
> > > Evgeny<br>> ><br>> >             Martin Woodward<br>> >             
> > <martin.woodward@<br>> >             gmail.com>                             
> >                     To<br>> >
> > [email protected]<br>> >             06/27/2005 08:30                 
> >                           cc<br>> >             PM<br>> >                   
> >                                                 Subject<br>> >              
> >                          NTLM Authentication (again)<br>> >             
> > Please respond to<br>> >             [EMAIL PROTECTED]<br>> >               
> >    he.org<br>> ><br>> ><br>> > Hi,<br>> ><br>> > I'm trying to talk to a 
> > web service that requires NTLM authentication<br>> > for my sins.  The good 
> > news is that it works, the bad news is that I<br>> > have to proxy the 
> > request through a local instance of TCPmon to get it<br>> > to work.  Does 
> > this sound familiar to anyone, I could very possibly be<br>> > me doing 
> > something dumb...<br>> ><br>> > I am using axis-1_2_1, 
> > commons-httpclient-3.0-rc3, commons-codec-1.3<br>> > on j2sdk1.4.2_08 
> > running in Windows XP Pro SP2.<br>> ><br>> > As I say, everything works 
> > fine if I run up TCPMonitor on my machine<br>> >
> > and then include the following lines in my client...<br>> ><br>> > 
> > System.setProperty("http.proxyHost", "localhost");<br>> > 
> > System.setProperty("http.proxyPort", "8888");<br>> ><br>> > I've allready 
> > edited my stub to add the username/password and added a<br>> > 
> > client-config.wsdd to point to the CommonsHTTPSender.<br>> ><br>> > Below 
> > is the stack trace when I don't have the web service call proxied:-<br>> 
> > ><br>> > AxisFault<br>> > faultCode:<br>> 
> > {http://schemas.xmlsoap.org/soap/envelope/}Server.userException<br>> > 
> > faultSubcode:<br>> > faultString: java.net.SocketException: Connection 
> > reset<br>> > faultActor:<br>> > faultNode:<br>> > faultDetail:<br>> ><br>> 
> > > {http://xml.apache.org/axis/}stackTrace:java.net.SocketException:<br>> > 
> > Connection reset<br>> >             at<br>> 
> > java.net.SocketInputStream.read(SocketInputStream.java:168)<br>> >          
> >    at<br>> > 
> > java.io.BufferedInputStream.fill(BufferedInputStream.java:183)<br>> >       
> >       at<br>> >
> > java.io.BufferedInputStream.read(BufferedInputStream.java:201)<br>> >       
> >       at<br>> > 
> > org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77)<br>>
> >  >             at<br>> > 
> > org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105)<br>> 
> > >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1110)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1391)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1592)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)<br>>
> >  <br>> ><br>> >
> > at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:393)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)<br>>
> >  >             at<br>> ><br>> 
> > org.apache.axis.transport.http.CommonsHTTPSender.invoke(CommonsHTTPSender.java:188)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)<br>>
> >  <br>> ><br>> >             at<br>> > 
> > org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)<br>> >         
> >     at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)<br>> >       
> >       at<br>> > 
> > org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)<br>> >        
> >      at org.apache.axis.client.Call.invokeEngine(Call.java:2765)<br>> >     
> >         at
> > org.apache.axis.client.Call.invoke(Call.java:2748)<br>> >             at 
> > org.apache.axis.client.Call.invoke(Call.java:2424)<br>> >             at 
> > org.apache.axis.client.Call.invoke(Call.java:2347)<br>> >             at 
> > org.apache.axis.client.Call.invoke(Call.java:1804)<br>> >             at 
> > SNIP.whoAmI(SNIP.java:430)<br>> >             at 
> > com.mrwpro.vsts.play.TestClient.main(TestClient.java:30)<br>> ><br>> >      
> >        {http://xml.apache.org/axis/}hostname:tst-028-04452<br>> ><br>> > 
> > java.net.SocketException: Connection reset<br>> >             at 
> > org.apache.axis.AxisFault.makeFault(AxisFault.java:101)<br>> >             
> > at<br>> ><br>> 
> > org.apache.axis.transport.http.CommonsHTTPSender.invoke(CommonsHTTPSender.java:277)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)<br>>
> >  <br>> ><br>> >             at<br>> > 
> > org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)<br>> >         
> >     at
> > org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)<br>> >             
> > at<br>> > 
> > org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)<br>> >        
> >      at org.apache.axis.client.Call.invokeEngine(Call.java:2765)<br>> >     
> >         at org.apache.axis.client.Call.invoke(Call.java:2748)<br>> >        
> >      at org.apache.axis.client.Call.invoke(Call.java:2424)<br>> >           
> >   at org.apache.axis.client.Call.invoke(Call.java:2347)<br>> >             
> > at org.apache.axis.client.Call.invoke(Call.java:1804)<br>> >             at 
> > SNIP.whoAmI(SNIP.java:430)<br>> >             at 
> > com.mrwpro.vsts.play.TestClient.main(TestClient.java:30)<br>> > Caused by: 
> > java.net.SocketException: Connection reset<br>> >             at<br>> 
> > java.net.SocketInputStream.read(SocketInputStream.java:168)<br>> >          
> >    at<br>> > 
> > java.io.BufferedInputStream.fill(BufferedInputStream.java:183)<br>> >       
> >       at<br>> > 
> > java.io.BufferedInputStream.read(BufferedInputStream.java:201)<br>> >
> >      at<br>> > 
> > org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77)<br>>
> >  >             at<br>> > 
> > org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105)<br>> 
> > >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1110)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1391)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1592)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)<br>>
> >  <br>> ><br>> >             at<br>> ><br>>
> > org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:393)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)<br>>
> >  <br>> ><br>> >             at<br>> ><br>> 
> > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)<br>>
> >  >             at<br>> ><br>> 
> > org.apache.axis.transport.http.CommonsHTTPSender.invoke(CommonsHTTPSender.java:188)<br>>
> >  <br>> ><br>> >             ... 11 more<br>> ><br>> > When I do have it 
> > proxied, you see the 401 error coming back from the<br>> > server, followed 
> > by a 100 with the final 200 response containing the<br>> > answer.  When I 
> > run pointing to the proxy I also get the following<br>> > console 
> > output...<br>> ><br>> > - Unable to find required classes 
> > (javax.activation.DataHandler and<br>> > 
> > javax.mail.internet.MimeMultipart). Attachment support is disabled.<br>> > 
> > - ntlm authentication scheme selected<br>> > -
> > Discarding unexpected response: HTTP/1.1 100 Continue<br>> ><br>> > Any 
> > ideas?<br>> ><br>> > Thanks,<br>> ><br>> > Martin.<br>> ><br>> > --<br>> 
> > ><br>> > http://www.woodwardweb.com<br>> ><br>> ><br>> <br>> --<br>> <br>> 
> > http://www.woodwardweb.com<br>> <br>> <br><br><br>-- 
> > <br><br>http://www.woodwardweb.com<br>
> >
> > _______________________________________________
> >
> >
> 
> 
> --
> 
> http://www.woodwardweb.com
> 


-- 
Davanum Srinivas -http://blogs.cocoondev.org/dims/

Reply via email to