我已经找了很多线程,但没有一个帮助解决这个问题。
快捷方式:当我们想要从模拟器访问localhost网络服务时,应该如何看起来像以下网址:
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服务。它在本地进行测试和访问。例如:urls
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服务连接,没有任何问题。
即使geny http://localhost:8080/Serwer/
中的http://10.0.3.2:8080/Serwer/
也可以。
有什么想法吗?
答案 0 :(得分:0)
您是否设置了OutputSoapObject?
SoapObject request = new SoapObject(namespace, method);
...
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);