Handle Soap Fault Using JaxBElement - web-services

Problem is
WSDL we have used for generating JAXBElement does not contain SOAP Faults where as the service can return Soap Faults in response.
Now when the service is returning faults and I use my JaxBElement, it throws an exception.
Is there a way I can handle (parse) these Soap Faults and get the error message or description from it.

Related

How to disable Verbose Error Messages of soap web services?

How to disable Verbose Error Messages of soap web services?
I have one web method with some para.
Example Req:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<GenerateTestRequest xmlns="http://tempuri.org/">
<sId>1#!aB</sId>
<mobileNum>12345678</mobileNum>
<srcType>1</srcType>
</GenerateTestRequest>
</Body>
</Envelope>
When an unexpected input was supplied into sId para instead of Int32, Then the web service returned an exception within the response content.
Example Res:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode>
<faultstring xml:lang="en-SG">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:sId. The InnerException message was 'There was an error deserializing the object of type System.Int32. The value '1#!aB' cannot be parsed as the type 'Int32'.'. Please see InnerException for more details.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
I don't want to display response content of exception message. Is there any way to turn off stack trace or exception details?
Is there any way to turn off stack trace or exception details?
Yes, by doing proper error handling for the SOAP web service.
A SOAP request can receive back a successful SOAP response or can receive back an unsuccessful response in the form of a SOAP Fault. People unfortunately focus on the successful cases only and let the framework they are using handle other problems.
Because SOAP is a protocol any exception on the server needs to be converted to a proper Fault response. This needs to be done by the developer by catching any exception and building appropriate Fault responses out of them, with only the needed data inside. For security reasons of course that data can't contain stacktraces or others sensitive information. But like I said, people often neglect to handle the error cases, and the framework can't build custom Faults, it can only build a SOAP fault with details from the exception that occurred, exposing it to the client.
You didn't tag this WCF but the schema namespace on the error code says windowscommunicationfoundation so I'll assume that's the web service framework. You can replace all exception messages with a generic error message by setting IncludeExceptionDetailInFaults to false (I think for your service it is set to true right now). See here for details: either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server
Or, you can do proper error handling and define and document the possible Faults a client can receive and convert any exception to one of those Faults. You can start reading here: Specifying and Handling Faults in Contracts and Services
If you are using any other web service framework or library, the idea is the same, the documentation to read will be different.

Web service axis fault: Error in deserializing body of request message

I am calling a webservice in java using basic auth. My code is deployed in an environment and in logs I can see this error as Axis Fault "Error in deserializing body of request message for operation 'GetUser'."
I am not able to debug it right now due to some environment issues so can anyone please give me some hint on when we get such type of errors?

Validating Spring Soap Webservice Response Serverside

I'd like to validate the response of a Soap Spring Webservice against XSD on server side.
The validation result should not lead to a soap fault.
For client compatiblity reason the webservice response contains
the validation error e.g. like
<SOAP-ENV:Body>
<ns:eltResponse>
<errCode>the error code</errorCode>
<errMessage>the error message</errMessage>
</ns:eltResponse>
</SOAP-ENV:Body>
I tried it with the PayloadValidatingInterceptor and a custom ValidationErrorHandler.
But this lead to soap faults. Is it possible to create a response like above mentioned, e.g. with an exception resolver?

How to customize SOAP Fault messages in Mule?

How do I send the fault code and fault string in such a way, that after my flow throws an exception, I get the desired error code and message in the SOAP error response (in FaultCode and FaultString fields).
I have a SOAP service that is being called in Mule. I am using a custom-exception-strategy for catching exceptions, and then setting spring-bean properties for code and message fields. The spring properties are being set, but my SOAP response is still the generic SOAP fault.
Also, I read that only MessagingExceptions can be handled in mule. So, how do I reproduce a messagingExcetion to test my code during development?

PeopleSoft - Cannot process SOAP fault messages after consuming web service

PT 8.50.15
We have a new integration with a third party system. They have provided the wsdl and I have used the consume web service wizard to consume it into PeopleSoft. All this does is give you the stub messages with a schema attached to each. I have written some peoplecode to send a test message out to the webservice. When the webservice returns a valid result, I have no problems. However, when the webservice returns a fault message, I get the following error:
Integration Gateway - HttpTargetConnector:ExternalApplicationException. Http status code HttpStatusCode returned : 500. (158,10623)
HttpTargetConnector:ExternalApplicationException. External System responded with an Error status. For Http Status Code explanation please check Http protocol Specifications.
I know the webservice is returning the fault message b/c I have tried the same thing in SOAPUI. Does anyone know why PeopleSoft throws up this error ONLY on the fault message?
In addition to the prior response, the 500 error you are seeing should be followed by any soap fault coming back with the response in the errorLog.html file on your gateway (or msgLog depending on the ig.log.level setting in your integrationgateway.properties file. Check the 'response' section, as well as the stack trace for additional information.
On the routing that you are using, click the 'User Exception' check box. Then you will not get the HTTP 500 error. Evaluate the response from the response message. If it's not zero, you will then be able to parse the SOAP fault and see what the returned faultstring is.
Get your Service operation corrected. I Had same issue, After i changed the SO in this code it started working
&msgRequest = CreateMessage(Operation.Operation_name, %IntBroker_Request);