1

我在尝试连接到 web 服务时得到这个输出

org.xmlpull.v1.XmlPullParserException:意外类型(位置:END_DOCUMENT null@1:0 i[0.0] n java.io.InputStreamReader@6cf4fb80)

package com.rim.SoapRequest;

import net.rim.device.api.io.parser.soap.SOAPBody;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;

public class TSOAPRequest
{   

    public String fnSendRequest(String strServerUrl,String strServiceNamespace,String strSoapAction,String strMethodName,String strLablelText)
    {
        System.out.println("inside method !!!!!!!!");

        String strRequestData = "";

        SoapObject oSoapObject = new SoapObject(strServiceNamespace, strMethodName);
        SoapSerializationEnvelope oSoapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
//      oSoapObject.addProperty("GetCountryByCountryCode",strLablelText);
        oSoapObject.addProperty("CountryCode",strLablelText);
        oSoapEnvelope.bodyOut = oSoapObject;
        oSoapEnvelope.dotNet = true;
        oSoapEnvelope.encodingStyle = SoapSerializationEnvelope.XSD;
        oSoapEnvelope.enc = SoapSerializationEnvelope.ENC;

        System.out.println("soap Object !!!!!!________"+oSoapObject.toString());
        System.out.println("soap envelope !!!!++++++"+oSoapEnvelope.toString());

        HttpTransport httpTransport = new HttpTransport(strServerUrl);
        httpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");   
        httpTransport.debug = true; 
        System.out.println("---------BEFORE TRY BLOCK....");
        try
        {
            httpTransport.call(strSoapAction, oSoapEnvelope);
            System.out.println("INSIDE TRY BLOCK.......");
            strRequestData = (oSoapEnvelope.getResponse()).toString()+"inside try........";         
        }
        catch (Exception e)
        {
            e.printStackTrace();
            strRequestData = e.toString()+"Exception!!!!!!!!!!!!!!!!!!!!!";
        }       
        System.out.println("Request Data======" + strRequestData);
//      System.out.println("request dump ========"+httpTransport.requestDump);

//      strRequestData = httpTransport.requestDump+"=======DUMP=======";
        System.out.println("====dump report is=============="+httpTransport.requestDump);

        return strRequestData;
    }
}

在我的主屏幕上,我正在使用此方法调用将国家代码传递给方法。

oTsoapRequest.fnSendRequest("http://www.webservicex.net/country.asmx","http://www.webserviceX.NET","http://www.webservicex.net/country.asmx/GetCountryByCountryCode", "GetCountryByCountryCode",m_oZipCodeEditField.getText());

请帮助我摆脱这个例外。

4

0 回答 0