I am trying to use the ksoap2 library to pull a request from a working (professional) server. After this testing this (flawlessly) in a java application but when I try to implement it in an Android application it messes up.
Here is my webservice class and the links work and so does the request:
private final static String MAIN_REQUEST_URL = "http://quantore-test.rightclick.nl/rc/public/webservices/private/app/catalog.cfc?wsdl";
private final static String SOAP_ACTION = "";
private final static String NAMESPACE = "http://rightclick.nl/webservices/private/app/catalog";
String value;
public WebService() throws Exception {
String id = "1456458";
double shopId = 156;
double siteId = 1456398;
HttpTransportSE ht = getHttpTransportSE();
String methodname = "getFolders";
SoapObject request = new SoapObject(NAMESPACE, methodname);
request.addProperty("id", id);
request.addProperty("shopId", shopId);
request.addProperty("siteId", siteId);
SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);
MarshallDouble marshall = new MarshallDouble();
marshall.register(envelope);
try {
ht.call(SOAP_ACTION, envelope); // bug is here.
}
catch(Exception e) {
System.out.println("Show error: ");
System.err.println(e.getMessage());
System.out.println("--------------------");
}
Here is the Android code in which I want to implement it :
private class ParseNFill extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... params) {
WebService service = null;
String data = null;
/**
* checks if a connection can be made. TODO: MAKE NICER AND NOT COPY PASTW
*/
try {
service = new WebService();
data = service.getServerData("1456458", 156, 1456398);
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
@Override
protected void onPostExecute(String data) {
text.setText(data);
}
}
Here is my logcat. The nullpointexception is because the ht.call(SOAP_ACTION, envelope); is never actually made.
Here is my logcat :
07-11 09:08:13.966: I/System.out(21059): Show error:
07-11 09:08:13.966: W/System.err(21059): unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@4265c7b0)
07-11 09:08:13.966: I/System.out(21059): --------------------
07-11 09:08:13.966: W/System.err(21059): java.lang.NullPointerException
07-11 09:08:13.991: W/System.err(21059): at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:534)
07-11 09:08:13.991: W/System.err(21059): at com.dayone.testing.resources.WebService.<init>(WebService.java:55)
07-11 09:08:13.991: W/System.err(21059): at com.webarchitects.activities.Splash_activity$ParseNFill.doInBackground(Splash_activity.java:61)
07-11 09:08:13.991: W/System.err(21059): at com.webarchitects.activities.Splash_activity$ParseNFill.doInBackground(Splash_activity.java:1)
07-11 09:08:13.996: W/System.err(21059): at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 09:08:13.996: W/System.err(21059): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 09:08:13.996: W/System.err(21059): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
07-11 09:08:13.996: W/System.err(21059): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 09:08:13.996: W/System.err(21059): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 09:08:14.001: W/System.err(21059): at java.lang.Thread.run(Thread.java:841)
Any help would be appreciated. I've looked at some other posts on SO with a similar problem. None seem to work.
The service didn't allow the IP adress from the internet connection I was using. A simple modification in SoapUI fixed it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.