尝试连接到 Web 服务 GetCountryByCountryCode 时出现 XmlPullParserException
我在尝试连接到网络服务时收到此输出
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());
请帮助我摆脱这个异常。
i am getting this output when trying to connect to webservice
org.xmlpull.v1.XmlPullParserException:
unexpected type (position: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;
}
}
from my main screen i am passing country code to the methos using this method call.
oTsoapRequest.fnSendRequest("http://www.webservicex.net/country.asmx","http://www.webserviceX.NET","http://www.webservicex.net/country.asmx/GetCountryByCountryCode","GetCountryByCountryCode",m_oZipCodeEditField.getText());
please help me in getting out of this exception.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论