色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術文章
文章詳情頁

Java 使用Axis調用WebService的示例代碼

瀏覽:19日期:2022-08-23 16:17:13

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&#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調用WebService的示例代碼的詳細內容,更多關于Java 使用Axis調用WebService的資料請關注好吧啦網其它相關文章!

標簽: Java
相關文章:
主站蜘蛛池模板: 欧美亚洲综合视频 | 亚洲区精品久久一区二区三区 | 日本a级片免费观看 | 萌白酱国产一区 | 亚洲精品亚洲一区二区 | 久草视频资源在线 | 欧美日韩一区二区不卡三区 | 一区二区三区四区视频 | 亚洲日本欧美产综合在线 | 亚洲日韩中文字幕天堂不卡 | 自拍 欧美| 91色老99久久九九爱精品 | 一区二区网站在线观看 | 久草综合在线观看 | 国产精品久久久久久麻豆一区 | 91精品手机国产露脸 | 久久久久爽亚洲精品 | 免费公开视频人人人人人人人 | 国产成人99精品免费观看 | 国产一区二区在线观看免费 | 日本高清在线不卡 | 欧美一级毛片免费看 | 中国一级毛片欧美一级毛片 | 一级国产精品一级国产精品片 | 久草在线观看首页 | 久久久久久综合成人精品 | selaoban在线视频免费精品 | 亚洲视频精品在线观看 | 亚洲国产精品日韩在线 | 午夜香蕉成视频人网站高清版 | 午夜爽爽爽视频 | 免费观看毛片视频 | 日韩毛毛片| 亚洲欧美一级久久精品 | 亚洲第一视频在线播放 | 一区二区精品视频 | 日韩手机看片福利精品 | 欧美日韩一区二区综合在线视频 | 亚洲男人的天堂久久无 | 欧美日韩高清不卡一区二区三区 | www.xxxx欧美|