FTPC uses Axis2 to create WebService

In the past, jaxrpc was used to create WebService in FTPC, but this time, the return from the server could not be parsed, and it was not easy to use jaxrpc to parse the return value by itself. After testing axis2, I think it is not bad.

1. Introduce the jar package of Axis2, you can build a library when developing and testing, and put it under the lib of SOS when deploying, without worrying about jar package conflicts

2. The jar that needs to be imported

Among them, dom4j is introduced because there is an error in parsing the message returned by the server, and the parsing statement that converts XML into an object by hand is used.

The other is the jar package used by axis2 itself

3. The server responds that the request object cannot be received, and the HTTP request header is required to be set to: Content-Type: text/xml; charset=UTF-8  

Modification method:

_serviceClient.getOptions().setSoapVersionURI(org.apache.axiom.soap.SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

If using SOAP11Constants (SOAP 1.1), the HTTP request headers are as follows:

  1. POST /test HTTP/1.1  
  2. Content-Type: text/xml; charset=UTF-8  
  3. SOAPAction: "urn:add"  
  4. User-Agent: Axis2  
  5. Host: 146.11.42.87:9876  
  6. Transfer-Encoding: chunked  

If using SOAP12Constants (SOAP 1.2), the HTTP request headers are as follows:

  1. POST /test HTTP/1.1  
  2. Content-Type: application/soap+xml; charset=UTF-8; action="urn:add"  
  3. User-Agent: Axis2  
  4. Host: 146.11.42.87:9876  
  5. Transfer-Encoding: chunked  

If this parameter is not set, the HTTP request header is as follows (the same as SOAP 1.1, you can confirm that SOAP 1.1 is used by default):

  1. POST /test HTTP/1.1  
  2. Content-Type: text/xml; charset=UTF-8  
  3. SOAPAction: "urn:add"  
  4. User-Agent: Axis2  
  5. Host: 146.11.42.87:9876  
  6. Transfer-Encoding: chunked  

The same is true for the Content-Type field in the HTTP response header

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325484358&siteId=291194637