I'm trying to consume some WCF data services from an android application, using ksoap2
and running in Genymotion. I can access the URL from the emulator web browser, but when I try to use it from my code I get this exception:
12-22 12:46:34.911: W/System.err(5230): org.ksoap2.transport.HttpResponseException: HTTP request failed, HTTP status: 307
My code in the android app is like this:
private static final String SOAP_ACTION = "http://192.168.1.223:82/Adv.svc/and_hist_ventas?$filter=xarticulo_id eq '''666'''";
private static final String METHOD_NAME = "GetHistVentas";
private static final String NAMESPACE = "Adv";
private static final String URL = "http://192.168.1.223:82/Adv.svc";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE transport = new HttpTransportSE(URL);
transport.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
String resultData = result.toString();
I get the exception in transport.call(SOAP_ACTION, envelope);
and, since I know, a 307 error is a redirection loop, which doesn't make sense for me. Remember please that I can access to the web service from the emulator browser.
Any idea?
I am guessing that WCF needs you to change your URL to use an ending slash. This is the most usual reason for 307 response. So use the Uri with the ending slash to avoid WCF responding with the 307 like so "http://192.168.1.223:82/Adv.svc/"
.
It would help though if you updated your question to show the raw http response using a tool like fiddler