Hi,
I have created a method that carries out post commands and returns the response body.
It is called doPostMethod and my usage is shown below:
if (isProxySetUp()) { //sets up the proxy
// Create a method instance of amazon.co.uk site.
responseBody = doGetMethod(sellYourStuffURL); //works fine
String reponse = new String(responseBody);
if (reponse != null) {
HashMap ISBNPostValuesMap = new HashMap();
NameValuePair bookISBN = new NameValuePair("sdp-sai-asin", "1852271493");
//NameValuePair bookImage = new NameValuePair("absmiddle",
"http://images-eu.amazon.com/images/G/02/x-locale/common/buttons/find-it.gif");
ISBNPostValuesMap.put("ISBN", bookISBN);
responseBody = doPostMethod(enterISBNURL, ISBNPostValuesMap);
reponse = new String(responseBody);
if (reponse != null) {//does not complete the block below error shown below
ISBNPostValuesMap = new HashMap();
bookISBN = new NameValuePair("sdp-sai-asin", "1852271493");
NameValuePair bookCondition = new NameValuePair("sdp-sai-condition-type",
"NEW");
NameValuePair bookComment = new NameValuePair("sdp-sai-condition-comments",
"Brand New");
ISBNPostValuesMap = new HashMap();
ISBNPostValuesMap.put("ISBN", bookISBN);
ISBNPostValuesMap.put("Condition", bookCondition);
ISBNPostValuesMap.put("Comment", bookComment);
responseBody = null;
responseBody = doPostMethod(enterSalePriceURL, ISBNPostValuesMap);
System.out.println(responseBody);
//reponse = new String(responseBody);
//System.out.println(new String(reponse));
}
else {
System.out.println("RESPONSE FAILED");
}
}
Running the above and other code I get the error:
java.lang.IllegalArgumentException: host parameter is null
at
org.apache.commons.httpclient.HttpConnection.setHost(HttpConnection.java:228)
at
org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnectionWithTimeout(SimpleHttpConnectionManager.java:146)200
at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:161)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:437)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
at testhttpclient.HttpClientTutorial.doPostMethod(HttpClientTutorial.java:119)
at testhttpclient.HttpClientTutorial.main(HttpClientTutorial.java:46)
But removing the code that produces the error makes the error go away. Any help would
be appreciated.
Thanks
Rudy
-----Original Message-----
From: Hentzen, Rudy
Sent: 28 September 2004 10:10
To: Commons HttpClient Project
Subject: RE: Proxy
Thank you very much, I was using port 8081, as it was given with the pac script.
Your help has been very appreciated.
Thanks again
Rudy
-----Original Message-----
From: Ortwin Gl�ck [mailto:[EMAIL PROTECTED]
Sent: 28 September 2004 10:07
To: Commons HttpClient Project
Subject: Re: Proxy
Hentzen, Rudy wrote:
> Thanks for the swift reply, I have a proxy ip address, is that supported??
>
> Rudy
Sure. Just fill it into the example, where it says "myproxyhost" and
8080 is the TCP port.
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]