Hello,
I’m running the following method to http post xml data:
public StringBuffer post(String xml) {
OutputStream os = null;
InputStream is = null;
BufferedWriter wr = null;
BufferedReader rd = null;
StringBuffer response = null;
try {
if (_addr == null)
_addr = InetAddress.getByName(hostname);
if (_sock == null)
_sock = new Socket(_addr, port);
os = _sock.getOutputStream();
is = _sock.getInputStream();
wr = new BufferedWriter(new OutputStreamWriter(os, encoding));
wr.write("POST " + path + " HTTP/1.1\r\n");
wr.write("Host: " + hostname + "\r\n");
wr.write("Content-Length: " + xml.length() + "\r\n");
wr.write("Content-Type: application/soap+xml; charset=\""
+ encoding.toLowerCase() + "\"\r\n");
wr.write("\r\n");
wr.write(xml);
wr.flush();
rd = new BufferedReader(new InputStreamReader(is, encoding));
if (rd != null) {
response = new StringBuffer();
String line;
while ((line = rd.readLine()) != null)
response.append(line + "\r\n");
}
wr.close();
os.close();
rd.close();
is.close();
} catch (Exception e) {
try {
if (wr != null)
wr.close();
if (os != null)
os.close();
if (rd != null)
rd.close();
if (is != null)
is.close();
if (_sock != null)
_sock.close();
} catch (Exception ignore) {
}
e.printStackTrace();
}
return response;
}
When I run this code against various test services from SoapClient.com it works just fine. But when I use a service from a Microsoft BizTalk server the service in question is executed ok and headers along with HTTP/1.1 200 OK are received back but the SOAP body is not… Instead, it hangs waiting until domino log says: “A connection with a remote socket was reset by that socket” (etc.).
There’s got to be something in my code I’m overlooking. Can I lend you eyes and brains for a minute?
TIA,
Jan Sandholm