2

ksoap2 を使用して .net Web サービスを使用していますが、次の例外が発生します。

org.xmlpull.v1.XmlPullParserException: 予期しないタイプ (position:END_DOCUMENT null@1:1 in java.io.InputStreamReader@412caa08)`

要求ダンプは必要なものと同じですが、応答ダンプが得られず、null になっています。試していますが、同じエラーが発生します。誰か助けてください。私のコードは以下のとおりです-

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