對方使用的環境爲ASP.NET java
下載AXIS2的1.6.2包:http://axis.apache.org/axis2/java/core/download.cgi根據wsdl文件描述,使用 wsdl2java.bat 工具生成調用代碼 apache
命令以下:wsdl2java.bat -uri http://xxx.xxx.xxx:xxx/Services.asmx?wsdl app
生成的兩個class文件(ServicesCallbackHandler.java,ServicesStub.java)在D:/axis2-1.6.2/bin/src目錄下面, 拷貝到你的項目中進行編譯 工具
編譯前要把D:/axis2-1.6.2/lib目錄下面的包拷貝到你的項目中 測試
調用測試:public class TestCollectShowInfo{ public static String getXml(){ //該XML格式按照對方要求而生成 StringBuffer buf = new StringBuffer(); buf.append("<?xml version='1.0' encoding='UTF-8'?>"); buf.append("<root>"); buf.append("<head>"); buf.append("<requestid>11111</requestid>"); buf.append("<username>11111</username> "); buf.append("<password>11111</password>"); buf.append("</head>"); buf.append("<body>"); buf.append("<record productid=\"1002\" title=\"東莞醫療機構首現社會監督員\" url =\"www.baidu.com\" createtime =\"2008-11-12\" type=\"0\"/>"); buf.append("<record productid=\"1002\" title=\"78歲老太手術成功完全結束\" url =\"www.baidu.com\" createtime =\"2008-11-11\" type=\"1\" />"); buf.append("</body>"); buf.append("</root>"); return buf.toString(); } public static void main(String[] args){ try{ String uri = "http://xxx.xxx.xxx:xxx/Services.asmx"; ServicesStub stub = new ServicesStub(uri); CollectShowInfo info = new CollectShowInfo(); info.setXmlstr(getXml()); // xmlstr是要傳給WEBSERVICE的內容.本例子傳的是一個XML串 CollectShowInfoResponse response = stub.CollectShowInfo(info); System.out.println(response.getCollectShowInfoResult()); //輸出返回的結果 }catch (Exception e){ e.printStackTrace(); } } }注意: CollectShowInfo及CollectShowInfoResponse兩個CLASS是ServicesStub.java中的內部類.