package com.quickmap.common;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
/**
* Created by matt0614@qq.com on 2017/6/6 0006.
*/
public class WebServicesClient {
public static void main(String[] args) throws Exception {
getRes3();
}
public static void getRes3(){
try {
String soapBindingAddress = "http://www.webxml.com.cn/WebServices/ChinaZipSearchWebService.asmx";
ServiceClient sender = new ServiceClient();
EndpointReference endpointReference = new EndpointReference(
soapBindingAddress);
Options options = new Options();
options.setAction("http://WebXml.com.cn/getSupportCity");
options.setTo(endpointReference);
//options.setProperty(HTTPConstants.CHUNKED, "false");
sender.setOptions(options);
OMFactory fac = OMAbstractFactory.getOMFactory();
// 这个和qname差不多,设置命名空间
OMNamespace omNs = fac.createOMNamespace("http://WebXml.com.cn/",
"getSupportCity");
OMElement data = fac.createOMElement("getSupportCity", omNs);
// 对应参数的节点
String[] strs = new String[] {"byProvinceName" };
// 参数值
String[] val = new String[] {"上海"};
for (int i = 0; i < strs.length; i++) {
OMElement inner = fac.createOMElement(strs[i], omNs);
inner.setText(val[i]);
data.addChild(inner);
}
// 发送数据,返回结果
OMElement result = sender.sendReceive(data);
System.out.println(result.toString());
} catch (AxisFault ex) {
ex.printStackTrace();
}
}
}
引用最精简jar包列表:
jar包列表下载地址:
http://download.csdn.net/download/matt0614/9995548