Question

I am new to android and very new to soap web service calling. I am trying to call soap based web service using ksoap2 library but continuously getting error message

java.io.IOException: HTTP request failed, HTTP status: 405

But I am not able to understand why is it happening. I have searched over internet and could not found any solution to my problem.

these are the fields I am using:

private static final String METHOD_NAME = "Authenticate";
private static final String SOAP_ACTION = "http://tempuri.org/IService1/Authenticate";
private static final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
private static final String NAMESPACE = "http://tempuri.org/";

This is the wsdl url: http://www.w3schools.com/webservices/tempconvert.asmx?WSDL

This should be the request format: http://www.w3schools.com/webservices/tempconvert.asmx?WSDL

I have tested this service with web service studio and got the following request and working fine.

<?xml version="1.0" encoding="utf-16"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><Authenticate xmlns="http://tempuri.org/">
  <UserName>test</UserName>
  <Password>test</Password>
</Authenticate></soap:Body></soap:Envelope>

I am trying to call this service using below code

request = new SoapObject(NAMESPACE, METHOD_NAME);       
request.addProperty("UserName","test");
request.addProperty("Password","test");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.setOutputSoapObject(request);

HttpTransportSE ht = new HttpTransportSE(URL);
ht.call(SOAP_ACTION, envelope);

So please help me to get response from this service.

Was it helpful?

Solution

Why are you using "http://demo.knowcross.com/TritonMobileService"; as URL? Service address you can find in wsdl and it is:

<soap:address location="http://demo.knowcross.com/TritonMobileService/Service1.svc"/>

so you should use it as URL.

EDIT: You can set ht.debug=true and check whether ht.requestDump is correct. First of all you should add the namespace for properties like this:

PropertyInfo p = new PropertyInfo();
p.setNamespace(NAMESPACE);
p.setValue("test");
p.setName("UserName");
request.addProperty(p);
p = new PropertyInfo();
p.setNamespace(NAMESPACE);
p.setValue("test");
p.setName("Password");
request.addProperty(p);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top