import org.apache.axis.client.Call;
import org.apache.axis.client.Service; /**
* @ClassName: TestAxis
* @Description: TODO(描述这个类的作用)
* @author huc
*
*/ public class TestAxis {
public static void main(String []args){
String inConditions = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><ROWS><INFO><SBM>*</SBM></INFO><ROW><GMSFHM>公民身份号码</GMSFHM><XM>姓名</XM></ROW><ROW><GMSFHM>110101******</GMSFHM><XM>李闻</XM><FSD>100600</FSD><YWLX>个人贷款</YWLX></ROW><ROW><GMSFHM>3624221952123***</GMSFHM><XM>李一闻</XM><FSD>100600</FSD><YWLX>个人贷款</YWLX></ROW><ROW><GMSFHM>1234********</GMSFHM><XM>王龙</XM><FSD>100600</FSD><YWLX>银行开户</YWLX></ROW><ROW><GMSFHM>110101******</GMSFHM><XM></XM><FSD>100600</FSD><YWLX>个人车贷</YWLX></ROW><ROW><GMSFHM>110101******</GMSFHM><XM></XM><FSD>100600</FSD><YWLX></YWLX></ROW><ROW><GMSFHM>230602***</GMSFHM><XM></XM><FSD>100600</FSD><YWLX>个人车贷</YWLX></ROW></ROWS>";
String inLicense = "********";
try{
//调用webservice地址
String url = "https://www.****.com/services/NciicServices";
          //如果url地址中有中文参数,要注意应单独将中文部分进行编码操作后再与URL字符串拼接到一起,编码方式为:URLEncoder.encode("中文部分", "utf-8");
//调用方法名
String method="nciicCheck";
Service service = new Service();
//通过service创建call对象
Call call = (Call) service.createCall();
          //call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS); 设置soap12协议方式调用
//设置服务地址
call.setTargetEndpointAddress(new java.net.URL(url));
//设置调用方法
call.setOperationName(method);
call.setUseSOAPAction(true);
//添加方法的参数,有几个添加几个
//inLicense是参数名,XSD_STRING是参数类型,IN代表传入
call.addParameter("inLicense", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("inConditions", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);

          //带命名空间的写法        

          //call.setOperationName(new QName("http://bussiness.***.com", "callPT"));
          //call.addParameter(new QName("http://bussiness.***.com","xmlData"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
          //call.addParameter(new QName("http://bussiness.***.com","methodName"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);

          //设置返回类型
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
          //解决错误:服务器未能识别 HTTP 头 SOAPAction 的值 
          call.setUseSOAPAction(true);
          call.setSOAPActionURI(targetNamespace + operationName);
                Object ret= null;
try{
//使用invoke调用方法,Object数据放传入的参数值
ret = call.invoke(new Object[] {inLicense,inConditions});
}catch(Exception e){
e.printStackTrace();
}
//输出SOAP请求报文
System.out.println("--SOAP Request: " + call.getMessageContext().getRequestMessage().getSOAPPartAsString());
//输出SOAP返回报文
System.out.println("--SOAP Response: " + call.getResponseMessage().getSOAPPartAsString());
//输出返回信息
System.out.println("result==="+ret.toString());
}catch(Exception e){
e.printStackTrace();
}
}
}

下面是输出结果信息:

--SOAP Request: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><nciicCheck soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><inLicense xsi:type="xsd:string">*****</inLicense><inConditions xsi:type="xsd:string">*****</inConditions></nciicCheck></soapenv:Body></soapenv:Envelope>
--SOAP Response: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><ns1:nciicCheckResponse xmlns:ns1="https://api.nciic.org.cn/NciicServices"><ns1:out>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;RESPONSE errorcode=&quot;-72&quot; code=&quot;0&quot; countrows=&quot;1&quot;&gt;&lt;ROWS&gt;&lt;ROW&gt;&lt;ErrorCode&gt;-72&lt;/ErrorCode&gt;&lt;ErrorMsg&gt;IP地址受限&lt;/ErrorMsg&gt;&lt;/ROW&gt;&lt;/ROWS&gt;&lt;/RESPONSE&gt;</ns1:out></ns1:nciicCheckResponse></soap:Body></soap:Envelope>
result===<?xml version="1.0" encoding="UTF-8"?>
<RESPONSE errorcode="-72" code="0" countrows="1"><ROWS><ROW><ErrorCode>-72</ErrorCode><ErrorMsg>IP地址受限</ErrorMsg></ROW></ROWS></RESPONSE>

最新文章

  1. 滤镜 filter:gray 变灰色
  2. PHP中的全局变量global和$GLOBALS的区别
  3. 抓取百万知乎用户信息之HttpHelper的迭代之路
  4. 关于MVC中View使用自定义方法
  5. MySQL各版本的区别
  6. BizTalk开发系列(二十七) 异常管理中的数据编码
  7. 【iCore3 双核心板_ uC/OS-III】例程十:消息队列
  8. loadrunner解决“服务器正在运行中”方法
  9. 将ntfs分区转换为ext4分区
  10. reactjs入门到实战(二)---- jxs详解
  11. Pogo-Cow
  12. Java的外部类和内部类+静态变量和非静态变量的组合关系
  13. Even Fibonacci numbers
  14. Linux 线程属性函数总结
  15. ERROR&lt;53761&gt; - Plugins - conn=-1 op=-1 msgId=-1 - Connection Bind through PTA failed (91). Retrying...
  16. c++11: &lt;thread&gt;学习
  17. NoSql研究报告
  18. Bootstrap3 表格-状态类
  19. [shiro学习笔记]第三节 使用myeclipse导入apache shiro中的QuikStart example例子
  20. Spring Boot 2.0.1 入门教程

热门文章

  1. MongoDB入门---文档操作之增删改
  2. 推荐 的FPGA设计经验(3) 物理实现和时间闭环优化
  3. 成都Uber优步司机奖励政策(3月21日)
  4. datawindow自动换行打印,需结合该函数一起使用
  5. Java图片转字符
  6. 【picker】选择器组件说明
  7. *转载 Tarjan有向图详解
  8. opencv-学习笔记(2)
  9. Python3 小工具-UDP发现
  10. HADOOP docker(五):hadoop用户代理 Proxy user