如何从Android中的WebServices SOAP获取数据?

时间:2018-10-12 07:27:58

标签: android asp.net soap ksoap2 android-ksoap2

我尝试在Android中从this获取数据,但报错

org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT [{"BusinessPart...

我们有两个作为参数CP传递的值,并返回JSON数据。

这是我的Java代码:

public void getMyDataFromWS() {
        String SOAP_ACTION = "http://tempuri.org/GetCustomerDataforMobile";
        String METHOD_NAME = "GetCustomerDataforMobile";
        String NAMESPACE = "http://tempuri.org/";
        String URL = "http://arg-online.net/MobileGetService.asmx";

        try {
            SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
         // Request.addProperty("datatype", getCel);
            SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            soapEnvelope.dotNet = true;
            soapEnvelope.setOutputSoapObject(Request);

            HttpTransportSE transport = new HttpTransportSE(URL);

            transport.call(SOAP_ACTION, soapEnvelope);
            resultString = (SoapPrimitive) soapEnvelope.getResponse();

            Log.i(TAG, "Result Celsius: " + resultString);
        } catch (Exception ex) {
            Log.e(TAG, "Error: " + ex.getMessage());
        }
    }

SOAP ACTIONNAMESPACEMETHODURL here

    private static String SOAP_ACTION = "http://tempuri.org/GetCustomerDataforMobile";
    private static String NAMESPACE = "http://tempuri.org/";
    private static String METHOD_NAME = "GetCustomerDataforMobile";
    private static String URL = "http://arg-online.net/MobileGetService.asmx";
 // private static String PRAMS = "datatype";

0 个答案:

没有答案