XmlPullParser 异常

发布于 2024-10-27 07:23:13 字数 2324 浏览 0 评论 0原文

我无法解决此错误:

org.xmlpull.v1.XmlPullParserException:预期:START_TAG {http://www. w3.org/2001/12/soap-envelope}信封(位置:START_TAG @1:6 in java.io.InputStreamReader@43e524c8)

我有一个访问 .NET Web 服务的 Android 应用程序。它传递一个 int 并接收一个 int 作为响应。我正在使用 ksoap2。 我还向清单文件添加了权限,而且还包含了所有 jar 文件。但是,我陷入困境,无法查看我正在发送的 SOAP 请求。

我的代码是:

public class FirstAppUI extends Activity{

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

    private static final String URL = 
        "http://nautilussoft.biz.whbus12.onlyfordemo.com/staging/litigation/demowebservice.asmx";

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

private static final String METHOD_NAME = "GetNumber";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView tv= (TextView)findViewById(R.id.TextView01);
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("maxbelow", "123");
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 

        envelope.dotNet= true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {
            //Toast.makeText(getBaseContext(), "received object", Toast.LENGTH_SHORT).show();
            androidHttpTransport.call(SOAP_ACTION, envelope);

             Object resultsRequestSOAP = (SoapObject)envelope.getResponse();
            //SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
            //Toast.makeText(getBaseContext(), "received object", Toast.LENGTH_SHORT).show();
            tv.setText("Received :" + resultsRequestSOAP.toString());
        } catch (MalformedURLException e) {
            e.printStackTrace();
            Log.e("APP", "MalformedURLException while sending\n" + e.getMessage());
            tv.setText("Malformedexception"+e);
        }
        catch(Exception e1)
        {
            e1.printStackTrace();
            tv.setText("exception"+e1);

        }

        }

}

提前致谢。

I'm not able to resolve this error:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2001/12/soap-envelope}Envelope (position:START_TAG @1:6 in java.io.InputStreamReader@43e524c8)

I have an Android app which accesses a .NET web service. It passes an int and receives an int as a response. I'm using ksoap2.
I added the permissions to the manifest file also and moreover I included all jar files. However, I'm stuck and I am unable to view which SOAP request I am sending.

My code is:

public class FirstAppUI extends Activity{

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

    private static final String URL = 
        "http://nautilussoft.biz.whbus12.onlyfordemo.com/staging/litigation/demowebservice.asmx";

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

private static final String METHOD_NAME = "GetNumber";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView tv= (TextView)findViewById(R.id.TextView01);
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("maxbelow", "123");
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 

        envelope.dotNet= true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {
            //Toast.makeText(getBaseContext(), "received object", Toast.LENGTH_SHORT).show();
            androidHttpTransport.call(SOAP_ACTION, envelope);

             Object resultsRequestSOAP = (SoapObject)envelope.getResponse();
            //SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
            //Toast.makeText(getBaseContext(), "received object", Toast.LENGTH_SHORT).show();
            tv.setText("Received :" + resultsRequestSOAP.toString());
        } catch (MalformedURLException e) {
            e.printStackTrace();
            Log.e("APP", "MalformedURLException while sending\n" + e.getMessage());
            tv.setText("Malformedexception"+e);
        }
        catch(Exception e1)
        {
            e1.printStackTrace();
            tv.setText("exception"+e1);

        }

        }

}

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゞ花落谁相伴 2024-11-03 07:23:13

在 IIS 中或通过 IIS 管理器授予对 webserivce 文件夹的权限。

Give permission to your webserivce folder in IIS or through IIS manager.

梦年海沫深 2024-11-03 07:23:13

请检查您正在使用的 weburl...它区分大小写...即使它在网络浏览器中工作正常,您也应该在代码中使用确切的名称...

please check the weburl you are using.. its case sensitive... even though its working fine in a web browser, you should use the exact name in your code...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文