jsp 調用webservice 實例
安裝Axis (Install Axis)
http://ws.apache.org/axis/
http://ws.apache.org/axis/download.cgi
2. unpack to d:/axis-1_1
3.配置系統環境變量Windows:
set AXIS_HOME=D:\opensource\axis\axis-1_1
set AXIS_LIB=%AXIS_HOME%\lib
set AXISCLASSPATH=%AXIS_LIB%\axis.jar;
%AXIS_LIB%\commons-discovery.jar;
%AXIS_LIB%\commons-logging.jar;
%AXIS_LIB%\jaxrpc.jar;
%AXIS_LIB%\saajjar;
%AXIS_LIB%\log4j-1.2.8.jar;
%AXIS_LIB%\saaj.jar;
%AXIS_LIB%\wsdl4j.jar;
How to use WSDL2Java
Given a WSDL file of a web service you can manually code a client based on your understanding of WSDL document or you can use a tool to do that for you. This is very handy when WSDL is very complex. Axis provides such tool. Here is the command that you can run on GoogleSeach.wsdl.
java org.apache.axis.wsdl.WSDL2Java --verbose GoogleSearch.wsdl
Make sure that you have axis.jar file in your classpath while executing this command, as that is where org.apache.axis.wsdl.WSDL2Java resides.
You will find a number of .java files generated in a subdirectory named GoogleSearch. These are the stub files or wrapper classes. The wrapper classes allow you to code in java data types and convert them transparently to XML.
在網上google 一個有效的wsdl:
http://www.webservicex.com/stockquote.asmx?WSDL
D:\projects\test\webservice\src>java org.apache.axis.wsdl.WSDL2Java --verbose http://www.webservicex.com/stockquote.asmx?WSDL
Parsing XML file: http://www.webservicex.com/stockquote.asmx?WSDL
Generating NET\webserviceX\www\StockQuote.java
Generating NET\webserviceX\www\StockQuoteLocator.java
Generating NET\webserviceX\www\StockQuoteSoap.java
Generating NET\webserviceX\www\StockQuoteSoapStub.java
建立工程寫 java test






























運行測試:
D:\projects\test\webservice\classes>java -classpath %classpath%;.;NET.webservice
X.www.*; Test




















D:\projects\test\webservice\classes>
成功了。:)
這樣,就完成了對.NET WebService端的調用。
(data filetype:mdb)
方向:分布式系統設計
posted on 2005-03-07 15:52 java光環 閱讀(5830) 評論(3) 編輯 收藏 所屬分類: webservice