1
我想从我的应用程序调用Web服务。我的系统受防火墙保护,我使用代理来访问任何外部URL/Internet访问。该应用程序在JBoss EAP 5.1服务器上运行。应用程序无法使用IO异常写入服务URL:'无法传输消息'。JBoss EAP 5.1服务器不使用Windows网络设置
但是,当我试图访问与IE/Firefox的服务URL,它是开放的。虽然我从浏览器收到的XML响应声明了一个通用错误 - '无效的请求参数...',这很明显。因为我没有从浏览器发送正确的请求XML。
我真的很困惑与这种差距。我曾经相信JBoss会选择标准的Windows网络设置,但在我的情况下,它不是。
我的代码如下:
String strUrl = "http://theurlgoeshere";
String requestXml = "<request></request>";
String wsResponse="";
SOAPConnection conn = null;
try {
MessageFactory msgFac = MessageFactory.newInstance();
MimeHeaders mh = new MimeHeaders();
mh.setHeader("Content-Type", "text/xml; charset=UTF-8");
log.info("Request Xml:" + requestXml);
InputStream is = new ByteArrayInputStream(requestXml.getBytes("UTF-8"));
SOAPMessage reqMsg = msgFac.createMessage(mh, is);
SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
conn = conFac.createConnection();
SOAPMessage repMsg = conn.call(reqMsg, strUrl);
ByteArrayOutputStream out = new ByteArrayOutputStream();
repMsg.writeTo(out);
wsResponse = new String(out.toByteArray());
}
catch (Exception e) {
e.printStackTrace();
}