基於Axis1.4的webservice接口開發(接口調用)html
1、webservice接口代碼參考上一篇博客:java
http://www.cnblogs.com/zhukunqiang/p/7125668.htmlweb
2、代碼部分apache
一、新建Web Project工程,取名爲axiswebserviceClint,並導入Axis1.4所需jar包(將jar包粘貼到lib目錄)。
url
二、新建webservice接口調用類:spa
package com.no8.clint; import java.net.URL; import javax.xml.rpc.ServiceException; import org.apache.axis.AxisFault; import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class WebClient { public static void main(String[] args) throws Exception { String endpoint = "http://localhost:8080/axiswebservice/services/HelloWorld?wsdl"; //建立一個服務(service)調用(call) Service service = new Service(); Call call = (Call) service.createCall(); //設置service所在的url call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperation("sayHello"); String ret = (String)call.invoke(new Object[]{"張三"}); System.out.println(ret); } }
三、點擊運行java類(直接運行java文件,不須要將web工程部署到Tomcat中就可直接運行):.net
調用成功!xml