有关apache soap的配置

iceying iceying 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如下两个文件:

// SOAPService.java
package HelloWorld;

public class SOAPService {
public String sayHi(String x) {
return("Hello my friend, " + x + "! Glad to see you!");
}
}

// HelloWorldClient.java
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;

public class HelloWorldClient {
public static void main(String[] arg) throws Exception {
Call c = null;
URL url = null;
Vector params = null;
Response rep = null;
String ourName = "Superman";
String ourUrn = "urn:HelloWorld_SOAPService";
String ourMethod = "sayHi";
url = new URL("http://localhost:8080/soap/servlet/rpcrouter");
System.out.println("Passing to our deployed "+ourUrn+" our name ("+ourName+"): ");
c = new Call();
c.setTargetObjectURI(ourUrn);
c.setMethodName(ourMethod);
c.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
params = new Vector();
params.addElement(new Parameter("ourName", String.class, ourName, null));
c.setParams(params);
System.out.print("and its answer is: ");
rep = c.invoke(url, "");
if (rep.generatedFault()) {
Fault fault = rep.getFault();
System.out.println("\nCall failed!");
System.out.println("Code = " + fault.getFaultCode());
System.out.println("String = " + fault.getFaultString());
} else {
Parameter result = rep.getReturnValue();
System.out.print(result.getValue());
System.out.println();
}
}
}

我已经把soap.jar、activation.jar和mail.jar加入系统的classpath,并且通过http://localhost:8080/soap/admin/index.html Deploy一个Provider Class为HelloWorld.SOAPService的Service

但是执行java HelloWorldClient出现如下错误:
Code = SOAP-ENV:Server.BadTargetObjectURI
String = Unable to resolve target object: HelloWorld.SOAPService

我猜想这个错误是tomcat没有找到SOAPService这个类,这个问题如何解决?
我试过把HelloWorld.SOAPService封装成jar,改tomcat\bin\setclasspath.bat文件,还是不行。

本人刚刚接触soap,请高手指点,不胜感激!
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
iceying
Java EE 67,535 成员 225,843 内容