I need to consume a SOAP web service using Android.
The issue is that before request for a particular function I need to authenticate a client using basic http request.
Do you know how to do this using KSOAP?
Until this moment I have tried using overloaded method of httpsTransportSE.call() as it suggest that I can specify additional headers for http connection
headerPropertyList.add(new HeaderProperty("Authorization", "Basic : dXNlcjpwYXNz"));
"cdXNlcjpwYXNz" is base 64 encoded string of "user:pass"
public List call(String soapAction, SoapEnvelope envelope, List headers)
* @param headers a list of HeaderProperties to be http header properties when establishing the connection
private static final String SOAP_ACTION = "someaddress/IPortReporting/GetPortStatus";
private static final String METHOD_NAME = "methodname";
private static final String NAMESPACE = "http://ssn.someaddress/2.0/";
private static final String URL = "new.someaddress/functionName.svc";
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("MessageId", "1");
SoapSerializationEnvelope soapEnvelop = new SoapSerializationEnvelope(
11);
//soapEnvelop.headerOut = addHeaders();
soapEnvelop.dotNet = true;
soapEnvelop.setOutputSoapObject(Request);
List<HeaderProperty> headerPropertieList = new ArrayList<HeaderProperty>();
headerPropertyList.add(new HeaderProperty("Authorization", "Basic : cG9ydHdzOjEyM3F3ZUFTRA=="));
//HeaderProperty headerProperty = new HeaderProperty()
HttpsTransportSE httpsse = new HttpsTransportSE(URL, 443, "", 5000);
try {
httpsse.call(SOAP_ACTION, soapEnvelop, headerPropertyList);
//httpsse.call(SOAP_ACTION, soapEnvelop);
SoapPrimitive resultString = (SoapPrimitive) soapEnvelop
.getResponse();
tv.setText("Status: ");
} catch (Exception e) {
tv.setText("Some error," + " "
+ e.getMessage());
}
But I have message "permission denied" reported back.
Have you tried HttpTranspostBasicAuth?
Here is the reference information: http://ksoap2.sourceforge.net/doc/api/org/ksoap2/transport/HttpTransportBasicAuth.html
At the linked question to this one, the second arg of the HeaderProperty does not have a colon in it - it would be "Basic dXNlcjpwYXNz" - maybe that's the problem? (Which one is correct?)
See this. I have implemented a simple code that calls a local SOAP web service(.asmx) from Android application.
It is a simple web service to authenticate user using username and password.
Hope that helps
Cheers
You most probably need to include the following in your Android manifest file:
Try this. This worked for me, consuming .Net service from android application. I have used ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar
THIS WORK only https://stackoverflow.com/a/5614243/7198554 ....
this - >
SoapSerializationEnvelope envelope
NAMESPACE this -> http://tempuri.org/ my code=>In VS C#