2014-08-28 77 views
1

我想通过Android Eclipse模拟器调用在本地Tomcat服务器上运行的WSDL webservice。我正在使用KSOAP2来启动服务呼叫。在Android模拟器上运行的KSOAP2 WebService错误

我看到试图得到回应时,错误:

SoapFault - faultcode: 'S:Client' faultstring: 'Cannot find dispatch method for {http://localhost:8080/test/}getAllAvailableAssessments' faultactor: 'null' detail: null 

需要注意以下几点:

  • 我已经给INTERNET权限
  • WebService的运行良好的应用程序,如果测试on soapUI
  • 我能够看到WSDL文件给出了它的URL到仿真器的浏览器

这是调用Web服务类:

private static String NAMESPACE = "http://localhost:8080/test/"; 
private static String URL = "http://10.10.10.55:8080/testwebservices/WebServices/AssessmentListingService?wsdl"; 
private static String METHOD_NAME = "getAllAvailableAssessments"; 
private static String SOAP_ACTION = "http://localhost:8080/test/getAllAvailableAssessments"; 

public static String getAllAvailableAssessments() 
{ 
    String webServiceResult = ""; 

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    envelope.setOutputSoapObject(request); 
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
    try 
    { 
     androidHttpTransport.call(SOAP_ACTION, envelope); 
     SoapPrimitive response = (SoapPrimitive) envelope.getResponse(); 
     webServiceResult = response.toString(); 
    } 
    catch(Exception e) 
    { 
     e.printStackTrace(); 
    } 

    return webServiceResult; 
} 

这是WSDL文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<wsdl:definitions xmlns:assessmentListing="http://localhost:8080/test/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="AssessmentListingService" targetNamespace="http://localhost:8080/test/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://localhost:8080/test/AssessmentListing/"> 
<wsdl:types> 
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <xsd:import namespace="http://localhost:8080/test/AssessmentListing/" schemaLocation="AssessmentListing.xsd"></xsd:import> 
    </xsd:schema> 
</wsdl:types> 
<wsdl:message name="getAllAvailableAssessmentsRequest"> 
    <wsdl:part name="parameters" 
     element="xsd:getAllAvailableAssessmentsRequest"> 
    </wsdl:part> 
</wsdl:message> 
<wsdl:message name="getAllAvailableAssessmentsResponse"> 
    <wsdl:part name="parameters" 
     element="xsd:getAllAvailableAssessmentsResponse"> 
    </wsdl:part> 
</wsdl:message> 
<wsdl:portType name="AssessmentListingService"> 
    <wsdl:operation name="getAllAvailableAssessments"> 
     <wsdl:input message="assessmentListing:getAllAvailableAssessmentsRequest"></wsdl:input> 
     <wsdl:output message="assessmentListing:getAllAvailableAssessmentsResponse"></wsdl:output> 
    </wsdl:operation> 
</wsdl:portType> 
<wsdl:binding name="AssessmentListingServicePortBinding" 
    type="assessmentListing:AssessmentListingService"> 
    <soap:binding style="document" 
     transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="getAllAvailableAssessments"> 
     <soap:operation 
      soapAction="http://localhost:8080/test/AssessmentListingService/getAllAvailableAssessments" /> 
     <wsdl:input> 
      <soap:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
      <soap:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
</wsdl:binding> 
<wsdl:service name="AssessmentListingService"> 
    <wsdl:port name="AssessmentListingServicePort" binding="assessmentListing:AssessmentListingServicePortBinding"> 
     <soap:address location="http://localhost:8080/testwebservices/WebServices/AssessmentListingService" /> 
    </wsdl:port> 
</wsdl:service> 

任何想法,将不胜感激。

+0

你为什么不本地运行Web服务和阅读两个点后的数字: “://本地主机:HTTP” NEW_NUMBERS “/测试/ getAllAvailableAssessments”; – 2014-08-28 21:33:46

回答

0

SOAP_ACTION变量不必遵循NAMESPACE + METHOD_NAME模式。这些值可以是任何值,具体取决于WSDL结构。

将来自SoapUI的请求XML与来自KSOAP2的转储请求XML进行比较后,我看到不匹配。

特别是在这种情况下,在SOAP_ACTION变量末尾添加“请求”字符串可解决此问题。

因此,

private static String NAMESPACE = "http://localhost:8080/test/"; 
private static String URL = "http://10.10.10.55:8080/testwebservices/WebServices/AssessmentListingService?wsdl"; 
private static String METHOD_NAME = "getAllAvailableAssessments"; 
private static String SOAP_ACTION = "http://localhost:8080/test/getAllAvailableAssessmentsRequest";