最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java 使用Axis調(diào)用WebService的示例代碼

 更新時(shí)間:2020年09月28日 09:47:19   作者:H.U.C-王子  
這篇文章主要介紹了Java 使用Axis調(diào)用WebService的示例代碼,幫助大家更好的理解和使用Java,感興趣的朋友可以了解下
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

/** 
* @ClassName: TestAxis 
* @Description: TODO(描述這個(gè)類的作用) 
* @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>公民身份號(hào)碼</GMSFHM><XM>姓名</XM></ROW><ROW><GMSFHM>110101******</GMSFHM><XM>李聞</XM><FSD>100600</FSD><YWLX>個(gè)人貸款</YWLX></ROW><ROW><GMSFHM>3624221952123***</GMSFHM><XM>李一聞</XM><FSD>100600</FSD><YWLX>個(gè)人貸款</YWLX></ROW><ROW><GMSFHM>1234********</GMSFHM><XM>王龍</XM><FSD>100600</FSD><YWLX>銀行開戶</YWLX></ROW><ROW><GMSFHM>110101******</GMSFHM><XM></XM><FSD>100600</FSD><YWLX>個(gè)人車貸</YWLX></ROW><ROW><GMSFHM>110101******</GMSFHM><XM></XM><FSD>100600</FSD><YWLX></YWLX></ROW><ROW><GMSFHM>230602***</GMSFHM><XM></XM><FSD>100600</FSD><YWLX>個(gè)人車貸</YWLX></ROW></ROWS>";
    String inLicense = "********"; 
     try{    
        //調(diào)用webservice地址   
        String url = "https://www.****.com/services/NciicServices";           //如果url地址中有中文參數(shù),要注意應(yīng)單獨(dú)將中文部分進(jìn)行編碼操作后再與URL字符串拼接到一起,編碼方式為:URLEncoder.encode("中文部分", "utf-8"); 
        //調(diào)用方法名
        String method="nciicCheck";
        Service service = new Service();
        //通過(guò)service創(chuàng)建call對(duì)象   
        Call call = (Call) service.createCall();          //call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS); 設(shè)置soap12協(xié)議方式調(diào)用
        //設(shè)置服務(wù)地址
        call.setTargetEndpointAddress(new java.net.URL(url)); 
        //設(shè)置調(diào)用方法
        call.setOperationName(method);
        call.setUseSOAPAction(true);
        //添加方法的參數(shù),有幾個(gè)添加幾個(gè)
        //inLicense是參數(shù)名,XSD_STRING是參數(shù)類型,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);
          //設(shè)置返回類型 
        call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);          //解決錯(cuò)誤:服務(wù)器未能識(shí)別 HTTP 頭 SOAPAction 的值           call.setUseSOAPAction(true);          call.setSOAPActionURI(targetNamespace + operationName);
        Object ret= null;
        try{
          //使用invoke調(diào)用方法,Object數(shù)據(jù)放傳入的參數(shù)值
          ret = call.invoke(new Object[] {inLicense,inConditions}); 
        }catch(Exception e){
          e.printStackTrace();
        }
        //輸出SOAP請(qǐng)求報(bào)文
        System.out.println("--SOAP Request: " + call.getMessageContext().getRequestMessage().getSOAPPartAsString());
        //輸出SOAP返回報(bào)文
        System.out.println("--SOAP Response: " + call.getResponseMessage().getSOAPPartAsString());
        //輸出返回信息
        System.out.println("result==="+ret.toString()); 
    }catch(Exception e){
    e.printStackTrace();
    }
  }  
}

下面是輸出結(jié)果信息:

--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&#x5730;&#x5740;&#x53D7;&#x9650;&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>

以上就是Java 使用Axis調(diào)用WebService的示例代碼的詳細(xì)內(nèi)容,更多關(guān)于Java 使用Axis調(diào)用WebService的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論

滨海县| 民县| 镇远县| 安庆市| 施秉县| 乐都县| 泾阳县| 琼海市| 新乡县| 木兰县| 阜平县| 古浪县| 井研县| 日照市| 海宁市| 子长县| 襄樊市| 文水县| 中西区| 东方市| 涟水县| 南郑县| 高阳县| 来宾市| 大同市| 怀化市| 门头沟区| 香格里拉县| 南涧| 镇平县| 丹凤县| 汪清县| 富宁县| 吕梁市| 凤冈县| 屯留县| 平潭县| 双桥区| 哈巴河县| 射洪县| 伽师县|