【问题标题】:ServerSOAPFaultException and how to read it?ServerSOAPFaultException 以及如何读取它?
【发布时间】:2014-11-03 05:14:42
【问题描述】:

我做了一个请求,我的程序吐了

WARNING: Input Action on WSDL operation Search and @Action on its associated Web Method search did not match and will cause problems in dispatching the requests
Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Client error Please see the server log to find more detail regarding exact cause of the failure.
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:124)
    at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238)
    ....

我通过 mitmproxy 看到服务器发回了

<?xml version='1.0' encoding='utf-8'?>
<!--pageview_candidate-->
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <soapenv:Fault>
      <faultcode>soapenv:Client</faultcode>
      <faultstring>Client error</faultstring>
      <faultactor>http://api.bing.net:80/soap.asmx</faultactor>
      <detail>
        <Errors xmlns="http://schemas.microsoft.com/LiveSearch/2008/03/Search">
          <Error>
            <Code>1001</Code>
            <Message>Required parameter is missing.</Message>
            <HelpUrl>http://msdn.microsoft.com/en-us/library/dd251042.aspx</HelpUrl>
            <Parameter>SearchRequest.AppId</Parameter>
          </Error>
          <Error>
            <Code>1001</Code>
            <Message>Required parameter is missing.</Message>
            <HelpUrl>http://msdn.microsoft.com/en-us/library/dd251042.aspx</HelpUrl>
            <Parameter>SearchRequest.Sources</Parameter>
          </Error>
        </Errors>
      </detail>
    </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>

如何读取第一位并获取第二位的详细信息?我无权访问服务器日志,例如托管 Web 服务的服务器上的日志。

我注意到soapenv:Fault 中的xml 元素没有xmlns。这是大多数 SOAP 错误报告的方式吗?这是一种非标准的做事方式吗?我是否将不得不完全依赖 mitmproxy 来调试此类 Web 服务问题?

【问题讨论】:

    标签: jax-ws


    【解决方案1】:

    您必须创建一个 SOAPHandler 来拦截 SOAP 响应/故障。

    使用本教程了解如何创建处理程序并将其注册到服务端口:

    http://www.mkyong.com/webservices/jax-ws/jax-ws-soap-handler-in-client-side/

    然后记得重写handleFault(SOAPMessageContext)方法来拦截服务器故障。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多