org.xmlpull.v1.XmlPullParserException:意外类型(位置:END_DOCUMENT null@1:0 in java.io.InputStreamReader@c599f9fd)

Ani*_*mar 5 soap web-services blackberry

我是黑莓的新手,我只是想调用一个在 SAP CRM 上执行一些操作的 Web 服务,但我收到此异常: org.xmlpull.v1.XmlPullParserException:意外类型(位置:END_DOCUMENT null@1:0 in java .io.InputStreamReader@c599f9fd)

这是代码...

   SoapObject rpc = new SoapObject(serviceNamespace,"zws_incoming_email");

   rpc.addProperty("username","sreenu");

   rpc.addProperty("Password","ravi");

   SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
   envelope.bodyOut = rpc;

   envelope.dotNet = true;
   envelope.encodingStyle = SoapSerializationEnvelope.ENC;
   envelope.env = "http://schemas.xmlsoap.org/soap/envelope/";
   HttpTransport ht = new HttpTransport(serviceUrl);
 //s  ht.requestDump=msg;
   ht.debug = true;
   String request="";
   ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"  ); 
   String response=ht.responseDump;
        try
            {  
            System.out.print("2222222");
            ht.call(soapAction,envelope);
            String result = (envelope.getResponse()).toString();
            System.out.println("in try block"+result);
            System.out.println("Request"+request);
            System.out.println("Response"+response);
            System.out.println("Result......"+result);  
             }        
        catch(org.xmlpull.v1.XmlPullParserException ex2){
            String msg2 = ex2.toString();
              request=ht.requestDump;
               response=ht.responseDump;
             System.out.println("Exception...... "+msg2);
              System.out.println("request...... "+request);
              System.out.println("response...... "+response);
                 }

          catch(Exception ex)
           {
        String msg1 = ex.toString();
           System.out.println(".......... catch block"+msg1);
          }     
}
Run Code Online (Sandbox Code Playgroud)

ht.call() 方法后引发异常,请帮助我............

小智 0

我遇到了同样的问题,出现END_DOCUMENT错误,但我解决了。

主要问题在于模拟器中的代理设置。

当我尝试从 Blackberry 模拟器访问 Web 服务时,无论我做什么,我总是收到此错误。经过2天的“研究”,我解决了这个问题。请执行下列操作:

  1. 确保您已预先验证 KSOAP2 jar。如果没有,请执行以下步骤:http://www.craigagreen.com/index.php?/Blog/blackberry-and-net-webservice-tutorial-part-1.html
  2. 确保您已安装 MDS。如果没有,请转至https://swdownloads.blackberry.com/Downloads/entry.do?code=996009F2374006606F4C0B0FDA878AF1下载并安装 Blackberry 电子邮件和 MDS 服务模拟器包。
  3. 转到C:\Program Files (x86)\Research In Motion\BlackBerry Email and MDS Services Simulators 4.1.2\MDS\config(这是安装步骤 2 中的包的位置)。打开rimpublic.property文件。在下面[HTTP HANDLER]添加以下行:

    application.handler.http.proxyEnabled = true
    application.handler.http.proxyHost=YOUR_PROXY_IP
    application.handler.http.proxyPort=PROXY_PORT
    application.handler.http.proxyUser=PROXY_USER (with domain if required)
    application.handler.http.proxyPass=PASSWORD
    application.handler.http.proxyAutoConfig = false`
    
    Run Code Online (Sandbox Code Playgroud)
  4. 现在是非常重要且有趣的一步。我在 Eclipse 中的第一个 Blackberry 模拟器没有采取代理设置。而且我没有被提示输入代理设置。所以我在模拟器中无法访问互联网(这是主要问题)。然后我尝试安装其他模拟器。(在我的例子中 Blackberry Pearl 9100 版本 5.0.0.884 您可以在这里下载:http://us.blackberry.com/developers/resources/simulators.jsp)。当我尝试通过网络浏览器连接到互联网时,系统提示我输入用户名、域和密码。繁荣,我有互联网连接。问题解决了。我的应用程序运行良好。