Dear Roland,
The following logging is when I coded as:
----
...
StringEntity stringEntity = new StringEntity(login, HTTP.UTF_8);
stringEntity.setContentType(" text/plain; charset=UTF-8");
httpPost.setEntity(stringEntity);
...
----
executing: POST https://127.0.0.1/agent/xml/login.xml HTTP/1.1
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.max-redirects': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection-manager.timeout': null
DEBUG [org.apache.http.impl.conn.SingleClientConnManager]
SingleClientConnManager.getConnection: HttpRoute[{s}->https://127.0.0.1]
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.timeout': null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout':
null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.tcp.nodelay': null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout':
null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.linger': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.socket.buffer-size': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.element-charset': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.max-line-length': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.element-charset': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.max-header-count': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.max-line-length': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.max-status-line-garbage': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.stalecheck': null
DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Stale
connection check
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.virtual-host': null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.default-headers':
null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.useragent':
Apache-HttpClient/4.0-alpha3 (java 1.4)
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.expect-continue': true
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.cookie-policy': null
DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected:
best-match
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.cookie-datepatterns': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.single-cookie-header': null
DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Attempt 1 to
execute request
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.wire] >> "POST /agent/xml/login.xml HTTP/1.1[EOL]"
DEBUG [org.apache.http.wire] >> "Content-Length: 148[EOL]"
DEBUG [org.apache.http.wire] >> "Content-Type: text/plain; charset=UTF-8[EOL]"
DEBUG [org.apache.http.wire] >> "Host: 127.0.0.1[EOL]"
DEBUG [org.apache.http.wire] >> "Connection: Keep-Alive[EOL]"
DEBUG [org.apache.http.wire] >> "User-Agent: Apache-HttpClient/4.0-alpha3 (java
1.4)[EOL]"
DEBUG [org.apache.http.wire] >> "Expect: 100-Continue[EOL]"
DEBUG [org.apache.http.wire] >> "[EOL]"
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.headers] >> POST /agent/xml/login.xml HTTP/1.1
DEBUG [org.apache.http.headers] >> Content-Length: 148
DEBUG [org.apache.http.headers] >> Content-Type: text/plain; charset=UTF-8
DEBUG [org.apache.http.headers] >> Host: 127.0.0.1
DEBUG [org.apache.http.headers] >> Connection: Keep-Alive
DEBUG [org.apache.http.headers] >> User-Agent: Apache-HttpClient/4.0-alpha3
(java 1.4)
DEBUG [org.apache.http.headers] >> Expect: 100-Continue
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.wait-for-continue': null
DEBUG [org.apache.http.wire] << "HTTP/1.1 100 Continue[EOL]"
DEBUG [org.apache.http.headers] << HTTP/1.1 100 Continue
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.wire] >> "<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>[\n]"
DEBUG [org.apache.http.wire] >> "<login>[\n]"
DEBUG [org.apache.http.wire] >> "
<phaseKey>powerpanel.encryption.key</phaseKey>[\n]"
DEBUG [org.apache.http.wire] >> " <result>-1</result>[\n]"
DEBUG [org.apache.http.wire] >> "</login>[\n]"
DEBUG [org.apache.http.wire] << "HTTP/1.1 302 Moved Temporarily[EOL]"
DEBUG [org.apache.http.wire] << "Server: Apache-Coyote/1.1[EOL]"
DEBUG [org.apache.http.wire] << "Set-Cookie:
JSESSIONID=7FF0937163D9D659B2953AFF3850A544; Path=/agent; Secure[EOL]"
DEBUG [org.apache.http.wire] << "Pragma: No-cache[EOL]"
DEBUG [org.apache.http.wire] << "Cache-Control:
no-cache,no-store,max-age=0[EOL]"
DEBUG [org.apache.http.wire] << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[EOL]"
DEBUG [org.apache.http.wire] << "Location:
https://127.0.0.1:8443/agent/xml/login.xml;jsessionid=7FF0937163D9D659B2953AFF3850A544[EOL]"
DEBUG [org.apache.http.wire] << "Content-Type: text/html[EOL]"
DEBUG [org.apache.http.wire] << "Content-Length: 0[EOL]"
DEBUG [org.apache.http.wire] << "Date: Fri, 07 Mar 2008 05:28:54 GMT[EOL]"
DEBUG [org.apache.http.headers] << HTTP/1.1 302 Moved Temporarily
DEBUG [org.apache.http.headers] << Server: Apache-Coyote/1.1
DEBUG [org.apache.http.headers] << Set-Cookie:
JSESSIONID=7FF0937163D9D659B2953AFF3850A544; Path=/agent; Secure
DEBUG [org.apache.http.headers] << Pragma: No-cache
DEBUG [org.apache.http.headers] << Cache-Control: no-cache,no-store,max-age=0
DEBUG [org.apache.http.headers] << Expires: Thu, 01 Jan 1970 00:00:00 GMT
DEBUG [org.apache.http.headers] << Location:
https://127.0.0.1:8443/agent/xml/login.xml;jsessionid=7FF0937163D9D659B2953AFF3850A544
DEBUG [org.apache.http.headers] << Content-Type: text/html
DEBUG [org.apache.http.headers] << Content-Length: 0
DEBUG [org.apache.http.headers] << Date: Fri, 07 Mar 2008 05:28:54 GMT
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.client.protocol.ResponseProcessCookies] Cookie accepted:
"[version: 0][name: JSESSIONID][name: 7FF0937163D9D659B2953AFF3850A544][domain:
127.0.0.1][path: /agent][expiry: null]".
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.handle-redirects': null
DEBUG [org.apache.http.impl.client.DefaultRedirectHandler] Redirect requested
to location
'https://127.0.0.1:8443/agent/xml/login.xml;jsessionid=7FF0937163D9D659B2953AFF3850A544'
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.allow-circular-redirects': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.route.forced-route': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.route.local-address': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.route.default-proxy': null
DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Redirecting to
'https://127.0.0.1:8443/agent/xml/login.xml;jsessionid=7FF0937163D9D659B2953AFF3850A544'
via HttpRoute[{s}->https://127.0.0.1:8443]
DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Connection
kept alive
DEBUG [org.apache.http.impl.conn.SingleClientConnManager]
SingleClientConnManager.getConnection: HttpRoute[{s}->https://127.0.0.1:8443]
DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Connection shut down
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.timeout': null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout':
null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.tcp.nodelay': null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout':
null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.linger': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.socket.buffer-size': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.element-charset': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.max-line-length': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.element-charset': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.max-header-count': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.max-line-length': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.max-status-line-garbage': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.connection.stalecheck': null
DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Stale
connection check
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.virtual-host': null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.default-headers':
null
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.useragent':
Apache-HttpClient/4.0-alpha3 (java 1.4)
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.cookie-policy': null
DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected:
best-match
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.cookie-datepatterns': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.single-cookie-header': null
DEBUG [org.apache.http.client.protocol.RequestAddCookies] Cookie [version:
0][name: JSESSIONID][name: 7FF0937163D9D659B2953AFF3850A544][domain:
127.0.0.1][path: /agent][expiry: null] match
[(secure)127.0.0.1:8443/agent/xml/login.xml;jsessionid=7FF0937163D9D659B2953AFF3850A544]
DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Attempt 2 to
execute request
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.wire] >> "GET
/agent/xml/login.xml;jsessionid=7FF0937163D9D659B2953AFF3850A544 HTTP/1.1[EOL]"
DEBUG [org.apache.http.wire] >> "Host: 127.0.0.1:8443[EOL]"
DEBUG [org.apache.http.wire] >> "Connection: Keep-Alive[EOL]"
DEBUG [org.apache.http.wire] >> "User-Agent: Apache-HttpClient/4.0-alpha3 (java
1.4)[EOL]"
DEBUG [org.apache.http.wire] >> "Cookie:
JSESSIONID=7FF0937163D9D659B2953AFF3850A544[EOL]"
DEBUG [org.apache.http.wire] >> "Cookie2: $Version=1[EOL]"
DEBUG [org.apache.http.wire] >> "[EOL]"
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.headers] >> GET
/agent/xml/login.xml;jsessionid=7FF0937163D9D659B2953AFF3850A544 HTTP/1.1
DEBUG [org.apache.http.headers] >> Host: 127.0.0.1:8443
DEBUG [org.apache.http.headers] >> Connection: Keep-Alive
DEBUG [org.apache.http.headers] >> User-Agent: Apache-HttpClient/4.0-alpha3
(java 1.4)
DEBUG [org.apache.http.headers] >> Cookie:
JSESSIONID=7FF0937163D9D659B2953AFF3850A544
DEBUG [org.apache.http.headers] >> Cookie2: $Version=1
DEBUG [org.apache.http.wire] << "HTTP/1.1 200 OK[EOL]"
DEBUG [org.apache.http.wire] << "Server: Apache-Coyote/1.1[EOL]"
DEBUG [org.apache.http.wire] << "Pragma: No-cache[EOL]"
DEBUG [org.apache.http.wire] << "Cache-Control:
no-cache,no-store,max-age=0[EOL]"
DEBUG [org.apache.http.wire] << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[EOL]"
DEBUG [org.apache.http.wire] << "Content-Type: text/xml;charset=UTF-8[EOL]"
DEBUG [org.apache.http.wire] << "Content-Length: 147[EOL]"
DEBUG [org.apache.http.wire] << "Date: Fri, 07 Mar 2008 05:28:54 GMT[EOL]"
DEBUG [org.apache.http.headers] << HTTP/1.1 200 OK
DEBUG [org.apache.http.headers] << Server: Apache-Coyote/1.1
DEBUG [org.apache.http.headers] << Pragma: No-cache
DEBUG [org.apache.http.headers] << Cache-Control: no-cache,no-store,max-age=0
DEBUG [org.apache.http.headers] << Expires: Thu, 01 Jan 1970 00:00:00 GMT
DEBUG [org.apache.http.headers] << Content-Type: text/xml;charset=UTF-8
DEBUG [org.apache.http.headers] << Content-Length: 147
DEBUG [org.apache.http.headers] << Date: Fri, 07 Mar 2008 05:28:54 GMT
DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version':
HTTP/1.1
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.handle-redirects': null
DEBUG [org.apache.http.impl.client.ClientParamsStack]
'http.protocol.handle-authentication': null
Don't feel confused these logging is different with the " Re: cookie or
session-id is different from the same HttpClient connection?!" mail content.
"Re: cookie or session-id is different from the same HttpClient connection?!"
This mail coded as
----
NameValuePair[] nvps = new NameValuePair[] {
new BasicNameValuePair("jaxbString", login)
};
httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
----
So the login will OK. And server can receive it.
Please help me to find out why if I use StringEntity the server can't receive
it.
Thanks for your kindly help.
Sincerely,
Micky
-----Original Message-----
From: Roland Weber [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 06, 2008 1:04 AM
To: HttpClient User Discussion
Subject: Re: [help] how to set an OutputStream to a POST request?
Hi Micky,
> So the string is ok for sending, but the server still can't receive it.....
> >"<
Then we need to see the request that is being sent.
You have to get logging to work.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]