android SoapSerializationEnvelope KSoap问题

问题描述

我有一个C#Web服务,正在返回JSON响应。在IE上,我的示例返回值是

{“ 102”:{“ customerName”:“ asfd”,“ address”:“”,“ orderList”:{“ 3”:{“ 8”:1,“ 6”:1}}},“ 103“:{” customerName“:” hose“,” address“:” Road Jamica Queens“,” orderList“:{” 4“:{” 15“:1}}}}

但是,当从android访问相同的Web服务时,却遇到了Java异常。

意外的令牌(位置:TEXT {“ 102”:{“ custome ... @ 1:194 in java.io.InputStreamReader@29041cbd)

responsedump还在末尾添加了XML,从而导致了问题。

 responseDump:{"102":{"customerName":"asfd","address":"","orderList":{"3":{"8":1,"6":1}}},"103":{"customerName":"hose","address":"Road Jamica Queens","orderList":{"4":{"15":1}}}}<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><getInvoicesResponse xmlns="http://tempuri.org/" /></soap:Body></soap:Envelope>

public class webServiecHandler  extends AsyncTask<String,Void,String> {

    /**
     * Variable Decleration................
     *
     */
    String namespace = "http://tempuri.org/";
    private String url = "http://sample/WebService1.asmx";

    String SOAP_ACTION;
    SoapObject request = null,objMessages = null;
    SoapSerializationEnvelope envelope;




    /**
     * Set Envelope
     */
    protected void SetEnvelope() {

        try {

            // Creating SOAP envelope
            envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

            //You can comment that line if your web service is not .NET one.
            envelope.dotNet = true;


            envelope.setoutputSoapObject(request);


        } catch (Exception e) {
            System.out.println("Soap Exception---->>>" + e.toString());
        }
    }


    public String doInBackground(String ... params)
    {

        try {
            SOAP_ACTION = namespace + "getInvoices";

            //Adding values to request object
            request = new SoapObject(namespace,"getInvoices");
            HttpTransportSE androidHttpTransport = new HttpTransportSE(url);


            SetEnvelope();

            try {

                //SOAP calling webservice

                androidHttpTransport.call(SOAP_ACTION,envelope);

                SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
               String result = "";
                return result;

            } catch (Exception e) {
                Log.d("returnedClass",e.getMessage());
                return e.toString();
            }
        } catch (Exception e) {
            // Todo: handle exception
            return e.toString();
        }


    }


    /************************************/
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)