如何在SoapFault中获取faultstring?

时间:2013-04-22 11:03:27

标签: android soap soapfault

我在android中调用Soap API,我得到以下错误,

SoapFault - faultcode: '2' faultstring: 'Access denied.' faultactor: 'null' detail: null
at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:141)
at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:214)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:96)
at com.magentodemo.customer.MagentoCustomer$GetCustomerDetailsTask.doInBackground(MagentoCustomer.java:714)
at com.magentodemo.customer.MagentoCustomer$GetCustomerDetailsTask.doInBackground(MagentoCustomer.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)

我想从此SoapFault中检索拒绝访问的消息,

我该如何获得该消息?

2 个答案:

答案 0 :(得分:2)

我得到了我的问题的解决方案,

我有以下代码

private class Login extends AsyncTask<Void, Integer, String> {

    @Override
    protected void onPreExecute() {

    }

    @Override
    protected void onPostExecute(String result) {

    }

    @Override
    protected String doInBackground(Void... params) {
        try {

            // Soap Call

        } catch (SoapFault fault) {
            Log.v("TAG", "soapfault = "+fault.getMessage());

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

我只是为SoapFault添加了Catch块,我得到了faulttring,就是这样。

答案 1 :(得分:1)

您是否尝试过使用SoapFault类API的方法来获取您的要求?请从下面的链接中查看相应的内容: http://docs.oracle.com/javaee/5/api/javax/xml/soap/SOAPFault.html#getFaultString()