我收到一条错误消息。我已经成功地在 Android 上捕捉到了它。我现在想要的是获取触发故障的异常的类。消息是这样的:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>Error retrieving user`s [..]</faultstring>
<detail>
<ns2:exception class="com.example.UserException_Exception" note="To disable this feature, set com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false" xmlns:ns2="http://jax-ws.dev.java.net/">
<message>EError retrieving user`s [..]</message>
<ns2:stackTrace>
<ns2:frame class="sun.reflect.DelegatingMethodAccessorImpl" file="DelegatingMethodAccessorImpl.java" line="43" method="invoke"/>
<ns2:frame class="java.lang.reflect.Method" file="Method.java" line="601" method="invoke"/>
<ns2:frame class="com.sun.xml.ws.api.server.InstanceResolver$1" file="InstanceResolver.java" line="246" method="invoke"/>
<ns2:frame class="com.sun.xml.ws.server.InvokerTube$2" file="InvokerTube.java" line="146" method="invoke"/>
<ns2:frame class="com.sun.xml.ws.server.sei.EndpointMethodHandler" file="EndpointMethodHandler.java" line="257" method="invoke"/>
<ns2:frame class="com.sun.xml.ws.server.sei.SEIInvokerTube" file="SEIInvokerTube.java" line="95" method="processRequest"/>
<ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="629" method="__doRun"/>
<ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="588" method="_doRun"/>
<ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="573" method="doRun"/>
<ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="470" method="runSync"/>
<ns2:frame class="com.sun.xml.ws.server.WSEndpointImpl$2" file="WSEndpointImpl.java" line="295" method="process"/>
<ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit" file="HttpAdapter.java" line="515" method="handle"/>
<ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter" file="HttpAdapter.java" line="285" method="handle"/>
<ns2:frame class="com.sun.xml.ws.transport.http.servlet.ServletAdapter" file="ServletAdapter.java" line="143" method="handle"/>
<ns2:frame class="com.sun.xml.ws.transport.http.servlet.WSServletDelegate" file="WSServletDelegate.java" line="155" method="doGet"/>
<ns2:frame class="java.lang.Thread" file="Thread.java" line="722" method="run"/>
</ns2:stackTrace>
</ns2:exception>
</detail>
</S:Fault>
</S:Body>
</S:Envelope>
我已经删除了跟踪的一部分,因为它不相关。
这是我用于交易的代码:
public static Long getCount(String id)
throws XmlPullParserException, IOException {
SoapObject request = new SoapObject(NAMESPACE, "getCount");
request.addProperty("id", id);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
System.setProperty("http.keepAlive", "false");
HttpTransportSE htse = new HttpTransportSE(URL);
htse.call(URL, soapEnvelope, null);
SoapPrimitive response = (SoapPrimitive) soapEnvelope.getResponse();
Long count = null;
try {
timestampCount = Long.parseLong(response.toString());
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (SoapFault e) {
e.printStackTrace();
}
return count;
}
那么,我该如何class="com.ltc.mid.pdf.UserCertificateException_Exception"
从 SoapFault 对象中获取信息呢?
只是要非常清楚:我正在寻找:
class
从<detail><exception>
元素获取属性的Java代码- SOAP 解析代码以
class
从<detail><exception>
元素中获取属性
谢谢!