2

I am consuming a .net web service using ksoap2 but getting the following Exception:

org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@412caa08)`

My request dump is the same as I needed but I'm not getting response dump and it has come as null. I am trying, but getting the same error.Please some one help me. My code is given below-

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);
    }

  }
}
4

0 回答 0