Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServerSOAPFaultException and how to read it?

Tags:

jax-ws

I did a request and my program spit out

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)
    ....

I see via mitmproxy that the server sent back

<?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>

How do I read the first bit and get the details in the second bit? I don't have access to the server log, as in, the log on the server that hosts the web service.

I notice that the xml elements inside of soapenv:Fault don't have an xmlns. Is this how most SOAP errors are reported back? Is this a nonstandard way to do things? Am I going to have to rely completely on mitmproxy to debug these kinds of problems with web services?

like image 526
user988346 Avatar asked Sep 09 '14 17:09

user988346


People also ask

What is SOAPFaultException?

Class SOAPFaultException The SOAPFaultException exception represents a SOAP 1.1 or 1.2 fault. A SOAPFaultException wraps a SAAJ SOAPFault that manages the SOAP-specific representation of faults. The createFault method of javax. xml.

Which element can give information about service specific exceptions and their mapping to exception classes?

(1) Processing of service-specific exceptions The WSDL faults and Java exceptions are mapped according to the JAX-WS 2.2 specifications. The following figure shows an example of mapping between the WSDL faults and Java exception classes.


1 Answers

You must create a SOAPHandler to intercept the SOAP response/fault.

Use this tutorial to learn how to create an handler and register it to the service port:

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

Then remember to override the handleFault(SOAPMessageContext) method to intercept server faults.

like image 75
Valentino Avatar answered Jan 31 '23 17:01

Valentino