Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set http request (message Body) in a java class ?

Mohamed -raja
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
1. httpdirector listens the port, say 8080
On the port 8084, one service is running as background process (like apache tomcat service).
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

3. The problem is,
If i pass the xml based message, in the hardcoded url means, it is created in that service thru my httpredirector.

http://localhost:8080/demo?type=message&destination=myMsg&body=<root><data>My test message</data></root>

but not created by the following,

http://localhost:8080/demo?type=message&destination=myMsg&body=<?xml version=\"1.0\"?><root><data>My test message</data></root>

also, if sets the parameter by namevaluepair means,
NameValuPair paramter settings are,
body=<?xml version=\"1.0\"?><root><data>My test message</data></root>

so in these conditions it gives error as, Connection reset by peer: JVM_recv in socket input stream read

So anyone, please help to resolve this problem.
Thanks in advance
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic