axis2 默认端口_使用axis2创建webservice
這個方式創建的webservice可以和web項目放到同一個工程下。
創建webservice服務,所需要的jar包如下:
axiom-api-1.2.8.jar
axiom-impl-1.2.8.jar
axis-0.1.jar
axis2-adb-1.5.jar
axis2-kernel-1.5.jar
axis2-transport-http-1.5.jar
axis2-transport-local-1.5.jar
commons-codec-1.3.jar
commons-httpclient-3.1-rc1.jar
commons-httpclient-4.3.2.jar
commons-logging-1.1.1.jar
httpcore-4.0.jar
mail-1.4.jar
neethi-2.0.5.jar
woden-api-1.0M8.jar
woden-impl-dom-1.0M8.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.3.jar
一 創建java web項目
二 將上面的jar包放到lib文件下
三 創建一個class 如下
packagecom.geng.webservice;public classHelloService {publicString getName(String xml){if(xml!=null){
System.out.println(xml);
}return "hello webservice";
}publicString getAge(String xml){return "test";
}
}
四 配置web.xml文件
testWebservice
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
AxisServlet
org.apache.axis2.transport.http.AxisServlet
1
AxisServlet
/services/*
五 還需要一個services.xml 配置文件
這個配置文件放在WebContent=>WEB-INF=>services=>aa=>META-INF=>services.xml
我創建的項目結構如下圖所示:
services.xml文件的配置內容如下
練習WebService服務
com.geng.webservice.HelloService
六 運行項目
將該地址http://localhost:8080/testWebservice/services/hello?wsdl放到瀏覽器中進行訪問,
服務返回的內容如下圖所示:
對這個訪問地址進行一下說明http://localhost:8080/testWebservice/ 這一塊是ip地址、端口、項目名
services這是web.xml文件配置的。hello是services.xml中配置的service的name。?wsdl這樣查看wsdl文件的內容。
通過瀏覽器訪問只能得到webservice服務提供那些方法,不能調用提供的方法。
要想調用webservice提供的方法進行測試的話,可以使用soapUI工具(沒聽過這工具,搜索一下你就知道)
關于soapui的使用可以參考這篇博客http://blog.sina.com.cn/s/blog_4f925fc30102edku.html
以上只是簡單的入門,在實際開發中往往是比較復雜的。
關于如何配置services.xml可以參考這篇博客http://beyond-gzz.blog.163.com/blog/static/744735620119935948592/
總結
以上是生活随笔為你收集整理的axis2 默认端口_使用axis2创建webservice的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: asurerp可以导出php文件吗,编译
- 下一篇: c语言程序综合实习学生成绩,C语言程序设