获取pullParserExcepstion的Android ksoap web服务问题

时间:2012-12-05 18:31:58

标签: java android soap wsdl ksoap

我正在使用kso​​ap2使用.net网络服务,但收到以下例外:

  

org.xmlpull.v1.XmlPullParserException:意外类型(位置:END_DOCUMENT null @ 1:1 in java.io.InputStreamReader@412caa08)`

我的请求转储与我需要的相同,但我没有得到响应转储,它已经为空。我正在尝试,但得到同样的错误。请一些人帮助我。我的代码如下 -

public class Login extends Activity {

private final String NAMESPACE = "http://xyz.public/imageupload/1.0/";
private final String URL = "http://public.service.xyz.com/ImageUpload.svc";
private final String SOAP_ACTION = "http://xyz.public/imageupload/1.0/Services/Authentication";
private final String METHOD_NAME = "Authentication";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                .permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    SoapSerializationEnvelope envelope = null;
    SoapObject request = null;
    HttpTransportSE httpTransportSE = null;
    try {
        request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("userId", "admin");
        request.addProperty("password", "password");

        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
        envelope.dotNet = true;
        envelope.encodingStyle = SoapSerializationEnvelope.ENC;

        /**
         * below code for custom header
         */
        Element actionElement = new Element().createElement(null,
                "d:Action");
        actionElement.setAttribute("", "s:mustUnderstand", "1");
        actionElement.addChild(Node.TEXT, SOAP_ACTION);

        Element toElement = new Element().createElement(null, "d:To");
        toElement.setAttribute("", "s:mustUnderstand", "1");
        toElement.addChild(Node.TEXT, URL);

        Element[] header = { actionElement,toElement };
        envelope.headerOut = header;
        envelope.env = "http://schemas.xmlsoap.org/soap/envelope/";
        /**
         * Custom header part end
         */
        envelope.setOutputSoapObject(request);

        httpTransportSE = new HttpTransportSE(URL); 
        httpTransportSE.debug = true;
        httpTransportSE.call(SOAP_ACTION, envelope);
        SoapObject result = (SoapObject) envelope.getResponse();
        // To get the data.
        String textResult = result.toString();
        Log.i("textResult", textResult);

    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        Log.e("Exception:", e.toString());

    }

    finally {
        Log.i(getClass().getSimpleName(), "requestDump : "+ httpTransportSE.requestDump);
        Log.i(getClass().getSimpleName(), "responseDump : "+ httpTransportSE.responseDump);
    }

  }
}

0 个答案:

没有答案