这是我使用SOAPUI提交的SOAP请求
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = fac.getDefaultEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPBody body = envelope.getBody();
Iterator it = header.getChildElements();
Iterator bodyIt = body.getChildElements();
while (it.hasNext()) {
OMElement e = (OMElement) it.next();
System.out.println(e.getText().toString());
}
while (bodyIt.hasNext()) {
OMElement e = (OMElement) bodyIt.next();
System.out.println(e.getText().toString());
}
现在我在eclipse中创建了一个maven项目,并生成了一个wsdl文件,一个aar文件(用于使用Tomcat 7进行部署)和一个来自Java代码(java2wsdl)的jar文件。提交请求时,代码必须使用header元素下提供的凭据授权用户。但是,我无法解析SOAP请求。当我尝试解析时,
onStart(...){
callFirstWS();
callSecondWS();
}
其中SOAPFactory和其他对象是从公理导入的,没有执行的print语句。所以问题是如何解析这个请求,以便我能够读取标题和正文?
如果有什么含糊不清的话,我道歉;我还是Java Web服务的新手。答案 0 :(得分:0)
来自SOAPFactory#getDefaultEnvelope()
方法的Javadoc:
使用空标题和空体创建默认的SOAP信封。
因此,您的Java代码按预期运行。