Just a warning, I am very new to WS.
I have a Simple HTTP Authentication working for this WS Client.
However, I would like to get Digest or NTLM working.
So, I am currently going down the Digest path.
Below is my WS Client code:
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime",
"true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header",
"debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
"debug");
HttpClient client = new HttpClient();
//client.getParams().setAuthenticationPreemptive(true);
UsernamePasswordCredentials upc = new
UsernamePasswordCredentials("pcable", "password");
AuthScope as = new AuthScope(AuthScope.ANY_SCHEME,
AuthScope.ANY_PORT,
AuthScope.ANY_REALM);
client.getState().setCredentials(as, upc);
try {
GetMethod gm = new
GetMethod("http://12nxng1-d630.drhorton.com/wstest/WebService.asmx/HelloWorld");
int status = client.executeMethod(gm);
System.out.println("Response Status: "+ status);
String result = gm.getResponseBodyAsString();
System.out.println(result);
} catch (IOException e) {
e.printStackTrace();
}
I am getting the following result:
2009/04/16 14:44:36:030 CDT [DEBUG] HttpClient - Java version: 1.6.0
2009/04/16 14:44:36:030 CDT [DEBUG] HttpClient - Java vendor: Sun
Microsystems Inc.
2009/04/16 14:44:36:030 CDT [DEBUG] HttpClient - Java class path:
C:\Tools\MyEclipse-Workspaces\MyEclipse-6.0.1\Workspace-Base\MapsOnDemandWSTEst\WebRoot\WEB-INF\classes;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\activation-1.1.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\commons-beanutils-1.7.0.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\commons-codec-1.3.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\commons-logging-1.0.4.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jaxws-api-2.0.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jaxen-1.1-beta-9.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jdom-1.0.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\mail-1.4.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\saaj-api-1.3.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\saaj-impl-1.3.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\spring-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\stax-api-1.0.1.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\wsdl4j-1.6.1.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\wstx-asl-3.2.0.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xbean-2.2.0.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xbean-spring-2.8.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-aegis-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-annotations-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-core-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-java5-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-jaxws-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-spring-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-jsr181-api-1.0-M1.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jsr173_api-1.0.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\XmlSchema-1.1.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-jaxb2-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jaxb-api-2.0.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jaxb-impl-2.0.1.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jaxb-xjc-2.0.1.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-jaxb-1.1.2.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jaxb-api-1.0.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\jaxb-impl-1.0.5.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\relaxngDatatype-20050913.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\stax-utils-20040917.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xsdlib-20050913.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xml-apis-1.0.b2.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xercesImpl-2.6.2.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-xmlbeans-1.2.6.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\commons-attributes-api-2.1.jar;C:\Tools\MyEclipse-6.0.1-GA\eclipse\plugins\com.genuitec.eclipse.ws.xfire_6.0.1.zmyeclipse601200710\data\1.2\lib\xfire-generator-1.2.6.jar;C:\Tools\MyEclipse-Workspaces\MyEclipse-6.0.1\Workspace-Base\MapsOnDemandWSTEst\WebRoot\WEB-INF\lib\bcprov-jdk16-142.jar;C:\Tools\MyEclipse-Workspaces\MyEclipse-6.0.1\Workspace-Base\MapsOnDemandWSTEst\WebRoot\WEB-INF\lib\commons-httpclient-3.1.jar
2009/04/16 14:44:36:030 CDT [DEBUG] HttpClient - Operating system name:
Windows XP
2009/04/16 14:44:36:030 CDT [DEBUG] HttpClient - Operating system
architecture: x86
2009/04/16 14:44:36:030 CDT [DEBUG] HttpClient - Operating system version:
5.1
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - SUN 1.6: SUN (DSA
key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom;
X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX
CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy;
JavaLoginConfig Configuration)
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - SunRsaSign 1.5: Sun RSA
signature provider
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - SunJSSE 1.6: Sun JSSE
provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - SunJCE 1.6: SunJCE Provider
(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE,
Diffie-Hellman, HMAC)
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - SunJGSS 1.0: Sun (Kerberos
v5, SPNEGO)
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - SunSASL 1.5: Sun SASL
provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL,
PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - XMLDSig 1.0: XMLDSig (DOM
XMLSignatureFactory; DOM KeyInfoFactory)
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - SunPCSC 1.6: Sun PC/SC
provider
2009/04/16 14:44:36:108 CDT [DEBUG] HttpClient - SunMSCAPI 1.6: Sun's
Microsoft Crypto API provider
2009/04/16 14:44:36:108 CDT [DEBUG] DefaultHttpParams - Set parameter
http.useragent = Jakarta Commons-HttpClient/3.1
2009/04/16 14:44:36:108 CDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.version = HTTP/1.1
2009/04/16 14:44:36:108 CDT [DEBUG] DefaultHttpParams - Set parameter
http.connection-manager.class = class
org.apache.commons.httpclient.SimpleHttpConnectionManager
2009/04/16 14:44:36:108 CDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.cookie-policy = default
2009/04/16 14:44:36:108 CDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.element-charset = US-ASCII
2009/04/16 14:44:36:108 CDT [DEBUG] DefaultHttpParams - Set parameter
http.protocol.content-charset = ISO-8859-1
2009/04/16 14:44:36:124 CDT [DEBUG] DefaultHttpParams - Set parameter
http.method.retry-handler =
org.apache.commons.httpclient.defaulthttpmethodretryhand...@5329c5
2009/04/16 14:44:36:124 CDT [DEBUG] DefaultHttpParams - Set parameter
http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE, dd-MMM-yy
HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy HH:mm:ss z, EEE,
dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE dd-MMM-yyyy HH:mm:ss
z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy HH-mm-ss z, EEE dd-MMM-yy
HH:mm:ss z, EEE dd MMM yy HH:mm:ss z, EEE,dd-MMM-yy HH:mm:ss z,
EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy HH:mm:ss z]
2009/04/16 14:44:36:170 CDT [DEBUG] HttpConnection - Open connection to
12nxng1-d630.drhorton.com:80
2009/04/16 14:44:36:186 CDT [DEBUG] header - >> "GET
/wstest/WebService.asmx/HelloWorld HTTP/1.1[\r][\n]"
2009/04/16 14:44:36:186 CDT [DEBUG] HttpMethodBase - Adding Host request
header
2009/04/16 14:44:36:202 CDT [DEBUG] header - >> "User-Agent: Jakarta
Commons-HttpClient/3.1[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - >> "Host:
12nxng1-d630.drhorton.com[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - >> "[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "HTTP/1.1 401 Access
Denied[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "HTTP/1.1 401 Access
Denied[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "Server:
Microsoft-IIS/5.1[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "Date: Thu, 16 Apr 2009
19:44:36 GMT[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "Connection: close[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "Content-Length:
4431[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "WWW-Authenticate: Digest
qop="auth", realm="drhorton.com",
nonce="caa2e77fe8b5fa33107124200000ce2d720c6fbd4e75247692c66883eab0"[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "Content-Type:
text/html[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] header - << "[\r][\n]"
2009/04/16 14:44:36:202 CDT [DEBUG] HttpMethodDirector - Authorization
required
2009/04/16 14:44:36:217 CDT [DEBUG] AuthChallengeProcessor - Supported
authentication schemes in the order of preference: [ntlm, digest, basic]
2009/04/16 14:44:36:217 CDT [DEBUG] AuthChallengeProcessor - Challenge for
ntlm authentication scheme not available
2009/04/16 14:44:36:217 CDT [INFO] AuthChallengeProcessor - digest
authentication scheme selected
2009/04/16 14:44:36:217 CDT [DEBUG] AuthChallengeProcessor - Using
authentication scheme: digest
2009/04/16 14:44:36:217 CDT [DEBUG] AuthChallengeProcessor - Authorization
challenge processed
2009/04/16 14:44:36:217 CDT [DEBUG] HttpMethodDirector - Authentication
scope: DIGEST 'drhorton.com'@12nxng1-d630.drhorton.com:80
2009/04/16 14:44:36:217 CDT [DEBUG] HttpMethodDirector - Retry
authentication
2009/04/16 14:44:36:217 CDT [DEBUG] HttpMethodBase - Should close connection
in response to directive: close
2009/04/16 14:44:36:217 CDT [DEBUG] HttpConnection - Connection is locked.
Call to releaseConnection() ignored.
2009/04/16 14:44:36:217 CDT [DEBUG] HttpMethodDirector - Authenticating with
DIGEST 'drhorton.com'@12nxng1-d630.drhorton.com:80
2009/04/16 14:44:36:217 CDT [DEBUG] HttpMethodParams - Credential charset
not configured, using HTTP element charset
2009/04/16 14:44:36:217 CDT [DEBUG] DigestScheme - Using qop method auth
2009/04/16 14:44:36:217 CDT [DEBUG] HttpConnection - Open connection to
12nxng1-d630.drhorton.com:80
2009/04/16 14:44:36:217 CDT [DEBUG] header - >> "GET
/wstest/WebService.asmx/HelloWorld HTTP/1.1[\r][\n]"
2009/04/16 14:44:36:217 CDT [DEBUG] HttpMethodBase - Adding Host request
header
2009/04/16 14:44:36:217 CDT [DEBUG] header - >> "User-Agent: Jakarta
Commons-HttpClient/3.1[\r][\n]"
2009/04/16 14:44:36:217 CDT [DEBUG] header - >> "Authorization: Digest
username="pcable", realm="drhorton.com",
nonce="caa2e77fe8b5fa33107124200000ce2d720c6fbd4e75247692c66883eab0",
uri="/wstest/WebService.asmx/HelloWorld",
response="f53f71f559de454b64ded01ae3995aab", qop=auth, nc=00000001,
cnonce="aa5b8064a0bc5c20f1fe903d0123c07c"[\r][\n]"
2009/04/16 14:44:36:217 CDT [DEBUG] header - >> "Host:
12nxng1-d630.drhorton.com[\r][\n]"
2009/04/16 14:44:36:217 CDT [DEBUG] header - >> "[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "HTTP/1.1 401 Access
Denied[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "HTTP/1.1 401 Access
Denied[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "Server:
Microsoft-IIS/5.1[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "Date: Thu, 16 Apr 2009
19:44:36 GMT[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "Connection: close[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "Content-Length:
4280[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "WWW-Authenticate: Digest
qop="auth", realm="drhorton.com",
nonce="08db52627acbaf001071242000004dadf199bd209256d83b5e588addacc7"[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "Content-Type:
text/html[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] header - << "[\r][\n]"
2009/04/16 14:44:36:249 CDT [DEBUG] HttpMethodDirector - Authorization
required
2009/04/16 14:44:36:249 CDT [DEBUG] AuthChallengeProcessor - Using
authentication scheme: digest
2009/04/16 14:44:36:249 CDT [DEBUG] AuthChallengeProcessor - Authorization
challenge processed
2009/04/16 14:44:36:249 CDT [DEBUG] HttpMethodDirector - Authentication
scope: DIGEST 'drhorton.com'@12nxng1-d630.drhorton.com:80
2009/04/16 14:44:36:249 CDT [DEBUG] HttpMethodDirector - Credentials
required
2009/04/16 14:44:36:249 CDT [DEBUG] HttpMethodDirector - Credentials
provider not available
2009/04/16 14:44:36:249 CDT [INFO] HttpMethodDirector - Failure
authenticating with DIGEST 'drhorton.com'@12nxng1-d630.drhorton.com:80
2009/04/16 14:44:36:249 CDT [DEBUG] HttpMethodBase - Buffering response body
2009/04/16 14:44:36:249 CDT [DEBUG] HttpMethodBase - Should close connection
in response to directive: close
2009/04/16 14:44:36:249 CDT [DEBUG] HttpConnection - Releasing connection
back to connection manager.
2009/04/16 14:44:36:249 CDT [DEBUG] HttpMethodBase - Default charset used:
ISO-8859-1
Response Status: 401
I have seen other items like this in these forums, but I am just not getting
what I need to change to fix things. Any help would be greatly appreciated.
Thanks,
PCable
--
View this message in context:
http://www.nabble.com/WS-Digest-Authentication-Issues-tp23085159p23085159.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]