There is a perfect tool called "soapUI",it can help you to generate code easily.
1.Add SOAPHeader information in the request.
- // Set header
- try {
- SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement(
- new javax.xml.namespace.QName(
- "http://www.stefli.com/auth",
- "AccessTestRequest"), "");
- soapHeaderElement.setPrefix("auth");
- soapHeaderElement
- .setNamespaceURI("http://www.stefli.com/auth");
- soapHeaderElement.setObjectValue(null);
- SOAPElement element = (SOAPElement) (soapHeaderElement
- .addChildElement("UserId"));
- element.setPrefix("auth");
- element.addTextNode(accessRequest.getUserId());
- element = (SOAPElement) (soapHeaderElement
- .addChildElement("Password"));
- element.addTextNode(accessRequest.getPassword());
- element = (SOAPElement) (soapHeaderElement
- .addChildElement("LicenseNumber"));
- element.addTextNode(license));
- _call.addHeader(soapHeaderElement);
- } catch (SOAPException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
2. Move the request body code from "SOAPHeader" to "SOAPBody".
param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName(),, TestRequest.class, false, true);
the last two parameters are the keys.the first parameter configure the "inHeader" functionality,the second paramter configure the "outHeader" functionality.
3.AxisFault->NullpointerException
it need to add the xml-apis.jar & xercesImpl.jar to the classpath.

本文介绍了一款名为soapUI的强大工具,它可以帮助用户轻松生成SOAP请求代码。文中详细展示了如何通过soapUI设置SOAP Header信息,并提供了具体的Java代码示例。此外,还提到了将请求体从Header移至Body的方法及解决AxisFault异常时遇到的问题。
2450

被折叠的 条评论
为什么被折叠?



