You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Zhaohua Meng <zm...@cgsh.com> on 2005/08/03 20:10:04 UTC

httpclient running in a loop

Gurus,
My following code ends up in the httpclient sending request/getting 
response again and again, when Basic Authentication failed. How do I make 
it stop after "Authorization: Basic dGVzdGltYW46aW1hbjg=" header is sent 
to server and and the server responds with 401 (the second trip)?
Thanks,
Zhaohua

    public static void postWithSupportedAuth() throws IOException, 
HttpException, IllegalAccessException, InstantiationException, 
ClassNotFoundException, ParserConfigurationException {
        String secProviderName = "com.sun.crypto.provider.SunJCE";
        java.security.Provider secProvider = 
(java.security.Provider)Class.forName(secProviderName).newInstance();
        Security.addProvider(secProvider);
        String strURL = 
"http://driman8.cgsh.com/worksite/services/factory.asmx";
        String strXMLFilename = "C:/project/junk/Test/Java 
Source/request.xml";
                String requestDoc = 
ImanageCreateWorkspaceSOAP.getTestDoc(); 
        // Prepare HTTP post
        PostMethod post = new PostMethod(strURL);
                post.setRequestEntity(new StringRequestEntity(requestDoc,
"text/xml; charset=UTF-8","UTF-8"));
        post.setRequestHeader("Content-type", "text/xml; charset=UTF-8");
        post.setRequestHeader("SOAPAction",
                        "\"http://worksite.imanage.com/CreateWorkspace\""
); 
        HttpClient httpclient = new HttpClient(); 
                post.getParams().setVersion(HttpVersion.HTTP_1_1);
 httpclient.getParams().setParameter(CredentialsProvider.PROVIDER,
                new PostXML.MyCredentialsProvider());
                post.setDoAuthentication(true);
        try {
            int result = httpclient.executeMethod(post);
            System.out.println("Response status code: " + result);
            System.out.println("Response body: ");
        } finally {
            // Release current connection to the connection pool once you 
are done
            post.releaseConnection();
        }
     }
This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Re: httpclient running in a loop: the log

Posted by Zhaohua Meng <zm...@cgsh.com>.
The log:

2005/08/03 15:23:31:040 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.useragent = Jakarta Commons-HttpClient/3.0-rc3
2005/08/03 15:23:31:050 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.protocol.version = HTTP/1.1
2005/08/03 15:23:31:050 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.connection-manager.class = class 
org.apache.commons.httpclient.SimpleHttpConnectionManager
2005/08/03 15:23:31:050 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.protocol.cookie-policy = rfc2109
2005/08/03 15:23:31:050 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.protocol.element-charset = US-ASCII
2005/08/03 15:23:31:060 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.protocol.content-charset = ISO-8859-1
2005/08/03 15:23:31:070 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.method.retry-handler = 
org.apache.commons.httpclient.DefaultHttpMethodRetryHandler@4e7f8161
2005/08/03 15:23:31:070 EDT [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]
2005/08/03 15:23:31:220 EDT [DEBUG] HttpClient - -Java version: 1.3.1
2005/08/03 15:23:31:220 EDT [DEBUG] HttpClient - -Java vendor: IBM 
Corporation
2005/08/03 15:23:31:220 EDT [DEBUG] HttpClient - -Java class path: 
C:\Program Files\IBM\WebSphere 
Studio\runtimes\base_v5\java\jre\lib\rt.jar;c:\project\junk\Test\Web 
Content\WEB-INF\classes;C:\Program Files\IBM\WebSphere 
Studio\runtimes\base_v5\lib\j2ee.jar;C:\Program Files\IBM\WebSphere 
Studio\runtimes\base_v5\lib\servletevent.jar;C:\Program 
Files\IBM\WebSphere Studio\runtimes\base_v5\lib\ivjejb35.jar;C:\Program 
Files\IBM\WebSphere 
Studio\runtimes\base_v5\lib\runtime.jar;c:\project\junk\Test\Web 
Content\WEB-INF\lib\taglibs-response.jar;c:\project\junk\Test\Web 
Content\WEB-INF\lib\taglibs-session.jar;c:\project\junk\Test\Web 
Content\WEB-INF\lib\taglibs-request.jar;c:\project\junk\Test\Web 
Content\WEB-INF\lib\taglibs-application.jar;c:\project\junk\Test\Web 
Content\WEB-INF\lib\taglibs-page.jar;C:\Program Files\IBM\WebSphere 
Studio\runtimes\base_v5\lib\soap.jar;C:\Program Files\IBM\WebSphere 
Studio\eclipse\plugins\org.apache.xerces_4.0.7\xmlParserAPIs.jar;C:\Program 
Files\IBM\WebSphere 
Studio\eclipse\plugins\org.apache.xerces_4.0.7\xercesImpl.jar;c:\project\junk\Test\Web 
Content\WEB-INF\lib\webservice-runtime.jar;c:\project\junk\Test\Web 
Content\WEB-INF\lib\xsd.bean.runtime.jar;C:\Program Files\IBM\WebSphere 
Studio\runtimes\base_v5\java\jre\lib\ext\mail.jar;C:\commons-httpclient-3.0-rc3\commons-httpclient-3.0-rc3.jar;C:\commons-logging-1.0.3\commons-logging.jar;C:\commons-codec-1.3\commons-codec-1.3.jar;C:\jce1.2.2\lib\jce1_2_2.jar;C:\jce1.2.2\lib\sunjce_provider.jar
2005/08/03 15:23:31:250 EDT [DEBUG] HttpClient - -Operating system name: 
Windows 2000
2005/08/03 15:23:31:250 EDT [DEBUG] HttpClient - -Operating system 
architecture: x86
2005/08/03 15:23:31:250 EDT [DEBUG] HttpClient - -Operating system 
version: 5.0
2005/08/03 15:23:31:250 EDT [DEBUG] HttpClient - -SUN 1.2: SUN (DSA 
key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; 
X.509 certificates; JKS keystore)
2005/08/03 15:23:31:250 EDT [DEBUG] HttpClient - -IBMJCA 1.0: IBMJCA 
Provider implements the following:
Signature algorithms           : SHA1withDSA, SHA1withRSA, MD5withRSA, 
MD2withRSA 
Key pair generator             : DSA, RSA
Message digest                 : MD2, MD5, SHA-1
Algorithm parameter generator  : DSA
Algorithm parameter            : DSA
Key factory                    : DSA, RSA
Certificate                    : X.509
Secure random                  : IBMSecureRandom
Key store                      : JCAKS

