Some experiences in axis.

 There is a perfect tool called "soapUI",it can help you to generate code easily.

 

1.Add SOAPHeader information in the request.

 

  1. // Set header
  2.         try {
  3.             SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement(
  4.                     new javax.xml.namespace.QName(
  5.                             "http://www.stefli.com/auth",
  6.                             "AccessTestRequest"), "");
  7.             soapHeaderElement.setPrefix("auth");
  8.             soapHeaderElement
  9.                     .setNamespaceURI("http://www.stefli.com/auth");
  10.             soapHeaderElement.setObjectValue(null);
  11.             SOAPElement element = (SOAPElement) (soapHeaderElement
  12.                     .addChildElement("UserId"));
  13.             element.setPrefix("auth");
  14.             element.addTextNode(accessRequest.getUserId());
  15.             element = (SOAPElement) (soapHeaderElement
  16.                     .addChildElement("Password"));
  17.             element.addTextNode(accessRequest.getPassword());
  18.             element = (SOAPElement) (soapHeaderElement
  19.                     .addChildElement("LicenseNumber"));
  20.             element.addTextNode(license));
  21.             _call.addHeader(soapHeaderElement);
  22.         } catch (SOAPException e) {
  23.             e.printStackTrace();
  24.         } catch (Exception e) {
  25.             e.printStackTrace();
  26.         }

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.

你可能感兴趣的:(Some experiences in axis.)