java 安卓 ksoap2 faultcode:'S:Client'faultstring:'找不到分派方法
我已经寻找了很多线索,但没有一个能帮助解决这个问题
快捷方式:当我们要从emulator访问localhost web服务时,应该如何显示以下URL:
private static final String NAMESPACE = "http://10.0.3.2:8080/SerwerWS/";
private static final String MAIN_REQUEST_URL = "http://10.0.3.2:8080/SerwerWS/SerwerWS?wsdl";
private static final String SOAP_ACTION = "http://10.0.3.2:8080/SerwerWS/hello";
private static String methodName = "hello";
问题:
在本地pc上有一个基于SOAP的web服务。它在本地经过测试并可访问。例如:URL
http://localhost:8080/SerwerWS/SerwerWS?Tester
http://localhost:8080/SerwerWS/SerwerWS?wsdl
“WSDL定义”节点包含:
targetNamespace="http://serwer.me.org/"
name="SerwerWS"
namespace="http://serwer.me.org/"
schemaLocation="http://localhost:8080/SerwerWS/SerwerWS?xsd=1"
wsdl定义了两种方法:
<portType name="SerwerWS">
<operation name="hello">
<input wsam:Action="http://serwer.me.org/SerwerWS/helloRequest" message="tns:hello"/>
<output wsam:Action="http://serwer.me.org/SerwerWS/helloResponse" message="tns:helloResponse"/>
</operation>
<operation name="getImage">
<input wsam:Action="http://serwer.me.org/SerwerWS/getImageRequest" message="tns:getImage"/>
<output wsam:Action="http://serwer.me.org/SerwerWS/getImageResponse" message="tns:getImageResponse"/>
</operation>
</portType>
当我从ide运行Project时,它会使用url:
http://localhost:8080/Serwer/
当我从浏览器访问此文件时,它会工作。 要从Android访问它,需要使用ksoap2库。使用Genymotion emulator(localhost设置为10.0.3.2)进行访问,如下所示:
private static final String NAMESPACE = "http://10.0.3.2:8080/SerwerWS/";
private static final String MAIN_REQUEST_URL = "http://10.0.3.2:8080/SerwerWS/SerwerWS?wsdl";
private static final String SOAP_ACTION = "http://10.0.3.2:8080/SerwerWS/hello";
private static String methodName = "hello";
呼叫
ht.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive) envelope
.getResponse();
响应
SoapFault - faultcode: 'S:Client' faultstring: 'Cannot find dispatch method for {http://10.0.3.2:8080/SerwerWS/}hello' faultactor: 'null' detail: null
为了验证genymotion是否正常,我已经将示例应用程序与一些免费的web SOAP服务连接起来,没有任何问题。
甚至genyhttp://10.0.3.2:8080/Serwer/
中的http://localhost:8080/Serwer/
也可以
有什么想法吗
# 1 楼答案
您是否设置了OutputSoapObject