I am able to send the following request using browser and receive the correct response, but when I send it using following code the server return an error.
I suspect the problem is that Java puts the xml attributes in "request version" part of HTTP request.
String QueryString = "http://xml.example.com/service?"
+ "<List>"
+ "<Credentials username=\"example\" password=\"example1\" remoteIp=\"X.X.X.X\"/>"
+ "<Id>10202</Id>"
+ "</List>";
try {
URL page = new URL(QueryString);
StringBuffer text = new StringBuffer();
HttpURLConnection conn = (HttpURLConnection) page.openConnection();
conn.connect();
InputStreamReader in = new InputStreamReader(
(InputStream) conn.getContent());
I had a look at the request being sent using WireShark.
GET /service?<List><Credentials username="example" password="example1" remoteIp="X.X.X.X"/<Id>10202</Id></List>
....
Request URI: /service?<List><Credentials
Request Version: username="example" password="example1" remoteIp="X.X.X.X"/<Id>10202</Id></List> HTTP/1.1
Server's result is
XML document structures must start and end within the same entity.