用到axis2与axiom的jar
示例代码:
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
Options options = new Options();
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setAction(namespace + method);
options.setTo(new EndpointReference(uri));
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(namespace, "");
OMElement data = fac.createOMElement(method, omNs);
OMElement inner = fac.createOMElement("flightinfoid", omNs);
inner.setText(legId);
data.addChild(inner);
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMElement result = sender.sendReceive(data);