I am trying to call a WSDL webservice running on local Tomcat server via Android Eclipse Emulator. I am using KSOAP2 to initiate service call.
The error I see when trying to get a response:
SoapFault - faultcode: 'S:Client' faultstring: 'Cannot find dispatch method for {http://localhost:8080/test/}getAllAvailableAssessments' faultactor: 'null' detail: null
Some things to note:
This is the class that calls webservice:
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;
}
And this is the wsdl file:
<?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>
Any ideas would be appreciated.
The SOAP_ACTION
variable does not have to follow NAMESPACE + METHOD_NAME
pattern. These values could be anything, depending on the WSDL structure.
After comparing request XML from SoapUI with dumped request XML from KSOAP2 I saw a mismatch.
Particularly in this case, adding "Request" string at the end of the SOAP_ACTION
variable solves the issue.
Hence,
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";