尝试连接到webservice GetCountryByCountryCode时获取XmlPullParserException
我在尝试连接到webservice时获得此输出 org.xmlpull.v1.XmlPullParserException: 意外类型(位置:结束文档) null@1:0 i[0.0]n java.io。InputStreamReader@6cf4fb80)尝试连接到webservice GetCountryByCountryCode时获取XmlPullParserException,xml,xmlpullparser,Xml,Xmlpullparser,我在尝试连接到webservice时获得此输出 org.xmlpull.v1.XmlPullParserException: 意外类型(位置:结束文档) null@1:0 i[0.0]n java.io。InputStreamReader@6cf4fb80) package com.rim.SoapRequest; 导入net.rim.device.api.io.parser.soap.SOAPBody; 导入org.ksoap2.SoapEnvelope; 导入org.ksoap2.seria
package com.rim.SoapRequest;
导入net.rim.device.api.io.parser.soap.SOAPBody;
导入org.ksoap2.SoapEnvelope;
导入org.ksoap2.serialization.SoapObject;
导入org.ksoap2.serialization.SoapSerializationEnvelope;
导入org.ksoap2.transport.HttpTransport;
公共类TSOAPRequest
{
公共字符串fnSendRequest(字符串strServerUrl、字符串strServiceNamespace、字符串strSoapAction、字符串strMethodName、字符串strLabelText)
{
System.out.println(“内部方法!!!!!!!”;
字符串strRequestData=“”;
SoapObject OSOAbObject=新的SoapObject(strServiceNamespace,strMethodName);
SoapSerializationEnvelope oSoapEnvelope=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
//osoabObject.addProperty(“GetCountryByCountryCode”,strLabelText);
osoabObject.addProperty(“国家代码”,strLabelText);
osoapenvelop.bodyOut=osoabObject;
osoapenvelop.dotNet=true;
oSoapEnvelope.encodingStyle=SoapSerializationEnvelope.XSD;
oSoapEnvelope.enc=SoapSerializationEnvelope.enc;
System.out.println(“soap对象!!!!!!!\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;
System.out.println(“soap信封!!!!+OSOApenvelop.toString());
HttpTransport HttpTransport=新的HttpTransport(strServerUrl);
httpTransport.setXmlVersionTag(“”);
httpTransport.debug=true;
System.out.println(“-----------在TRY块之前…”);
尝试
{
httpTransport.call(strSoapAction,osoapenvelop);
System.out.println(“内部试块……);
strRequestData=(oSoapEnvelope.getResponse()).toString()+“内部尝试…”;
}
捕获(例外e)
{
e、 printStackTrace();
strRequestData=e.toString()+“异常!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!”;
}
System.out.println(“请求数据===”+strRequestData);
//System.out.println(“请求转储====”+httpTransport.requestDump);
//strRequestData=httpTransport.requestDump+“=============DUMP==========”;
System.out.println(“===转储报告为=====”+httpTransport.requestDump);
返回strRequestData;
}
}
从我的主屏幕,我使用这个方法调用将国家代码传递给methods
oTsoapRequest.fnSendRequest(“http://www.webservicex.net/country.asmx","http://www.webserviceX.NET","http://www.webservicex.net/country.asmx/GetCountryByCountryCode“,“GetCountryByCountryCode”,m_oZipCodeEditField.getText())
请帮我摆脱这个例外
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;
}
}