org.xmlpull.v1.XmlPullParserException:期望值START_TAG {http://schemas.xmlsoap.org/soap/envelope/期望值、Xml

2023-09-05 23:54:13 作者:我们会发光@

您好我新的web服务,我在这里使用SOAP服务和运行在本地主机上,但得到这个错误这里是我的code:公共类Neteesh延伸活动{

 私有静态最后字符串的URL =HTTP://本地主机:7642 / Service1.asmx的;
私有静态最后弦乐NAMESPACE =htt​​p://tempuri.org/;
私有静态最后弦乐METHOD_NAME =HelloWorld的;

私有静态最后弦乐SOAP_ACTION =htt​​p://tempuri.org/HelloWorld;

公共无效的onCreate(包savedInstanceState){

super.onCreate(savedInstanceState);

TextView中的TextView =新的TextView(本);

的setContentView(TextView的);


新LongOperation()执行();
}


私有类LongOperation扩展的AsyncTask<字符串,太虚,字符串>
{

    @覆盖
    保护字符串doInBackground(字符串... HelloWorldResult)
    {
        // TODO自动生成方法存根

        字符串值=新的String();
        的System.out.println(内部getLognoperation方法...........);
        SoapObject请求=新SoapObject(命名空间METHOD_NAME);
        request.addProperty(BILLID,HelloWorldResult);

        SoapSerializationEnvelope的SoapEnvelope =新SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapEnvelope.dotNet = TRUE;
        soapEnvelope.setOutputSoapObject(要求);
        AndroidHttpTransport androidHttpTransport =新AndroidHttpTransport(URL);
        尝试
        {
            androidHttpTransport.call(SOAP_ACTION,的SoapEnvelope);
            SoapPrimitive resultString =(SoapPrimitive)soapEnvelope.getResponse();
            值= resultString.toString();
            的System.out.println(这getAccountsNames XMLS是:+值);
        }赶上(例外五){
            e.printStackTrace();
        }
        返回值;
    }
}
}
 

下面是我的logcat:

 十一月11日至一十六号:11:48.371:W / System.err的(1324):org.xmlpull.v1.XmlPullParserException:期望值START_TAG {HTTP://schemas.xmlsoap。组织/ SOAP /信封/}信封(位置:START_TAG< HTML> @ 2:7 java.io.InputStreamReader@4101fc30)
十一月11号至16日:11:48.371:W / System.err的(1324):在org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
十一月11号至16日:11:48.371:W / System.err的(1324):在org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
十一月11号至16日:11:48.381:W / System.err的(1324):在org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
十一月11号至16日:11:48.381:W / System.err的(1324):在org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
十一月11号至16日:11:48.381:W / System.err的(1324):在com.example.helloworldwebservice.Neteesh $ LongOperation.doInBackground(Neteesh.java:55)
十一月11号至16日:11:48.381:W / System.err的(1324):在com.example.helloworldwebservice.Neteesh $ LongOperation.doInBackground(Neteesh.java:1)
十一月11号至16日:11:48.381:W / System.err的(1324):在android.os.AsyncTask $ 2.call(AsyncTask.java:287)
十一月11号至16日:11:48.381:W / System.err的(1324):在java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:305)
十一月11号至16日:11:48.391:W / System.err的(1324):在java.util.concurrent.FutureTask.run(FutureTask.java:137)
十一月11号至16日:11:48.391:W / System.err的(1324):在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
十一月11号至16日:11:48.404:W / System.err的(1324):在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:569)
十一月11号至16日:11:48.404:W / System.err的(1324):在java.lang.Thread.run(Thread.java:856)
11月11号至16号:11:48.404:W / System.err的(1324):11月11号至16号:11:48.404 1324:1337的I /预期:START_TAG {http://schemas.xmlsoap.org/soap/envelope/ }信封(位置:START_TAG异常
 
Inception Network 各版本演进史

请编辑的问题,如果我的结构是错误的,如何解决它。我需要在web服务响应串其中之一。请帮助在此先感谢。

解决方案

由于对虚拟机的Andr​​oid模拟器中运行,因此你必须使用这种

 私有静态最后字符串的URL =htt​​p://10.0.2.2:7642/Service1.asmx;
 

而不是

 私有静态最后字符串的URL =HTTP://本地主机:7642 / Service1.asmx的;
 

然后

 保护字符串doInBackground(字符串... HelloWorldResult)
    {
      .....
      SoapObject请求=新SoapObject(命名空间METHOD_NAME);
      request.addProperty(BILLID,HelloWorldResult [0]);
      .....
  }
 

如您正试图...

Hello I new in webservice here i am using SOAP service and run on localhost but getting this error Here is my code: public class Neteesh extends Activity{

private static final String URL = "http://localhost:7642/Service1.asmx";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String METHOD_NAME = "HelloWorld";

private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

TextView textView = new TextView(this);

setContentView(textView);


new LongOperation().execute("");
}


private class LongOperation extends AsyncTask<String, Void, String> 
{

    @Override
    protected String doInBackground(String... HelloWorldResult) 
    {
        // TODO Auto-generated method stub

        String value = new String();
        System.out.println("Inside getLognoperation method...........");
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("billId", HelloWorldResult);

        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapEnvelope.dotNet=true;
        soapEnvelope.setOutputSoapObject(request);
        AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
        try
        {
            androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
            SoapPrimitive  resultString = (SoapPrimitive)soapEnvelope.getResponse();
            value = resultString.toString();
            System.out.println("This getAccountsNames xmls is : "+value);
        }   catch (Exception e) {
            e.printStackTrace ();
        }
        return value;
    }           
}   
}

Here is my logcat:

  11-16 11:11:48.371: W/System.err(1324): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <HTML>@2:7 in java.io.InputStreamReader@4101fc30) 
11-16 11:11:48.371: W/System.err(1324):     at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
11-16 11:11:48.371: W/System.err(1324):     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
11-16 11:11:48.381: W/System.err(1324):     at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
11-16 11:11:48.381: W/System.err(1324):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
11-16 11:11:48.381: W/System.err(1324):     at com.example.helloworldwebservice.Neteesh$LongOperation.doInBackground(Neteesh.java:55)
11-16 11:11:48.381: W/System.err(1324):     at com.example.helloworldwebservice.Neteesh$LongOperation.doInBackground(Neteesh.java:1)
11-16 11:11:48.381: W/System.err(1324):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
11-16 11:11:48.381: W/System.err(1324):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-16 11:11:48.391: W/System.err(1324):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-16 11:11:48.391: W/System.err(1324):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-16 11:11:48.404: W/System.err(1324):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-16 11:11:48.404: W/System.err(1324):     at java.lang.Thread.run(Thread.java:856)
11-16 11:11:48.404: W/System.err(1324): [ 11-16 11:11:48.404  1324: 1337 I/expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG Exception

Please edit question if my structure is wrong, How to solve it.I need string response which one in webservice. please help thanks in Advance..

解决方案

Since Android emulator run on Virtual Machine therefore you have to use this

private static final String URL = "http://10.0.2.2:7642/Service1.asmx";

instead of

private static final String URL = "http://localhost:7642/Service1.asmx";

And then

protected String doInBackground(String... HelloWorldResult) 
    {
      .....
      SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
      request.addProperty("billId", HelloWorldResult[0]);
      .....
  }

As you are trying now...