hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lei Cao" <Lei....@acntv.com>
Subject question about PostMethod
Date Tue, 15 Mar 2005 19:41:02 GMT
I constantly receive an error message as below:
------------------------------------
org.apache.commons.httpclient.HttpMethodBase readResponse
INFO: Discarding unexpected response: HTTP/1.1 100 Continue
------------------------------------

I have followed the HttpClient tutorial and could not find what I have done wrong. Is there
anybody can help me out?
Thanks in advance! 

My java source code is:
---------------------------------------------------
String SHIPPING_URI = "http://testing.shippingapis.com/ShippingAPITest.dll";
String API_NAME = "GlobalExpressMailLabelCertify";
String XML_REQUEST_FILE_NAME = "C:\\temp\\SampleGlobalExpressMailLabelRequest.xml";
String XML_RESPONSE_FILE_NAME = "C:\\temp\\response.xml";

String unencodedXml = FileUtil.getTextContents(
			StreamUtil.openResource(XML_REQUEST_FILE_NAME),
			true,
			false);
String encodedXml = URLEncoder.encode(
			unencodedXml,
			"UTF-8");

HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(SHIPPING_URI);

NameValuePair[] nvps = {new NameValuePair("API", API_NAME), new NameValuePair("XML", encodedXml)};
postMethod.setRequestBody(nvps);

int statusCode = client.executeMethod(postMethod);

FileOutputStream out = new FileOutputStream(new File(XML_RESPONSE_FILE_NAME));
InputStream in = postMethod.getResponseBodyAsStream();
byte[] buffer = new byte[4000];
int len ;
while ((len = in.read(buffer)) > 0) {
    out.write(buffer, 0, len);
}
in.close();
out.close();

postMethod.releaseConnection();
-----------------------------------------------------


Lei Cao
Software Developer
Jewelry Televison



This message originates from Jewelry Television (TM) . The message and any file transmitted
with it is intended to be privileged and confidential. It is intended only for the addressee
named above. Any disclosure, distribution, copying or use of the information by anyone other
than the intended recipient, regardless of address or routing, is strictly prohibited. If
you have received this message in error, please advise the sender by immediate reply and delete
the original message. Personal messages express views solely of the sender and are not attributable
to Jewelry Television (TM).

Mime
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message