Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » 技术文章库  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Apache SOAP的Web Services在Tomcat4.0.4的安装和测试
madfool



发贴: 0
积分: 0
于 2003-01-03 21:20 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
作者:疯傻 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

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.java
package test;
public class SimpleMath
{
public double getSinValue(double input)
{
double ret = Math.sin(input);
return ret;
}
}
---第二个JAVA源文件----------------

//SimpleMathClient.java
package 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服务了!

参考书籍: JavaWeb服务 应用开发详解




话题树型展开
人气 标题 作者 字数 发贴时间
6623 Apache SOAP的Web Services在Tomcat4.0.4的安装和测试 madfool 2895 2003-01-03 21:20

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923