I can't figure out why my soap request on Android does not work, I followed the tutorial on https://code.tutsplus.com/tutorials/consuming-web-services-with-ksoap--mobile-21242
Which is basically my code as follows:
public class SoapClient {
private static final String NAMESPACE = "https://ieslamp.technikum-wien.at/sys_bvu4_17_l/JamDec/ContentManager/soapservice.php";
//not used right now
private static final String TARGET_NAMESPACE = "http://ieslamp.technikum-wien.at/soap/getJamRoutes";
private static final String SOAP_ACTION = "https://ieslamp.technikum-wien.at/sys_bvu4_17_l/JamDec/ContentManager/soapservice.php/getJamRoutes";
//which is the URL I need? some tutorials say it's the url to the wsdl, but others say it's the location of the webservice
private static final String POST_URL = "https://ieslamp.technikum-wien.at/sys_bvu4_17_l/JamDec/ContentManager/soapservice.php?wsdl";
private static final String LOCATION_URL = "https://ieslamp.technikum-wien.at:443/sys_bvu4_17_l/JamDec/ContentManager/soapservice.php";
private Context context;
public SoapClient(Context context) {
this.context = context;
}
public String getJamsFromServer() {
String methodname = "getJamRoutes";
SoapObject request = new SoapObject(TARGET_NAMESPACE, methodname);
String routes = null;
SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);
HttpTransportSE ht = getHttpTransportSE();
try {
ArrayList<HeaderProperty> headerPropertyArrayList = new ArrayList<>();
headerPropertyArrayList.add(new HeaderProperty("Connection", "close"));
ht.call(SOAP_ACTION, envelope, headerPropertyArrayList);
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
routes = result.toString();
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
return routes;
}
private final SoapSerializationEnvelope getSoapSerializationEnvelope(SoapObject request) {
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.implicitTypes = true;
envelope.setOutputSoapObject(request);
return envelope;
}
private final HttpTransportSE getHttpTransportSE() {
HttpTransportSE ht = new HttpTransportSE(Proxy.NO_PROXY, LOCATION_URL, 1200000);
ht.debug = true;
ht.setXmlVersionTag("<!--?xml version=\"1.0\" encoding= \"UTF-8\" ?-->");
return ht;
}
}
The service returns a "Hello World" - String, and I am using SOAP-UI to test it and a request with this software actually gives me a response, but when I am trying to make a response with my Android app -
ht.call();
throws a EOF-Exception on me and I can't figure out what's wrong.
Can you maybe explain which namespace and url for -
HttpTransportSE ht = new HttpTransportSE(URL);
I actually need? And do I use the targetNamespace or Namespace? I can't figure out while researching.
Here is my generated wsdl file:
Thank you for your Help!
The problem solved itself, it seems that the newest jar file does not work. If you are going to use ksoap I would recommend you to use older versions which are flagged as deprecated, but they will at least do the job.