I've got a ASP.Net webservice that is functioning perfectly called from iPhone SOAP code or another .Net client. However, when I try to use Ksoap2 the parameters passed to the service are not set. In service the parameter "AuthenticationID" must not be coming in because the first thing the WebMethod does is to check if the string is null or empty and returns an "AuthenticationFailure" response. I do get that response so I know the SOAP stuff is just fine, just the parameter is not being passed.
public SoapObject soap(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL) throws IOException, XmlPullParserException {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("AuthenticationID", "5");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.debug = true;
httpTransport.call(SOAP_ACTION, envelope);
SoapObject result=(SoapObject)envelope.getResponse();
return result;
}
And the WSDL looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<LookupStores xmlns="http://blah.com/Services/">
<AuthenticationID>string</AuthenticationID>
<NameMatch>string</NameMatch>
</LookupStores>
</soap:Body>
</soap:Envelope>
Please give me some things to try this is just a simple service and I thought it would be easy to consume using KSoap2. Thanks!
I had a similar problem and managed to pass my parameter by using a PropertyInfo. Try the code below, no garanty it will work but worth giving a go.
public SoapObject soap(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL) throws IOException, XmlPullParserException
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("int"); //change to appropriate type e.g. String
pi.setValue(5); // if sString add the speech marks e.g. "5"
pi.setType("AuthenticationID".getClass());
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.debug = true;
httpTransport.call(SOAP_ACTION, envelope);
SoapObject result=(SoapObject)envelope.getResponse();
return result;
}
Hope this helps.