使用Axis1.4 和 Spring2.5.6搭建最簡易的Webservice及如何在Windchill 7.0中配置(二)

補充: 1.Demo配置/WebContent/WEB-INF/web.xml文件最後需如下: DemoAxisServletApache-Axis Servlet org.apache.axis.transport.http.AxisServletAdminServletAxis Admin Servlet org.apache.axis.transport.http.AdminServlet100AxisServlet/servlet/AxisServletAxisServlet*.jwsAxisServlet/services/*AdminServlet/servlet/AdminServletindex.htmlindex.htmindex.jspdefault.htmldefault.htmdefault.jsp 2.可以使用axis提供的Java2WSDL功能生成所要發布類的WSDL, 方法一,步驟如下: 1)在eclipse項目Demo中找到引入的 axis.jar包,打開它, 在其裏面找到org.apache.axis.wsdl下面的Java2WSDL類,然後以[Java application]方式運行一下它 2).打開菜單[run]->[Debug],在彈出框的左邊找到[Java Application]項,在裏面你會看到“Java2WSDL”子項, 左鍵點擊它->在右面“Main”選項下有:[Project]選擇Demo,[Main class]為'org.apache.axis.wsdl.Java2WSDL' 這些信息是默認的,不需要改動;進入[Arguments]選項,在其下[Program arguments]中輸入: -d[]-l"http://127.0.0.1:8080/Demo/services/demoService"[]-o[]"demoService.wsdl"[]webservice.DemoServiceEndPoint 說明:以上[]為空格 輸入參數的意思: -d 這個選項是要生成deploy.wsdd和undeploy.wsdd -l 這個選項是要生成webService客戶端要訪問的地址,假設為:http://127.0.0.1:8080/Demo/services/demoService 此處需注意:在windchill中,此處的地址為在步驟6設定的地址相匹配,例如: http://localhost/Winchill/services/demoService 這樣才能讓Apache將請求轉發至Tomcat中處理 -o 這個選項是要生成wsdl文件,假設文件名為:demoService.wsdl webservice.DemoServiceEndPoint 就是要發布的類 3).然後左鍵點擊"Debug"按鈕,就可以生成wsdl文件了。 方法二,步驟如下: 1)在windows系統中[開始]->[執行]->輸入cmd 2)在cmd窗口執行如下命令: cd C:/ptc/tomcat/webapps/Demo 說明:如果是Windhill中就進入至%Windchill_home%/codebase目錄 3.可以使用axis提供的AdminClient功能生成所需的server-config.wsdd文件 執行步驟前提:Tomcat啟動,如果是在Demo中發布Webservice就將Demo項目打包部署至Tomcat中; 步驟如下: 1)在windows系統中[開始]->[執行]->輸入cmd 2)在cmd窗口執行如下命令: cd C:/ptc/tomcat/webapps/Demo/WEB-INF 說明:如果是Windhill中就進入至%Windchill_home%/codebase/WEB-INF目錄 3)在cmd窗口執行如下代碼: java[]-cp[]C:/WEBServiceJars/axis-1_4/axis.jar;C:/WEBServiceJars/axis-1_4/axis-ant.jar; C:/WEBServiceJars/axis-1_4/commons-discovery-0.2.jar; C:/WEBServiceJars/axis-1_4/commons-logging-1.0.4.jar; C:/WEBServiceJars/axis-1_4/jaxrpc.jar;C:/WEBServiceJars/axis-1_4/log4j-1.2.8.jar; C:/WEBServiceJars/axis-1_4/saaj.jar;C:/WEBServiceJars/axis-1_4/wsdl4j-1.5.1.jar []org.apache.axis.client.AdminClient[]-lhttp://localhost:8081/Demo/servlet/AxisServlet []deploy.wsdd 說明:以上為一行代碼,中間無[回車]按鍵操作,執行時將[]換為空格 "C:/WEBServiceJars/axis-1_4/"是Axis包中jar的位置 輸入參數的意思: -l 這個選項是要生成webService客戶端要訪問的地址,此處假設為:http://127.0.0.1:8080/Demo/services/demoService 此處需注意:在windchill中,此處的地址為在步驟6設定的地址相匹配,例如: http://localhost/Winchill/services/demoService 這樣才能讓Apache將請求轉發至Tomcat中處理 deploy.wsdd為deploy文件在工程中的路徑 4)[回車]按鍵後,輸出如下表示成功: Processing file deploy.wsdd Done processing 如果輸出如下表示執行成功,但是在鏈接至服務端時創建出錯: Processing file deploy.wsdd Exception: AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.net.ConnectException: Connection refused: connect faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne ction refused: connect 如果是部署Demo至Windchill系統中的Tomcat,則需在%Tomcat_home%/conf/server.xml文件將HTTP訪問打開 解開如下代碼的注釋即可: 5)重啟Tomcat
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章