1

我正在调用PHP使用此代码创建的网络服务

SoapObject request = new SoapObject("getCustomerInfo",  "getCustomerInfo");
    request.addProperty("user_id", Info.userId);
    request.addProperty("authToken", Info.authToken);
    request.addProperty("request_id", Integer.toString(CUSTOMERACCOUNTINFO));

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE httpTransport = new HttpTransportSE(soapURL);
        httpTransport.debug=true;
        try {               
            httpTransport.call(soap, envelope); //Throwing Exception here
            System.out.println("dump state "+httpTransport.responseDump);
            client.success((Object) envelope.getResponse());
        }catch(NumberFormatException e){
            e.printStackTrace();
            System.out.println(" exception  num format");
            //client.error("NumberFormatException");
            client.error(e.getLocalizedMessage());
        }catch(XmlPullParserException xppe){
            System.out.println(" exception  pullparser");
            //client.error("XmlPullParserException");
            client.error(xppe.getLocalizedMessage());
        }catch(IOException ioe){
            System.out.println(" exception  io"+ ioe.toString());
            //client.error("IOException");
            client.error(ioe.getLocalizedMessage());
        }

并得到以下错误

12-31 10:52:03.024: W/System.err(2306): java.lang.NumberFormatException: Invalid int: ""
12-31 10:52:03.074: W/System.err(2306):     at java.lang.Integer.invalidInt(Integer.java:138)
12-31 10:52:03.104: W/System.err(2306):     at java.lang.Integer.parseInt(Integer.java:359)
12-31 10:52:03.124: W/System.err(2306):     at java.lang.Integer.parseInt(Integer.java:332)
12-31 10:52:03.134: W/System.err(2306):     at org.ksoap2.serialization.DM.readInstance(DM.java:39)
12-31 10:52:03.145: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.readInstance(SoapSerializationEnvelope.java:406)
12-31 10:52:03.155: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:364)
12-31 10:52:03.174: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:233)
12-31 10:52:03.184: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:366)
12-31 10:52:03.194: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.readVector(SoapSerializationEnvelope.java:287)
12-31 10:52:03.214: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.readInstance(SoapSerializationEnvelope.java:432)
12-31 10:52:03.224: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:364)
12-31 10:52:03.234: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:233)
12-31 10:52:03.254: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:366)
12-31 10:52:03.264: W/System.err(2306):     at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:121)
12-31 10:52:03.274: W/System.err(2306):     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
12-31 10:52:03.284: W/System.err(2306):     at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
12-31 10:52:03.294: W/System.err(2306):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
12-31 10:52:03.334: W/System.err(2306):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-31 10:52:03.344: W/System.err(2306):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
12-31 10:52:03.364: W/System.err(2306):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-31 10:52:03.374: W/System.err(2306):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-31 10:52:03.384: W/System.err(2306):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-31 10:52:03.394: W/System.err(2306):     at java.lang.Thread.run(Thread.java:856)
4

2 回答 2

1

此错误意味着您正在传递空字符串“”,而被调用的方法需要一个数字的字符串表示形式。或者更准确地说,您应该发送的消息必须在某处包含一个数字,而不是可以解释为数字的东西,您传递的是空字符串。

仔细检查您放入的参数的值request。我猜其中之一是导致异常的空字符串。

于 2012-12-31T13:45:22.600 回答
0

我认为在 CUSTOMERACCOUNTINFO 中的值为 null ...因此,请确保向 CUSTOMERACCOUNTINFO 添加一些值并将解析为 Integer ..

或者

做出这样的条件..

if(CUSTOMERACCOUNTINFO.length()>0)
{
   SoapObject request = new SoapObject("getCustomerInfo",  "getCustomerInfo");
   request.addProperty("user_id", Info.userId);
   request.addProperty("authToken", Info.authToken);
   request.addProperty("request_id", Integer.toString(CUSTOMERACCOUNTINFO));
}
于 2012-12-31T14:02:29.553 回答