尝试连接到Web服务GetCountryByCountryCode时获取XmlPullParserException

时间:2011-05-17 09:21:06

标签: xml xmlpullparser

我在尝试连接到webservice

时收到此输出
  

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

请帮助我摆脱这个例外。

0 个答案:

没有答案