2005/08/03 15:23:31:250 EDT [DEBUG] HttpClient - -SunJCE 1.22: SunJCE 
Provider (implements DES, Triple DES, Blowfish, PBE, Diffie-Hellman, 
HMAC-MD5, HMAC-SHA1)
2005/08/03 15:23:31:260 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.protocol.version = HTTP/1.1
2005/08/03 15:23:31:270 EDT [DEBUG] DefaultHttpParams - -Set parameter 
http.authentication.credential-provider = 
PostXML$MyCredentialsProvider@69d14160
2005/08/03 15:23:31:280 EDT [DEBUG] HttpConnection - -Open connection to 
driman8.cgsh.com:80
2005/08/03 15:23:32:412 EDT [DEBUG] header - ->> "POST 
/worksite/services/factory.asmx HTTP/1.1[\r][\n]"
2005/08/03 15:23:32:412 EDT [DEBUG] HttpMethodBase - -Adding Host request 
header
2005/08/03 15:23:32:432 EDT [DEBUG] header - ->> "Content-type: text/xml; 
charset=UTF-8[\r][\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] header - ->> "SOAPAction: 
"http://worksite.imanage.com/CreateWorkspace"[\r][\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] header - ->> "User-Agent: Jakarta 
Commons-HttpClient/3.0-rc3[\r][\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] header - ->> "Host: 
driman8.cgsh.com[\r][\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] header - ->> "Content-Length: 
1874[\r][\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] header - ->> "[\r][\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] content - ->> "<?xml version="1.0" 
encoding="UTF-8"?>[\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] content - ->> "<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"[\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] content - ->> " 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">[\n]"
2005/08/03 15:23:32:442 EDT [DEBUG] content - ->> "    <soap:Body>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> "        <database 
xmlns="http://worksite.imanage.com">newyork</database>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> "        <templateID 
xmlns="http://worksite.imanage.com">7601</templateID>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> "        <name 
xmlns="http://worksite.imanage.com">myworspace</name>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> "        <description 
xmlns="http://worksite.imanage.com">this is a test</description>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> "        <category 
xmlns="http://worksite.imanage.com">mycagegory</category>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> " <defaultSecurity 
xmlns="http://worksite.imanage.com">imPrivate</defaultSecurity>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> "        <aclItems 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> " <AclItem>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:32:452 EDT [DEBUG] content - ->> " <Name>item 
name</Name>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " 
<Right>imRightReadWrite</Right>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " </AclItem>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " <AclItem>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " <Name>item name 
1</Name>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " 
<Right>imRightRead</Right>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " </AclItem>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " </aclItems>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> "        <profileItems 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " <ProfileItem>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " 
<AttributeID>imProfileDatabase</AttributeID>[\n]"
2005/08/03 15:23:32:462 EDT [DEBUG] content - ->> " <Value>profile 
value</Value>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " </ProfileItem>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " </profileItems>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> "        <notification 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " <Recipients>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " <Recipient>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " <Name>my 
name</Name>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " </Recipient>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " <Recipient>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:32:472 EDT [DEBUG] content - ->> " <Name>my 
name</Name>[\n]"
2005/08/03 15:23:32:532 EDT [DEBUG] content - ->> " </Recipient>[\n]"
2005/08/03 15:23:32:532 EDT [DEBUG] content - ->> " </Recipients>[\n]"
2005/08/03 15:23:32:582 EDT [DEBUG] content - ->> " <Subject>added 
....</Subject>[\n]"
2005/08/03 15:23:32:582 EDT [DEBUG] content - ->> " <Message>your 
workspace ....</Message>[\n]"
2005/08/03 15:23:32:592 EDT [DEBUG] content - ->> " </notification>[\n]"
2005/08/03 15:23:32:592 EDT [DEBUG] content - ->> "    </soap:Body>[\n]"
2005/08/03 15:23:32:592 EDT [DEBUG] content - ->> "</soap:Envelope>[\n]"
2005/08/03 15:23:32:632 EDT [DEBUG] EntityEnclosingMethod - -Request body 
sent
2005/08/03 15:23:32:632 EDT [DEBUG] header - -<< "HTTP/1.1 100 
Continue[\r][\n]"
2005/08/03 15:23:32:642 EDT [INFO] HttpMethodBase - -Discarding unexpected 
response: HTTP/1.1 100 Continue
2005/08/03 15:23:37:769 EDT [DEBUG] header - -<< "HTTP/1.1 401 
Unauthorized[\r][\n]"
2005/08/03 15:23:37:779 EDT [DEBUG] header - -<< "Date: Wed, 03 Aug 2005 
19:23:37 GMT[\r][\n]"
2005/08/03 15:23:37:779 EDT [DEBUG] header - -<< "Server: 
Microsoft-IIS/6.0[\r][\n]"
2005/08/03 15:23:37:779 EDT [DEBUG] header - -<< "WWW-Authenticate: Basic 
realm="cgsh.com"[\r][\n]"
2005/08/03 15:23:37:779 EDT [DEBUG] header - -<< "X-Powered-By: 
ASP.NET[\r][\n]"
2005/08/03 15:23:37:799 EDT [DEBUG] header - -<< "X-AspNet-Version: 
1.1.4322[\r][\n]"
2005/08/03 15:23:37:799 EDT [DEBUG] header - -<< "Set-Cookie: 
ASP.NET_SessionId=ukiwuqvbicxafh3244tt1xin; path=/[\r][\n]"
2005/08/03 15:23:37:799 EDT [DEBUG] header - -<< "Set-Cookie: 
virtualPath=/WorkSite; path=/[\r][\n]"
2005/08/03 15:23:37:799 EDT [DEBUG] header - -<< "Set-Cookie: 
virtualRoot=http://driman8.cgsh.com/WorkSite; path=/[\r][\n]"
2005/08/03 15:23:37:799 EDT [DEBUG] header - -<< "Set-Cookie: keyCode=; 
path=/[\r][\n]"
2005/08/03 15:23:37:799 EDT [DEBUG] header - -<< "Cache-Control: 
private[\r][\n]"
2005/08/03 15:23:37:799 EDT [DEBUG] header - -<< "Content-Length: 
0[\r][\n]"
2005/08/03 15:23:38:170 EDT [DEBUG] HttpMethodBase - -Cookie accepted: 
"$Version=0; ASP.NET_SessionId=ukiwuqvbicxafh3244tt1xin; $Path=/"
2005/08/03 15:23:38:180 EDT [DEBUG] HttpMethodBase - -Cookie accepted: 
"$Version=0; virtualPath=/WorkSite; $Path=/"
2005/08/03 15:23:38:180 EDT [DEBUG] HttpMethodBase - -Cookie accepted: 
"$Version=0; virtualRoot=http://driman8.cgsh.com/WorkSite; $Path=/"
2005/08/03 15:23:38:180 EDT [DEBUG] HttpMethodBase - -Cookie accepted: 
"$Version=0; keyCode=; $Path=/"
2005/08/03 15:23:38:190 EDT [DEBUG] HttpMethodDirector - -Authorization 
required
2005/08/03 15:23:38:210 EDT [DEBUG] AuthChallengeProcessor - -Supported 
authentication schemes in the order of preference: [ntlm, digest, basic]
2005/08/03 15:23:38:220 EDT [DEBUG] AuthChallengeProcessor - -Challenge 
for ntlm authentication scheme not available
2005/08/03 15:23:38:220 EDT [DEBUG] AuthChallengeProcessor - -Challenge 
for digest authentication scheme not available
2005/08/03 15:23:38:220 EDT [INFO] AuthChallengeProcessor - -basic 
authentication scheme selected
2005/08/03 15:23:38:220 EDT [DEBUG] AuthChallengeProcessor - -Using 
authentication scheme: basic
2005/08/03 15:23:38:220 EDT [DEBUG] AuthChallengeProcessor - 
-Authorization challenge processed
2005/08/03 15:23:38:220 EDT [DEBUG] HttpMethodDirector - -Authentication 
scope: BASIC 'cgsh.com'@driman8.cgsh.com:80
2005/08/03 15:23:38:220 EDT [DEBUG] HttpMethodDirector - -Credentials 
required
2005/08/03 15:23:38:220 EDT [DEBUG] HttpMethodDirector - -BASIC 
'cgsh.com'@driman8.cgsh.com:80 new credentials given
2005/08/03 15:23:38:230 EDT [DEBUG] HttpMethodDirector - -Retry 
authentication
2005/08/03 15:23:38:230 EDT [DEBUG] HttpMethodBase - -Resorting to 
protocol version default close connection policy
2005/08/03 15:23:38:230 EDT [DEBUG] HttpMethodBase - -Should NOT close 
connection, using HTTP/1.1
2005/08/03 15:23:38:230 EDT [DEBUG] HttpConnection - -Connection is 
locked.  Call to releaseConnection() ignored.
2005/08/03 15:23:38:240 EDT [DEBUG] HttpMethodDirector - -Authenticating 
with BASIC 'cgsh.com'@driman8.cgsh.com:80
2005/08/03 15:23:38:250 EDT [DEBUG] HttpMethodParams - -Credential charset 
not configured, using HTTP element charset
2005/08/03 15:23:38:250 EDT [DEBUG] header - ->> "POST 
/worksite/services/factory.asmx HTTP/1.1[\r][\n]"
2005/08/03 15:23:38:260 EDT [DEBUG] HttpMethodBase - -Adding Host request 
header
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "Content-type: text/xml; 
charset=UTF-8[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "SOAPAction: 
"http://worksite.imanage.com/CreateWorkspace"[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "User-Agent: Jakarta 
Commons-HttpClient/3.0-rc3[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "Content-Length: 
1874[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "Authorization: Basic 
bXl1c2VybmFtZTpteXBhc3N3b3Jk[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "Host: 
driman8.cgsh.com[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "Cookie: $Version=0; 
ASP.NET_SessionId=ukiwuqvbicxafh3244tt1xin; $Path=/[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "Cookie: $Version=0; 
virtualPath=/WorkSite; $Path=/[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "Cookie: $Version=0; 
virtualRoot=http://driman8.cgsh.com/WorkSite; $Path=/[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "Cookie: $Version=0; 
keyCode=; $Path=/[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] header - ->> "[\r][\n]"
2005/08/03 15:23:38:270 EDT [DEBUG] content - ->> "<?xml version="1.0" 
encoding="UTF-8"?>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> "<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> "    <soap:Body>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> "        <database 
xmlns="http://worksite.imanage.com">newyork</database>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> "        <templateID 
xmlns="http://worksite.imanage.com">7601</templateID>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> "        <name 
xmlns="http://worksite.imanage.com">myworspace</name>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> "        <description 
xmlns="http://worksite.imanage.com">this is a test</description>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> "        <category 
xmlns="http://worksite.imanage.com">mycagegory</category>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " <defaultSecurity 
xmlns="http://worksite.imanage.com">imPrivate</defaultSecurity>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> "        <aclItems 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " <AclItem>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " <Name>item 
name</Name>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " 
<Right>imRightReadWrite</Right>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " </AclItem>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " <AclItem>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " <Name>item name 
1</Name>[\n]"
2005/08/03 15:23:38:280 EDT [DEBUG] content - ->> " 
<Right>imRightRead</Right>[\n]"
2005/08/03 15:23:38:290 EDT [DEBUG] content - ->> " </AclItem>[\n]"
2005/08/03 15:23:38:290 EDT [DEBUG] content - ->> " </aclItems>[\n]"
2005/08/03 15:23:38:290 EDT [DEBUG] content - ->> "        <profileItems 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:38:290 EDT [DEBUG] content - ->> " <ProfileItem>[\n]"
2005/08/03 15:23:38:290 EDT [DEBUG] content - ->> " 
<AttributeID>imProfileDatabase</AttributeID>[\n]"
2005/08/03 15:23:38:290 EDT [DEBUG] content - ->> " <Value>profile 
value</Value>[\n]"
2005/08/03 15:23:38:290 EDT [DEBUG] content - ->> " </ProfileItem>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " </profileItems>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> "        <notification 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Recipients>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Recipient>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Name>my 
name</Name>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " </Recipient>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Recipient>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Name>my 
name</Name>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " </Recipient>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " </Recipients>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Subject>added 
....</Subject>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " <Message>your 
workspace ....</Message>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> " </notification>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> "    </soap:Body>[\n]"
2005/08/03 15:23:38:300 EDT [DEBUG] content - ->> "</soap:Envelope>[\n]"
2005/08/03 15:23:38:310 EDT [DEBUG] EntityEnclosingMethod - -Request body 
sent
2005/08/03 15:23:38:410 EDT [DEBUG] header - -<< "HTTP/1.1 401 
Unauthorized[\r][\n]"
2005/08/03 15:23:38:410 EDT [DEBUG] header - -<< "Content-Length: 
1539[\r][\n]"
2005/08/03 15:23:38:410 EDT [DEBUG] header - -<< "Content-Type: 
text/html[\r][\n]"
2005/08/03 15:23:38:410 EDT [DEBUG] header - -<< "Server: 
Microsoft-IIS/6.0[\r][\n]"
2005/08/03 15:23:38:410 EDT [DEBUG] header - -<< "WWW-Authenticate: Basic 
realm="cgsh.com"[\r][\n]"
2005/08/03 15:23:38:410 EDT [DEBUG] header - -<< "X-Powered-By: 
ASP.NET[\r][\n]"
2005/08/03 15:23:38:410 EDT [DEBUG] header - -<< "Date: Wed, 03 Aug 2005 
19:23:37 GMT[\r][\n]"
2005/08/03 15:23:38:410 EDT [DEBUG] HttpMethodDirector - -Authorization 
required
2005/08/03 15:23:38:410 EDT [DEBUG] AuthChallengeProcessor - -Using 
authentication scheme: basic
2005/08/03 15:23:38:420 EDT [DEBUG] AuthChallengeProcessor - 
-Authorization challenge processed
2005/08/03 15:23:38:420 EDT [DEBUG] HttpMethodDirector - -Authentication 
scope: BASIC 'cgsh.com'@driman8.cgsh.com:80
2005/08/03 15:23:38:420 EDT [DEBUG] HttpMethodDirector - -Credentials 
required
2005/08/03 15:23:38:420 EDT [DEBUG] HttpMethodDirector - -BASIC 
'cgsh.com'@driman8.cgsh.com:80 new credentials given
2005/08/03 15:23:38:420 EDT [DEBUG] HttpMethodDirector - -Retry 
authentication
2005/08/03 15:23:38:420 EDT [DEBUG] content - -<< "<!DOCTYPE HTML PUBLIC 
"-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">[\r][\n]"
2005/08/03 15:23:38:420 EDT [DEBUG] content - -<< "<HTML><HEAD><TITLE>You 
are not authorized to view this page</TITLE>[\r][\n]"
2005/08/03 15:23:38:420 EDT [DEBUG] content - -<< "<META 
HTTP-EQUIV="Content-Type" Content="text/html; 
charset=Windows-1252">[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "<STYLE 
type="text/css">[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "  BODY { font: 8pt/12pt 
verdana }[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "  H1 { font: 13pt/15pt 
verdana }[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "  H2 { font: 8pt/12pt 
verdana }[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "  A:link { color: red 
}[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "  A:visited { color: 
maroon }[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "</STYLE>[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "</HEAD><BODY><TABLE 
width=500 border=0 cellspacing=10><TR><TD>[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "<h1>You are not 
authorized to view this page</h1>[\r][\n]"
2005/08/03 15:23:38:440 EDT [DEBUG] content - -<< "You do not have 
permission to view this directory or page using the credentials that you 
supplied.[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<hr>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<p>Please try the 
following:</p>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<ul>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<li>Contact the Web 
site administrator if you believe you should be able to view this 
directory or page.</li>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<li>Click the <a 
href="javascript:location.reload()">Refresh</a> button to try again with 
different credentials.</li>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "</ul>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<h2>HTTP Error 401.1 - 
Unauthorized: Access is denied due to invalid credentials.<br>Internet "
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "Information Services 
(IIS)</h2>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<hr>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<p>Technical 
Information (for support personnel)</p>[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<ul>[\r][\n]"
2005/08/03 15:23:38:450 EDT [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]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< "<li>Open <b>IIS 
Help</b>, which is accessible in IIS Manager (inetmgr),[\r][\n]"
2005/08/03 15:23:38:450 EDT [DEBUG] content - -<< " and search for topics 
titled <b>Authentication</b>, <b>Access Control</b>, and <b>About Custom 
Error Messages</b>.</li>[\r][\n]"
2005/08/03 15:23:38:460 EDT [DEBUG] content - -<< "</ul>[\r][\n]"
2005/08/03 15:23:38:460 EDT [DEBUG] content - -<< "[\r][\n]"
2005/08/03 15:23:38:460 EDT [DEBUG] content - -<< 
"</TD></TR></TABLE></BODY></HTML>[\r][\n]"
2005/08/03 15:23:38:460 EDT [DEBUG] HttpMethodBase - -Resorting to 
protocol version default close connection policy
2005/08/03 15:23:38:460 EDT [DEBUG] HttpMethodBase - -Should NOT close 
connection, using HTTP/1.1
2005/08/03 15:23:38:460 EDT [DEBUG] HttpConnection - -Connection is 
locked.  Call to releaseConnection() ignored.
2005/08/03 15:23:38:460 EDT [DEBUG] HttpMethodDirector - -Authenticating 
with BASIC 'cgsh.com'@driman8.cgsh.com:80
2005/08/03 15:23:38:470 EDT [DEBUG] HttpMethodParams - -Credential charset 
not configured, using HTTP element charset
2005/08/03 15:23:38:470 EDT [DEBUG] header - ->> "POST 
/worksite/services/factory.asmx HTTP/1.1[\r][\n]"
2005/08/03 15:23:38:470 EDT [DEBUG] HttpMethodBase - -Adding Host request 
header
2005/08/03 15:23:38:470 EDT [DEBUG] header - ->> "Content-type: text/xml; 
charset=UTF-8[\r][\n]"
2005/08/03 15:23:38:470 EDT [DEBUG] header - ->> "SOAPAction: 
"http://worksite.imanage.com/CreateWorkspace"[\r][\n]"
2005/08/03 15:23:38:480 EDT [DEBUG] header - ->> "User-Agent: Jakarta 
Commons-HttpClient/3.0-rc3[\r][\n]"
2005/08/03 15:23:38:480 EDT [DEBUG] header - ->> "Content-Length: 
1874[\r][\n]"
2005/08/03 15:23:38:490 EDT [DEBUG] header - ->> "Authorization: Basic 
bXl1c2VybmFtZTpteXBhc3N3b3Jk[\r][\n]"
2005/08/03 15:23:38:490 EDT [DEBUG] header - ->> "Host: 
driman8.cgsh.com[\r][\n]"
2005/08/03 15:23:38:490 EDT [DEBUG] header - ->> "Cookie: $Version=0; 
ASP.NET_SessionId=ukiwuqvbicxafh3244tt1xin; $Path=/[\r][\n]"
2005/08/03 15:23:38:490 EDT [DEBUG] header - ->> "Cookie: $Version=0; 
virtualPath=/WorkSite; $Path=/[\r][\n]"
2005/08/03 15:23:38:490 EDT [DEBUG] header - ->> "Cookie: $Version=0; 
virtualRoot=http://driman8.cgsh.com/WorkSite; $Path=/[\r][\n]"
2005/08/03 15:23:38:490 EDT [DEBUG] header - ->> "Cookie: $Version=0; 
keyCode=; $Path=/[\r][\n]"
2005/08/03 15:23:38:490 EDT [DEBUG] header - ->> "[\r][\n]"
2005/08/03 15:23:38:490 EDT [DEBUG] content - ->> "<?xml version="1.0" 
encoding="UTF-8"?>[\n]"
2005/08/03 15:23:38:500 EDT [DEBUG] content - ->> "<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"[\n]"
2005/08/03 15:23:38:500 EDT [DEBUG] content - ->> " 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> "    <soap:Body>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> "        <database 
xmlns="http://worksite.imanage.com">newyork</database>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> "        <templateID 
xmlns="http://worksite.imanage.com">7601</templateID>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> "        <name 
xmlns="http://worksite.imanage.com">myworspace</name>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> "        <description 
xmlns="http://worksite.imanage.com">this is a test</description>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> "        <category 
xmlns="http://worksite.imanage.com">mycagegory</category>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> " <defaultSecurity 
xmlns="http://worksite.imanage.com">imPrivate</defaultSecurity>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> "        <aclItems 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> " <AclItem>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> " <Name>item 
name</Name>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> " 
<Right>imRightReadWrite</Right>[\n]"
2005/08/03 15:23:38:520 EDT [DEBUG] content - ->> " </AclItem>[\n]"
2005/08/03 15:23:38:530 EDT [DEBUG] content - ->> " <AclItem>[\n]"
2005/08/03 15:23:38:530 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:38:530 EDT [DEBUG] content - ->> " <Name>item name 
1</Name>[\n]"
2005/08/03 15:23:38:530 EDT [DEBUG] content - ->> " 
<Right>imRightRead</Right>[\n]"
2005/08/03 15:23:38:530 EDT [DEBUG] content - ->> " </AclItem>[\n]"
2005/08/03 15:23:38:530 EDT [DEBUG] content - ->> " </aclItems>[\n]"
2005/08/03 15:23:38:530 EDT [DEBUG] content - ->> "        <profileItems 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:38:621 EDT [DEBUG] content - ->> " <ProfileItem>[\n]"
2005/08/03 15:23:38:621 EDT [DEBUG] content - ->> " 
<AttributeID>imProfileDatabase</AttributeID>[\n]"
2005/08/03 15:23:38:621 EDT [DEBUG] content - ->> " <Value>profile 
value</Value>[\n]"
2005/08/03 15:23:38:621 EDT [DEBUG] content - ->> " </ProfileItem>[\n]"
2005/08/03 15:23:38:621 EDT [DEBUG] content - ->> " </profileItems>[\n]"
2005/08/03 15:23:38:621 EDT [DEBUG] content - ->> "        <notification 
xmlns="http://worksite.imanage.com">[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Recipients>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Recipient>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Name>my 
name</Name>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " </Recipient>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Recipient>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Type>User</Type>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Name>my 
name</Name>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " </Recipient>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " </Recipients>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Subject>added 
....</Subject>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " <Message>your 
workspace ....</Message>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> " </notification>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> "    </soap:Body>[\n]"
2005/08/03 15:23:38:631 EDT [DEBUG] content - ->> "</soap:Envelope>[\n]"
2005/08/03 15:23:38:641 EDT [DEBUG] EntityEnclosingMethod - -Request body 
sent
2005/08/03 15:23:38:641 EDT [DEBUG] header - -<< "HTTP/1.1 401 
Unauthorized[\r][\n]"
2005/08/03 15:23:38:641 EDT [DEBUG] header - -<< "Content-Length: 
1539[\r][\n]"
2005/08/03 15:23:38:641 EDT [DEBUG] header - -<< "Content-Type: 
text/html[\r][\n]"
2005/08/03 15:23:38:641 EDT [DEBUG] header - -<< "Server: 
Microsoft-IIS/6.0[\r][\n]"
2005/08/03 15:23:38:641 EDT [DEBUG] header - -<< "WWW-Authenticate: Basic 
realm="cgsh.com"[\r][\n]"
2005/08/03 15:23:38:641 EDT [DEBUG] header - -<< "X-Powered-By: 
ASP.NET[\r][\n]"
2005/08/03 15:23:38:641 EDT [DEBUG] header - -<< "Date: Wed, 03 Aug 2005 
19:23:37 GMT[\r][\n]"
2005/08/03 15:23:38:641 EDT [DEBUG] HttpMethodDirector - -Authorization 
required
2005/08/03 15:23:38:641 EDT [DEBUG] AuthChallengeProcessor - -Using 
authentication scheme: basic
2005/08/03 15:23:38:641 EDT [DEBUG] AuthChallengeProcessor - 
-Authorization challenge processed
2005/08/03 15:23:38:641 EDT [DEBUG] HttpMethodDirector - -Authentication 
scope: BASIC 'cgsh.com'@driman8.cgsh.com:80
2005/08/03 15:23:38:651 EDT [DEBUG] HttpMethodDirector - -Credentials 
required
2005/08/03 15:23:38:651 EDT [DEBUG] HttpMethodDirector - -BASIC 
'cgsh.com'@driman8.cgsh.com:80 new credentials given
2005/08/03 15:23:38:651 EDT [DEBUG] HttpMethodDirector - -Retry 
authentication
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<!DOCTYPE HTML PUBLIC 
"-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<HTML><HEAD><TITLE>You 
are not authorized to view this page</TITLE>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<META 
HTTP-EQUIV="Content-Type" Content="text/html; 
charset=Windows-1252">[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<STYLE 
type="text/css">[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "  BODY { font: 8pt/12pt 
verdana }[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "  H1 { font: 13pt/15pt 
verdana }[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "  H2 { font: 8pt/12pt 
verdana }[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "  A:link { color: red 
}[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "  A:visited { color: 
maroon }[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "</STYLE>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "</HEAD><BODY><TABLE 
width=500 border=0 cellspacing=10><TR><TD>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<h1>You are not 
authorized to view this page</h1>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "You do not have 
permission to view this directory or page using the credentials that you 
supplied.[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<hr>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<p>Please try the 
following:</p>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<ul>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<li>Contact the Web 
site administrator if you believe you should be able to view this 
directory or page.</li>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "<li>Click the <a 
href="javascript:location.reload()">Refresh</a> button to try again with 
different credentials.</li>[\r][\n]"
2005/08/03 15:23:38:661 EDT [DEBUG] content - -<< "</ul>[\r][\n]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< "<h2>HTTP Error 401.1 - 
Unauthorized: Access is denied due to invalid credentials.<br>Internet "
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< "Information Services 
(IIS)</h2>[\r][\n]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< "<hr>[\r][\n]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< "<p>Technical 
Information (for support personnel)</p>[\r][\n]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< "<ul>[\r][\n]"
2005/08/03 15:23:38:671 EDT [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]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< "<li>Open <b>IIS 
Help</b>, which is accessible in IIS Manager (inetmgr),[\r][\n]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< " and search for topics 
titled <b>Authentication</b>, <b>Access Control</b>, and <b>About Custom 
Error Messages</b>.</li>[\r][\n]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< "</ul>[\r][\n]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< "[\r][\n]"
2005/08/03 15:23:38:671 EDT [DEBUG] content - -<< 
"</TD></TR></TABLE></BODY></HTML>[\r][\n]"
This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Re: httpclient running in a loop: the code

Posted by Zhaohua Meng <zm...@cgsh.com>.
I really appreciate your help.
thanks,
zhaohua
This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Re: httpclient running in a loop: the code

Posted by Oleg Kalnichevski <ol...@apache.org>.
Zhaohua,

I'll look into it. I can expect to get a response from me by the end of
the week the latest.

Oleg


On Wed, 2005-08-03 at 15:36 -0400, Zhaohua Meng wrote:
> Sorry I have to split this mail in 2 since apache.org mail server wont' 
> allow large messages.
> The code:
> 
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.security.Security;
> import java.util.ArrayList;
> import java.util.List;
> 
> import javax.xml.parsers.ParserConfigurationException;
> 
> import org.apache.commons.httpclient.Credentials;
> import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
> import org.apache.commons.httpclient.Header;
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.HttpException;
> import org.apache.commons.httpclient.HttpVersion;
> import org.apache.commons.httpclient.NTCredentials;
> import org.apache.commons.httpclient.UsernamePasswordCredentials;
> import org.apache.commons.httpclient.auth.AuthPolicy;
> import org.apache.commons.httpclient.auth.AuthScheme;
> import org.apache.commons.httpclient.auth.AuthScope;
> import 
> org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
> import org.apache.commons.httpclient.auth.CredentialsProvider;
> import org.apache.commons.httpclient.cookie.CookiePolicy;
> import org.apache.commons.httpclient.methods.GetMethod;
> import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
> import org.apache.commons.httpclient.methods.PostMethod;
> import org.apache.commons.httpclient.methods.StringRequestEntity;
> import org.apache.commons.httpclient.params.HttpMethodParams;
> 
> /**
>  *
>  * This is a sample application that demonstrates
>  * how to use the Jakarta HttpClient API.
>  *
>  * This application sends an XML document
>  * to a remote web server using HTTP POST
>  *
>  * @author Sean C. Sullivan
>  * @author Ortwin Glück
>  * @author Oleg Kalnichevski
>  */
> public class PostXML {
>         private Object password;
> 
>     /**
>      *
>      * Usage:
>      *          java PostXML http://mywebserver:80/ c:\foo.xml
>      *
>      *  @param args command line arguments
>      *                 Argument 0 is a URL to a web server
>      *                 Argument 1 is a local filename
>      *
>      */
>     public static void main(String[] args) throws Exception {
>         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", "debug");
>         System.setProperty(
> "org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", 
> "debug"); 
>         postWithSupportedAuth(); 
>    }
>     public static void postWithSupportedAuth() throws IOException, 
> HttpException, IllegalAccessException, InstantiationException, 
> ClassNotFoundException, ParserConfigurationException {
>         String secProviderName = "com.sun.crypto.provider.SunJCE";
>         java.security.Provider secProvider = 
> (java.security.Provider)Class.forName(secProviderName).newInstance();
>         Security.addProvider(secProvider);
>         String strURL = "
> http://driman8.cgsh.com/worksite/services/factory.asmx";
>         String strXMLFilename = "C:/project/junk/Test/Java 
> Source/request.xml";
>                 String requestDoc = 
> ImanageCreateWorkspaceSOAP.getTestDoc(); 
>         // Prepare HTTP post
>         PostMethod post = new PostMethod(strURL);
>           post.setRequestEntity(new StringRequestEntity(requestDoc,
> "text/xml; charset=UTF-8","UTF-8"));
>         post.setRequestHeader("Content-type", "text/xml; charset=UTF-8");
>         post.setRequestHeader("SOAPAction",
>                         "\"http://worksite.imanage.com/CreateWorkspace\""
> ); 
>         HttpClient httpclient = new HttpClient(); 
>           post.getParams().setVersion(HttpVersion.HTTP_1_1);
>  httpclient.getParams().setParameter(CredentialsProvider.PROVIDER,
>                 new PostXML.MyCredentialsProvider()); 
>         try {
>             int result = httpclient.executeMethod(post);
>             System.out.println("Response status code: " + result);
>             System.out.println("Response body: ");
>         } finally {
>             post.releaseConnection();
>         }
>      }
>     public static void getWithBasicAuth(String url, String username, 
> String password, String host, int port, String domain) throws 
> HttpException, IOException {
>         //http://www.developer.ibm.com/partnerworld/mem/index.html
>                 GetMethod get = new GetMethod(url);
>                 HttpClient httpclient = new HttpClient();
>         httpclient.getState().setCredentials(
>             new AuthScope(host, port,domain), new 
> NTCredentials(username,password,host,domain));
>             int result = httpclient.executeMethod(get);
>             // Display status code
>             System.out.println("Response status code: " + result);
>             // Display response
>             System.out.println("Response body: ");
>             System.out.println(get.getResponseBodyAsString());
>  
> 
>     }
>     public static class MyCredentialsProvider implements 
> CredentialsProvider {
>  
>                 /**
>                  * @see 
> org.apache.commons.httpclient.auth.CredentialsProvider#getCredentials(AuthScheme, 
> String, int, boolean)
>                  */
>                 public Credentials getCredentials(
>                         AuthScheme scheme,
>                         String host,
>                         int port,
>                         boolean proxy)
>                         throws CredentialsNotAvailableException {
>                                 return new UsernamePasswordCredentials(
> "myusername","mypassword");
>                 }
> 
>         }
> }
> 
> This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.


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


Re: httpclient running in a loop: the code

Posted by Oleg Kalnichevski <ol...@apache.org>.
Zhaohua,

I am glad I was of some help. 

Please refer to this resource for details regarding the official venues 
for contributions to the Apache Software Foundation:

http://www.apache.org/foundation/contributing.html

If you want to contribute code to the Jakarta HttpClient project, you
are very welcome to subscribe to the httpclient-dev list and discuss
the best ways to help with the HttpClient development on that list

Cheers,

Oleg

On Thu, Aug 04, 2005 at 10:10:53AM -0400, Zhaohua Meng wrote:
> Oleg,
> 
> Thanks for the prompt response. I followed your suggestion and it worked. 
> Many thanks to you and others who developed such an excellent product.
> Can you direct me to where I can donate some money? I'd like to contribute 
> some code in the future as well.
> 
> Zhaohua
> 
> 
> 
> "Oleg Kalnichevski" <ol...@apache.org> 
> 08/03/2005 06:08 PM
> Please respond to
> "Jakarta Commons Users List" <co...@jakarta.apache.org>
> 
> 
> To
> "Jakarta Commons Users List" <co...@jakarta.apache.org>
> cc
> 
> Subject
> Re: httpclient running in a loop: the code
> 
> 
> 
> 
> 
> 
> Zhaohua,
> 
> It is all very simple. The MyCredentialsProvider class of yours always
> returns the same credentials, which causes HttpClient to produce the
> same authentication response over and over again. HttpClient makes no
> provisions to check whether the same credentials have not been tried
> already. It is the responsibility of the custom CredentialsProvider to
> ensure that the same credentials are not used multiple times for the
> same authentication scope (that is, the same scheme, realm, host, and
> port).
> 
> I do admit this may not be obvious and the javadocs do not reflect this
> assumption. I'll make sure the javasocs get updated
> 
> If you not intend to prompt the user for a new set of credentials [1],
> or retrieve it from elsewhere, you should simply add the credentials to
> the HTTP state and HttpClient will make sure the same credentials are
> not tried multiple times.
> 
> httpclient.getState().setCredentials(
>   new AuthScope("driman8.cgsh.com", 80, "cgsh.com"),
>   new UsernamePasswordCredentials("myusername", "mypassword"));
> 
> Hope this helps
> 
> Oleg
> [1]
> http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/httpclient/trunk/src/examples/InteractiveAuthenticationExample.java?view=markup
> 
> 
> On Wed, 2005-08-03 at 15:36 -0400, Zhaohua Meng wrote: 
> > Sorry I have to split this mail in 2 since apache.org mail server wont' 
> > allow large messages.
> > The code:
> > 
> > import java.io.File;
> > import java.io.FileInputStream;
> > import java.io.IOException;
> > import java.security.Security;
> > import java.util.ArrayList;
> > import java.util.List;
> > 
> > import javax.xml.parsers.ParserConfigurationException;
> > 
> > import org.apache.commons.httpclient.Credentials;
> > import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
> > import org.apache.commons.httpclient.Header;
> > import org.apache.commons.httpclient.HttpClient;
> > import org.apache.commons.httpclient.HttpException;
> > import org.apache.commons.httpclient.HttpVersion;
> > import org.apache.commons.httpclient.NTCredentials;
> > import org.apache.commons.httpclient.UsernamePasswordCredentials;
> > import org.apache.commons.httpclient.auth.AuthPolicy;
> > import org.apache.commons.httpclient.auth.AuthScheme;
> > import org.apache.commons.httpclient.auth.AuthScope;
> > import 
> > org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
> > import org.apache.commons.httpclient.auth.CredentialsProvider;
> > import org.apache.commons.httpclient.cookie.CookiePolicy;
> > import org.apache.commons.httpclient.methods.GetMethod;
> > import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
> > import org.apache.commons.httpclient.methods.PostMethod;
> > import org.apache.commons.httpclient.methods.StringRequestEntity;
> > import org.apache.commons.httpclient.params.HttpMethodParams;
> > 
> > /**
> >  *
> >  * This is a sample application that demonstrates
> >  * how to use the Jakarta HttpClient API.
> >  *
> >  * This application sends an XML document
> >  * to a remote web server using HTTP POST
> >  *
> >  * @author Sean C. Sullivan
> >  * @author Ortwin Gl?ck
> >  * @author Oleg Kalnichevski
> >  */
> > public class PostXML {
> >         private Object password;
> > 
> >     /**
> >      *
> >      * Usage:
> >      *          java PostXML http://mywebserver:80/ c:\foo.xml
> >      *
> >      *  @param args command line arguments
> >      *                 Argument 0 is a URL to a web server
> >      *                 Argument 1 is a local filename
> >      *
> >      */
> >     public static void main(String[] args) throws Exception {
> >         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", "debug");
> >         System.setProperty(
> > 
> "org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", 
> > "debug"); 
> >         postWithSupportedAuth(); 
> >    }
> >     public static void postWithSupportedAuth() throws IOException, 
> > HttpException, IllegalAccessException, InstantiationException, 
> > ClassNotFoundException, ParserConfigurationException {
> >         String secProviderName = "com.sun.crypto.provider.SunJCE";
> >         java.security.Provider secProvider = 
> > (java.security.Provider)Class.forName(secProviderName).newInstance();
> >         Security.addProvider(secProvider);
> >         String strURL = "
> > http://driman8.cgsh.com/worksite/services/factory.asmx";
> >         String strXMLFilename = "C:/project/junk/Test/Java 
> > Source/request.xml";
> >                 String requestDoc = 
> > ImanageCreateWorkspaceSOAP.getTestDoc(); 
> >         // Prepare HTTP post
> >         PostMethod post = new PostMethod(strURL);
> >           post.setRequestEntity(new StringRequestEntity(requestDoc,
> > "text/xml; charset=UTF-8","UTF-8"));
> >         post.setRequestHeader("Content-type", "text/xml; 
> charset=UTF-8");
> >         post.setRequestHeader("SOAPAction",
> >                         "\"http://worksite.imanage.com/CreateWorkspace\
> ""
> > ); 
> >         HttpClient httpclient = new HttpClient(); 
> >           post.getParams().setVersion(HttpVersion.HTTP_1_1);
> >  httpclient.getParams().setParameter(CredentialsProvider.PROVIDER,
> >                 new PostXML.MyCredentialsProvider()); 
> >         try {
> >             int result = httpclient.executeMethod(post);
> >             System.out.println("Response status code: " + result);
> >             System.out.println("Response body: ");
> >         } finally {
> >             post.releaseConnection();
> >         }
> >      }
> >     public static void getWithBasicAuth(String url, String username, 
> > String password, String host, int port, String domain) throws 
> > HttpException, IOException {
> >         //http://www.developer.ibm.com/partnerworld/mem/index.html
> >                 GetMethod get = new GetMethod(url);
> >                 HttpClient httpclient = new HttpClient();
> >         httpclient.getState().setCredentials(
> >             new AuthScope(host, port,domain), new 
> > NTCredentials(username,password,host,domain));
> >             int result = httpclient.executeMethod(get);
> >             // Display status code
> >             System.out.println("Response status code: " + result);
> >             // Display response
> >             System.out.println("Response body: ");
> >             System.out.println(get.getResponseBodyAsString());
> > 
> > 
> >     }
> >     public static class MyCredentialsProvider implements 
> > CredentialsProvider {
> > 
> >                 /**
> >                  * @see 
> > 
> org.apache.commons.httpclient.auth.CredentialsProvider#getCredentials(AuthScheme, 
> 
> > String, int, boolean)
> >                  */
> >                 public Credentials getCredentials(
> >                         AuthScheme scheme,
> >                         String host,
> >                         int port,
> >                         boolean proxy)
> >                         throws CredentialsNotAvailableException {
> >                                 return new UsernamePasswordCredentials(
> > "myusername","mypassword");
> >                 }
> > 
> >         }
> > }
> > 
> > This message is being sent from a law firm and may contain confidential 
> or privileged information.  If you are not the intended recipient, please 
> advise the sender immediately by reply e-mail and delete this message and 
> any attachments without retaining a copy.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 
> 
> 
> This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

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


Re: httpclient running in a loop: the code

Posted by Zhaohua Meng <zm...@cgsh.com>.
Oleg,

Thanks for the prompt response. I followed your suggestion and it worked. 
Many thanks to you and others who developed such an excellent product.
Can you direct me to where I can donate some money? I'd like to contribute 
some code in the future as well.

Zhaohua



"Oleg Kalnichevski" <ol...@apache.org> 
08/03/2005 06:08 PM
Please respond to
"Jakarta Commons Users List" <co...@jakarta.apache.org>


To
"Jakarta Commons Users List" <co...@jakarta.apache.org>
cc

Subject
Re: httpclient running in a loop: the code






Zhaohua,

It is all very simple. The MyCredentialsProvider class of yours always
returns the same credentials, which causes HttpClient to produce the
same authentication response over and over again. HttpClient makes no
provisions to check whether the same credentials have not been tried
already. It is the responsibility of the custom CredentialsProvider to
ensure that the same credentials are not used multiple times for the
same authentication scope (that is, the same scheme, realm, host, and
port).

I do admit this may not be obvious and the javadocs do not reflect this
assumption. I'll make sure the javasocs get updated

If you not intend to prompt the user for a new set of credentials [1],
or retrieve it from elsewhere, you should simply add the credentials to
the HTTP state and HttpClient will make sure the same credentials are
not tried multiple times.

httpclient.getState().setCredentials(
  new AuthScope("driman8.cgsh.com", 80, "cgsh.com"),
  new UsernamePasswordCredentials("myusername", "mypassword"));

Hope this helps

Oleg
[1]
http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/httpclient/trunk/src/examples/InteractiveAuthenticationExample.java?view=markup


On Wed, 2005-08-03 at 15:36 -0400, Zhaohua Meng wrote: 
> Sorry I have to split this mail in 2 since apache.org mail server wont' 
> allow large messages.
> The code:
> 
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.security.Security;
> import java.util.ArrayList;
> import java.util.List;
> 
> import javax.xml.parsers.ParserConfigurationException;
> 
> import org.apache.commons.httpclient.Credentials;
> import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
> import org.apache.commons.httpclient.Header;
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.HttpException;
> import org.apache.commons.httpclient.HttpVersion;
> import org.apache.commons.httpclient.NTCredentials;
> import org.apache.commons.httpclient.UsernamePasswordCredentials;
> import org.apache.commons.httpclient.auth.AuthPolicy;
> import org.apache.commons.httpclient.auth.AuthScheme;
> import org.apache.commons.httpclient.auth.AuthScope;
> import 
> org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
> import org.apache.commons.httpclient.auth.CredentialsProvider;
> import org.apache.commons.httpclient.cookie.CookiePolicy;
> import org.apache.commons.httpclient.methods.GetMethod;
> import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
> import org.apache.commons.httpclient.methods.PostMethod;
> import org.apache.commons.httpclient.methods.StringRequestEntity;
> import org.apache.commons.httpclient.params.HttpMethodParams;
> 
> /**
>  *
>  * This is a sample application that demonstrates
>  * how to use the Jakarta HttpClient API.
>  *
>  * This application sends an XML document
>  * to a remote web server using HTTP POST
>  *
>  * @author Sean C. Sullivan
>  * @author Ortwin Glück
>  * @author Oleg Kalnichevski
>  */
> public class PostXML {
>         private Object password;
> 
>     /**
>      *
>      * Usage:
>      *          java PostXML http://mywebserver:80/ c:\foo.xml
>      *
>      *  @param args command line arguments
>      *                 Argument 0 is a URL to a web server
>      *                 Argument 1 is a local filename
>      *
>      */
>     public static void main(String[] args) throws Exception {
>         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", "debug");
>         System.setProperty(
> 
"org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", 
> "debug"); 
>         postWithSupportedAuth(); 
>    }
>     public static void postWithSupportedAuth() throws IOException, 
> HttpException, IllegalAccessException, InstantiationException, 
> ClassNotFoundException, ParserConfigurationException {
>         String secProviderName = "com.sun.crypto.provider.SunJCE";
>         java.security.Provider secProvider = 
> (java.security.Provider)Class.forName(secProviderName).newInstance();
>         Security.addProvider(secProvider);
>         String strURL = "
> http://driman8.cgsh.com/worksite/services/factory.asmx";
>         String strXMLFilename = "C:/project/junk/Test/Java 
> Source/request.xml";
>                 String requestDoc = 
> ImanageCreateWorkspaceSOAP.getTestDoc(); 
>         // Prepare HTTP post
>         PostMethod post = new PostMethod(strURL);
>           post.setRequestEntity(new StringRequestEntity(requestDoc,
> "text/xml; charset=UTF-8","UTF-8"));
>         post.setRequestHeader("Content-type", "text/xml; 
charset=UTF-8");
>         post.setRequestHeader("SOAPAction",
>                         "\"http://worksite.imanage.com/CreateWorkspace\
""
> ); 
>         HttpClient httpclient = new HttpClient(); 
>           post.getParams().setVersion(HttpVersion.HTTP_1_1);
>  httpclient.getParams().setParameter(CredentialsProvider.PROVIDER,
>                 new PostXML.MyCredentialsProvider()); 
>         try {
>             int result = httpclient.executeMethod(post);
>             System.out.println("Response status code: " + result);
>             System.out.println("Response body: ");
>         } finally {
>             post.releaseConnection();
>         }
>      }
>     public static void getWithBasicAuth(String url, String username, 
> String password, String host, int port, String domain) throws 
> HttpException, IOException {
>         //http://www.developer.ibm.com/partnerworld/mem/index.html
>                 GetMethod get = new GetMethod(url);
>                 HttpClient httpclient = new HttpClient();
>         httpclient.getState().setCredentials(
>             new AuthScope(host, port,domain), new 
> NTCredentials(username,password,host,domain));
>             int result = httpclient.executeMethod(get);
>             // Display status code
>             System.out.println("Response status code: " + result);
>             // Display response
>             System.out.println("Response body: ");
>             System.out.println(get.getResponseBodyAsString());
> 
> 
>     }
>     public static class MyCredentialsProvider implements 
> CredentialsProvider {
> 
>                 /**
>                  * @see 
> 
org.apache.commons.httpclient.auth.CredentialsProvider#getCredentials(AuthScheme, 

> String, int, boolean)
>                  */
>                 public Credentials getCredentials(
>                         AuthScheme scheme,
>                         String host,
>                         int port,
>                         boolean proxy)
>                         throws CredentialsNotAvailableException {
>                                 return new UsernamePasswordCredentials(
> "myusername","mypassword");
>                 }
> 
>         }
> }
> 
> This message is being sent from a law firm and may contain confidential 
or privileged information.  If you are not the intended recipient, please 
advise the sender immediately by reply e-mail and delete this message and 
any attachments without retaining a copy.


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




This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Re: httpclient running in a loop: the code

Posted by Oleg Kalnichevski <ol...@apache.org>.
Zhaohua,

It is all very simple. The MyCredentialsProvider class of yours always
returns the same credentials, which causes HttpClient to produce the
same authentication response over and over again. HttpClient makes no
provisions to check whether the same credentials have not been tried
already. It is the responsibility of the custom CredentialsProvider to
ensure that the same credentials are not used multiple times for the
same authentication scope (that is, the same scheme, realm, host, and
port).

I do admit this may not be obvious and the javadocs do not reflect this
assumption. I'll make sure the javasocs get updated

If you not intend to prompt the user for a new set of credentials [1],
or retrieve it from elsewhere, you should simply add the credentials to
the HTTP state and HttpClient will make sure the same credentials are
not tried multiple times.

httpclient.getState().setCredentials(
  new AuthScope("driman8.cgsh.com", 80, "cgsh.com"),
  new UsernamePasswordCredentials("myusername", "mypassword"));

Hope this helps

Oleg
[1]
http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/httpclient/trunk/src/examples/InteractiveAuthenticationExample.java?view=markup

On Wed, 2005-08-03 at 15:36 -0400, Zhaohua Meng wrote: 
> Sorry I have to split this mail in 2 since apache.org mail server wont' 
> allow large messages.
> The code:
> 
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.IOException;
> import java.security.Security;
> import java.util.ArrayList;
> import java.util.List;
> 
> import javax.xml.parsers.ParserConfigurationException;
> 
> import org.apache.commons.httpclient.Credentials;
> import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
> import org.apache.commons.httpclient.Header;
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.HttpException;
> import org.apache.commons.httpclient.HttpVersion;
> import org.apache.commons.httpclient.NTCredentials;
> import org.apache.commons.httpclient.UsernamePasswordCredentials;
> import org.apache.commons.httpclient.auth.AuthPolicy;
> import org.apache.commons.httpclient.auth.AuthScheme;
> import org.apache.commons.httpclient.auth.AuthScope;
> import 
> org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
> import org.apache.commons.httpclient.auth.CredentialsProvider;
> import org.apache.commons.httpclient.cookie.CookiePolicy;
> import org.apache.commons.httpclient.methods.GetMethod;
> import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
> import org.apache.commons.httpclient.methods.PostMethod;
> import org.apache.commons.httpclient.methods.StringRequestEntity;
> import org.apache.commons.httpclient.params.HttpMethodParams;
> 
> /**
>  *
>  * This is a sample application that demonstrates
>  * how to use the Jakarta HttpClient API.
>  *
>  * This application sends an XML document
>  * to a remote web server using HTTP POST
>  *
>  * @author Sean C. Sullivan
>  * @author Ortwin Glück
>  * @author Oleg Kalnichevski
>  */
> public class PostXML {
>         private Object password;
> 
>     /**
>      *
>      * Usage:
>      *          java PostXML http://mywebserver:80/ c:\foo.xml
>      *
>      *  @param args command line arguments
>      *                 Argument 0 is a URL to a web server
>      *                 Argument 1 is a local filename
>      *
>      */
>     public static void main(String[] args) throws Exception {
>         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", "debug");
>         System.setProperty(
> "org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", 
> "debug"); 
>         postWithSupportedAuth(); 
>    }
>     public static void postWithSupportedAuth() throws IOException, 
> HttpException, IllegalAccessException, InstantiationException, 
> ClassNotFoundException, ParserConfigurationException {
>         String secProviderName = "com.sun.crypto.provider.SunJCE";
>         java.security.Provider secProvider = 
> (java.security.Provider)Class.forName(secProviderName).newInstance();
>         Security.addProvider(secProvider);
>         String strURL = "
> http://driman8.cgsh.com/worksite/services/factory.asmx";
>         String strXMLFilename = "C:/project/junk/Test/Java 
> Source/request.xml";
>                 String requestDoc = 
> ImanageCreateWorkspaceSOAP.getTestDoc(); 
>         // Prepare HTTP post
>         PostMethod post = new PostMethod(strURL);
>           post.setRequestEntity(new StringRequestEntity(requestDoc,
> "text/xml; charset=UTF-8","UTF-8"));
>         post.setRequestHeader("Content-type", "text/xml; charset=UTF-8");
>         post.setRequestHeader("SOAPAction",
>                         "\"http://worksite.imanage.com/CreateWorkspace\""
> ); 
>         HttpClient httpclient = new HttpClient(); 
>           post.getParams().setVersion(HttpVersion.HTTP_1_1);
>  httpclient.getParams().setParameter(CredentialsProvider.PROVIDER,
>                 new PostXML.MyCredentialsProvider()); 
>         try {
>             int result = httpclient.executeMethod(post);
>             System.out.println("Response status code: " + result);
>             System.out.println("Response body: ");
>         } finally {
>             post.releaseConnection();
>         }
>      }
>     public static void getWithBasicAuth(String url, String username, 
> String password, String host, int port, String domain) throws 
> HttpException, IOException {
>         //http://www.developer.ibm.com/partnerworld/mem/index.html
>                 GetMethod get = new GetMethod(url);
>                 HttpClient httpclient = new HttpClient();
>         httpclient.getState().setCredentials(
>             new AuthScope(host, port,domain), new 
> NTCredentials(username,password,host,domain));
>             int result = httpclient.executeMethod(get);
>             // Display status code
>             System.out.println("Response status code: " + result);
>             // Display response
>             System.out.println("Response body: ");
>             System.out.println(get.getResponseBodyAsString());
>  
> 
>     }
>     public static class MyCredentialsProvider implements 
> CredentialsProvider {
>  
>                 /**
>                  * @see 
> org.apache.commons.httpclient.auth.CredentialsProvider#getCredentials(AuthScheme, 
> String, int, boolean)
>                  */
>                 public Credentials getCredentials(
>                         AuthScheme scheme,
>                         String host,
>                         int port,
>                         boolean proxy)
>                         throws CredentialsNotAvailableException {
>                                 return new UsernamePasswordCredentials(
> "myusername","mypassword");
>                 }
> 
>         }
> }
> 
> This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.


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


Re: httpclient running in a loop: the code

Posted by Zhaohua Meng <zm...@cgsh.com>.
Sorry I have to split this mail in 2 since apache.org mail server wont' 
allow large messages.
The code:

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.Security;
import java.util.ArrayList;
import java.util.List;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.httpclient.NTCredentials;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthPolicy;
import org.apache.commons.httpclient.auth.AuthScheme;
import org.apache.commons.httpclient.auth.AuthScope;
import 
org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
import org.apache.commons.httpclient.auth.CredentialsProvider;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpMethodParams;

/**
 *
 * This is a sample application that demonstrates
 * how to use the Jakarta HttpClient API.
 *
 * This application sends an XML document
 * to a remote web server using HTTP POST
 *
 * @author Sean C. Sullivan
 * @author Ortwin Glück
 * @author Oleg Kalnichevski
 */
public class PostXML {
        private Object password;

    /**
     *
     * Usage:
     *          java PostXML http://mywebserver:80/ c:\foo.xml
     *
     *  @param args command line arguments
     *                 Argument 0 is a URL to a web server
     *                 Argument 1 is a local filename
     *
     */
    public static void main(String[] args) throws Exception {
        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", "debug");
        System.setProperty(
"org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", 
"debug"); 
        postWithSupportedAuth(); 
   }
    public static void postWithSupportedAuth() throws IOException, 
HttpException, IllegalAccessException, InstantiationException, 
ClassNotFoundException, ParserConfigurationException {
        String secProviderName = "com.sun.crypto.provider.SunJCE";
        java.security.Provider secProvider = 
(java.security.Provider)Class.forName(secProviderName).newInstance();
        Security.addProvider(secProvider);
        String strURL = "
http://driman8.cgsh.com/worksite/services/factory.asmx";
        String strXMLFilename = "C:/project/junk/Test/Java 
Source/request.xml";
                String requestDoc = 
ImanageCreateWorkspaceSOAP.getTestDoc(); 
        // Prepare HTTP post
        PostMethod post = new PostMethod(strURL);
          post.setRequestEntity(new StringRequestEntity(requestDoc,
"text/xml; charset=UTF-8","UTF-8"));
        post.setRequestHeader("Content-type", "text/xml; charset=UTF-8");
        post.setRequestHeader("SOAPAction",
                        "\"http://worksite.imanage.com/CreateWorkspace\""
); 
        HttpClient httpclient = new HttpClient(); 
          post.getParams().setVersion(HttpVersion.HTTP_1_1);
 httpclient.getParams().setParameter(CredentialsProvider.PROVIDER,
                new PostXML.MyCredentialsProvider()); 
        try {
            int result = httpclient.executeMethod(post);
            System.out.println("Response status code: " + result);
            System.out.println("Response body: ");
        } finally {
            post.releaseConnection();
        }
     }
    public static void getWithBasicAuth(String url, String username, 
String password, String host, int port, String domain) throws 
HttpException, IOException {
        //http://www.developer.ibm.com/partnerworld/mem/index.html
                GetMethod get = new GetMethod(url);
                HttpClient httpclient = new HttpClient();
        httpclient.getState().setCredentials(
            new AuthScope(host, port,domain), new 
NTCredentials(username,password,host,domain));
            int result = httpclient.executeMethod(get);
            // Display status code
            System.out.println("Response status code: " + result);
            // Display response
            System.out.println("Response body: ");
            System.out.println(get.getResponseBodyAsString());
 
 
    }
    public static class MyCredentialsProvider implements 
CredentialsProvider {
 
                /**
                 * @see 
org.apache.commons.httpclient.auth.CredentialsProvider#getCredentials(AuthScheme, 
String, int, boolean)
                 */
                public Credentials getCredentials(
                        AuthScheme scheme,
                        String host,
                        int port,
                        boolean proxy)
                        throws CredentialsNotAvailableException {
                                return new UsernamePasswordCredentials(
"myusername","mypassword");
                }

        }
}

This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Re: httpclient running in a loop

Posted by Oleg Kalnichevski <ol...@apache.org>.
Zhaohua,
(1) Please state the exact version of HttpClient you are using
(2) If you are using the latest release (3.0RC3) post the complete
context/wire log of the HTTP session and the source code of
PostXML.MyCredentialsProvider class

Oleg

On Wed, 2005-08-03 at 14:10 -0400, Zhaohua Meng wrote:
> Gurus,
> My following code ends up in the httpclient sending request/getting 
> response again and again, when Basic Authentication failed. How do I make 
> it stop after "Authorization: Basic dGVzdGltYW46aW1hbjg=" header is sent 
> to server and and the server responds with 401 (the second trip)?
> Thanks,
> Zhaohua
> 
>     public static void postWithSupportedAuth() throws IOException, 
> HttpException, IllegalAccessException, InstantiationException, 
> ClassNotFoundException, ParserConfigurationException {
>         String secProviderName = "com.sun.crypto.provider.SunJCE";
>         java.security.Provider secProvider = 
> (java.security.Provider)Class.forName(secProviderName).newInstance();
>         Security.addProvider(secProvider);
>         String strURL = 
> "http://driman8.cgsh.com/worksite/services/factory.asmx";
>         String strXMLFilename = "C:/project/junk/Test/Java 
> Source/request.xml";
>                 String requestDoc = 
> ImanageCreateWorkspaceSOAP.getTestDoc(); 
>         // Prepare HTTP post
>         PostMethod post = new PostMethod(strURL);
>                 post.setRequestEntity(new StringRequestEntity(requestDoc,
> "text/xml; charset=UTF-8","UTF-8"));
>         post.setRequestHeader("Content-type", "text/xml; charset=UTF-8");
>         post.setRequestHeader("SOAPAction",
>                         "\"http://worksite.imanage.com/CreateWorkspace\""
> ); 
>         HttpClient httpclient = new HttpClient(); 
>                 post.getParams().setVersion(HttpVersion.HTTP_1_1);
>  httpclient.getParams().setParameter(CredentialsProvider.PROVIDER,
>                 new PostXML.MyCredentialsProvider());
>                 post.setDoAuthentication(true);
>         try {
>             int result = httpclient.executeMethod(post);
>             System.out.println("Response status code: " + result);
>             System.out.println("Response body: ");
>         } finally {
>             // Release current connection to the connection pool once you 
> are done
>             post.releaseConnection();
>         }
>      }
> This message is being sent from a law firm and may contain confidential or privileged information.  If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.


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