
chillnoor
|
How To Set Http Request (message Body) Headers In Java Class ?
Friday, 17th April 2009
I created a httpRedirector class, it gets the request and sends that to actual host and get the response, send to the requester client(java class).
<br>Description:
<br>============
<br>1. httpdirector listens the port, say 8080
<br>On the port 8084, one service is running as background process (like apache tomcat service).
<br>2. Now the requester client (java class) has some sends the requesting url as hardcoded string, but the parameters are set by NameValuePair. The, sends it by using PostMethod. Eg:- request to create a message in that service which runs in 8084, through the httpRedirector. So i request to 8080 only.
<br>3. The problem is,
<br>If i pass the xml based message, in the hardcoded url means, it is created in that service thru my httpredirector.
<br>
<br>http://localhost:8080/demo?type=message&destination=myMsg&body=<root><data>My test message</data></root>
<br>
<br>but not created by the following,
<br>
<br>http://localhost:8080/demo?type=message&destination=myMsg&body=<?xml version=\"1.0\"?><root><data>My test message</data></root>
<br>
<br>also, if sets the parameter by namevaluepair means,
<br>http://localhost:8080/demo?
<br>NameValuPair paramter settings are,
<br>type=message
<br>destination=myMsg
<br>body=<?xml version=\"1.0\"?><root><data>My test message</data></root>
<br>
<br>so in these conditions it gives error as,
<br>
<br>java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
<br>
<br>So anyone, please help to resolve this problem.
<br>Thanks in advance
|