【问题标题】:android ksoap2 - faultcode: 'S:Client' faultstring: 'Cannot find dispatch methodandroid ksoap2 - faultcode: 'S:Client' faultstring: '找不到调度方法
【发布时间】:2015-02-07 19:07:52
【问题描述】:

我已经寻找了很多线程,但没有一个有助于解决这个问题。

快捷方式:当我们想从模拟器访问本地主机网络服务时,应该如下所示:

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";

问题:

在本地电脑上有基于 SOAP 的 Web 服务。它在本地经过测试和访问。例如:网址

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 运行项目时,它使用 url 分解 web:

http://localhost:8080/Serwer/

当我从浏览器访问它时它可以工作。 要从 Android 访问它,使用了 ksoap2 库。使用 Genymotion 模拟器(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 服务连接起来,没有任何问题。 即使在精灵http://10.0.3.2:8080/Serwer/ 中的http://localhost:8080/Serwer/ 也可以。

有什么想法吗?

【问题讨论】:

    标签: java android web-services soap wsdl


    【解决方案1】:

    你设置了 OutputSoapObject 吗?

    SoapObject request = new SoapObject(namespace, method);
    

    ....

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多