Android异常org.xmlpull.v1.XmlPullParserException:预期:START_TAG

时间:2013-02-18 17:33:21

标签: android web-services exception android-ksoap2 xmlpullparser

我一直在尝试使用.NET Web服务(首先测试HelloWorld方法),使用的实际代码与其他Web服务相同。

public class MainActivity extends Activity {

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

    private static final String METHOD_NAME = "HelloWorld";

    private static final String NAMESPACE = "http://tempuri.org/";
    private static final String URL = "http://demo.digiparc.com/autocomplete.asmx";

    private static final String TAG = "MyActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView tv = (TextView)findViewById(R.id.textView1);


        SoapObject Request = new SoapObject(NAMESPACE,METHOD_NAME);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet=true;
        envelope.setOutputSoapObject(Request);

        HttpTransportSE aht = new HttpTransportSE(URL);

        try{

            aht.call(SOAP_ACTION,envelope);
            Log.i(TAG, "ind");
            SoapPrimitive resultString = (SoapPrimitive)envelope.getResponse();
            System.out.println("Result: "+resultString);
            tv.setText("Status : " + resultString);

        }
        catch(Exception e){
            Log.i(TAG, e.toString());
            e.printStackTrace();
        }

    }

我的第一个日志没有出现在logcat中,而对于第二个日志我收到了以下的重复:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@1:6 in java.io.InputStreamReader@45f9a950) 

我做错了吗?如果有人遇到同样的问题或有任何线索可以帮忙吗?我的Web服务详细信息是准确的。

1 个答案:

答案 0 :(得分:0)

它不是android或WebService的问题 app_html.offline中可能有一个APPCODE,它不允许它在线运行 转到C#中的解决方案资源管理器 右键单击并从项目中排除它。 :d