简体   繁体   English

在Android设备上使用kso​​ap2时出现“意外类型错误”?

[英]“Unexpected type error” while using ksoap2 on Android device?

I am trying to use the ksoap2 library to pull a request from a working (professional) server. 我正在尝试使用kso​​ap2库从正在运行的(专业)服务器中提取请求。 After this testing this (flawlessly) in a java application but when I try to implement it in an Android application it messes up. 经过这个测试(完美无瑕)后,在Java应用程序中,但是当我尝试在Android应用程序中实现它时,它搞砸了。

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 : 这是我要在其中实现的Android代码:

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); nullpointexception是因为ht.call(SOAP_ACTION,信封); 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. 该服务不允许我正在使用的Internet连接提供IP地址。 A simple modification in SoapUI fixed it. SoapUI中的一个简单修改修复了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM