当前位置: 技术问答>java相关
Apache Soap问题,能正确部署Service,确始终不能调用!
来源: 互联网 发布时间:2015-08-13
本文导语: 急死了,我写了个最简单的: //SayHelloService.java public class SayHelloService { public String getValue() { return "Hello World :p"; } } //部署描述符d.xml //客户端Client.java import java.net.URL; import org.apache.soap.SO...
急死了,我写了个最简单的:
//SayHelloService.java
public class SayHelloService
{
public String getValue()
{
return "Hello World :p";
}
}
//部署描述符d.xml
//客户端Client.java
import java.net.URL;
import org.apache.soap.SOAPException;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
public class Client {
public static void main(String[] args) throws Exception {
try {
URL url = new URL("http://localhost:8080/soap/servlet/rpcrouter");
Call call = new Call();
call.setTargetObjectURI("serv:SayHello");
call.setMethodName("getValue");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Response resp = null;
try {
resp = call.invoke(url, "");
} catch (SOAPException e) {
System.err.println("Caught SOAPException (" + e.getFaultCode()
+ "): " + e.getMessage());
e.printStackTrace();
System.exit(-1);
}
// Check the response.
if (!resp.generatedFault())
{
Parameter ret = resp.getReturnValue();
Object value = ret.getValue();
System.out.println(value);
}
else
{
Fault fault = resp.getFault();
System.err.println("Generated fault: ");
System.out.println(" Fault Code = " + fault.getFaultCode());
System.out.println(" Fault String = " + fault.getFaultString());
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
我现在用命令将SayHelloService部署了,通过管理工具可以看到部署后serv:SayHello
但是运行Client后,得到如下信息:
Generated fault:
Fault Code = SOAP-ENV:Server.BadTargetObjectURI
Fault String = Unable to resolve target object: SayHelloService
应该是我指定的TargetObjectURI不对吧,感觉快成功了,不知道哪里错了。。。
//SayHelloService.java
public class SayHelloService
{
public String getValue()
{
return "Hello World :p";
}
}
//部署描述符d.xml
//客户端Client.java
import java.net.URL;
import org.apache.soap.SOAPException;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
public class Client {
public static void main(String[] args) throws Exception {
try {
URL url = new URL("http://localhost:8080/soap/servlet/rpcrouter");
Call call = new Call();
call.setTargetObjectURI("serv:SayHello");
call.setMethodName("getValue");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Response resp = null;
try {
resp = call.invoke(url, "");
} catch (SOAPException e) {
System.err.println("Caught SOAPException (" + e.getFaultCode()
+ "): " + e.getMessage());
e.printStackTrace();
System.exit(-1);
}
// Check the response.
if (!resp.generatedFault())
{
Parameter ret = resp.getReturnValue();
Object value = ret.getValue();
System.out.println(value);
}
else
{
Fault fault = resp.getFault();
System.err.println("Generated fault: ");
System.out.println(" Fault Code = " + fault.getFaultCode());
System.out.println(" Fault String = " + fault.getFaultString());
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
我现在用命令将SayHelloService部署了,通过管理工具可以看到部署后serv:SayHello
但是运行Client后,得到如下信息:
Generated fault:
Fault Code = SOAP-ENV:Server.BadTargetObjectURI
Fault String = Unable to resolve target object: SayHelloService
应该是我指定的TargetObjectURI不对吧,感觉快成功了,不知道哪里错了。。。
|
from Apache-SOAP User's FAQ
http://xml.apache.org/soap/faq/faq_chawke.html#Q4_3
4.3 Help! My client sees error message: "SOAP-ENV:Server.BadTargetObjectURI"
The most likely cause of this problem is a classpath error: The class file that implements your service is not in the classpath of
the server.
http://xml.apache.org/soap/faq/faq_chawke.html#Q4_3
4.3 Help! My client sees error message: "SOAP-ENV:Server.BadTargetObjectURI"
The most likely cause of this problem is a classpath error: The class file that implements your service is not in the classpath of
the server.
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。