bruce 转贴 (参与分:18537,专家分:3650) 发表:2002-8-20 下午2:27 版本:1.0 阅读:5105次
Author:疯傻 madfool@163.net
相关下载:
Apache SOAP http://xml.apache.org/soap/index.html
Tomcat4.0.4 http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.4/
1.安装Apache SOAP到C盘根目录,即C:\soap-2_3_1
http://www.javaresearch.org/article/showarticle.jsp?column=5&thread=1641
2.安装Tomcat4.0.4到C:\Program Files\Apache Tomcat 4.0
3.复制C:\soap-2_3_1\webapps\soap.war文件到C:\Program Files\Apache Tomcat 4.0\webapps目录下
4.建立测试目录C:\soaptest和C:\soaptest\classes
5.修改系统环境变量CLASSPATH,加入C:\soaptest\classes\test.jar
6.启动Tomca4.0.4,方法有两个:A.执行C:\Program Files\Apache Tomcat 4.0\bin\startup.ba;B.通过系统管理的服务管理开启Apache Tomcat4.0.4
7.建立测试java源文件,源文件应放置在目录C:\soaptest下
//SimpleMath.javapackage test;public class SimpleMath{ public double getSinValue(double input) { double ret = Math.sin(input); return ret; }}
---第二个JAVA源文件----------------
//SimpleMathClient.javapackage test;import java.io.*;import java.net.*;import java.util.*;import org.apache.soap.util.xml.*;import org.apache.soap.*;import org.apache.soap.rpc.*;public class SimpleMathClient{ public static void main(String[] args) throws Exception { System.err.println("SOAP call testing"); double value = Math.random(); SimpleMathClient smc = new SimpleMathClient(); //调用远程的SOAP服务 double returnValue = smc.doRequest(value); System.err.println("the sin value of "+value +"is: "+returnValue); } public double doRequest(double value) throws Exception { // Build the call. Call call = new Call (); //设置远程对象的URI call.setTargetObjectURI ("urn:test.math.sin"); //设置调用的方法名 call.setMethodName ("getSinValue"); //设置编码风格 call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); //设置方法调用的参数 Vector params = new Vector (); params.addElement (new Parameter("input", double.class, new Double (value), null)); call.setParams (params); //发送RPC请求 Response resp = call.invoke (new URL("http://127.0.0.1:8080/soap/servlet/rpcrouter"),""); if (resp.generatedFault ()) { //远程调用出错处理 Fault fault = resp.getFault (); System.out.println ("the call failed: "); System.out.println (" Fault Code = " + fault.getFaultCode ()); System.out.println (" Fault String = " + fault.getFaultString ()); return 0.0d; } else { //调用成功,获取返回值 Parameter result = resp.getReturnValue (); return ((Double)result.getValue()).doubleValue(); } }}
8.编译java源文件,并打包
a. cd c:\soaptest
b. javac -d classes *.java
c. cd classes
d. jar -cvf test.jar test
9.SOAP服务的发布
使用IE浏览器浏览http://localhost:8080/soap/admin/index.html,进入Deploy,填写如下信息:
ID: urn:test.math.sin
Scope: Request
Methods getSinValue
Provider Type: Java
Java Provider Provider Class: test.SimpleMath
Java Provider Static: NO
确认发布,可以点List查看已发布服务!
10.运行测试程序
a. cd c:\soaptest
b. java test.SimpleMathClien
应该可以看到返回的数值,则证明配置和测试成功,以后就可以发布自己的SOAP服务了!
jhsea3do 回复于:2004-02-11 13:49:59 |
现在都开始用axis了,soap快要成为过去式了 |
ruochen 回复于:2005-03-18 16:22:37 |
axis
soap 都不知道是什么东西! 麻烦请解释下! |
regedit 回复于:2005-04-25 22:01:48 |
axis C/C++ 在linux 下的makefile 需要加载那些库文件啊,刚开始学,多多指教,谢谢! |
jhsea3do 回复于:2005-04-26 19:32:58 |
哦,好像的确是有一个C版本的,
库中起码要一个 Xerces 的库吧,去C版问 |
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/