How to disable Verbose Error Messages of soap web services? - 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.

Related

Xamarin.iOS with SOAP 1.2

I need to use a SOAP 1.2 web service in Xamarin.iOS but I can't seem to find a way how to make it work. I added a ServiceRefence to my project, I can even send messages, but every time I send a message I get the following exception:
System.Net.WebException: There was an error processing web request: Status code 415(UnsupportedMediaType): Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.
I read that this message indicates, that I'm using a wrong binding. I should use WsHttpBinding instead of BasicHttpBinding, but I can't find WsHttpBinding in Mono.
Any idea how can I make it work?

Handle Soap Fault Using JaxBElement

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.

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

Reporting an error from a POST Web Service

I'm developing a web service (in asp.net) and I would like to have each web method report to whoever called it when an internal error occurs - for example when input validation has failed.
When I expose my web service with SOAP such errors can be reported by raising a SoapException. But what if I expose my web service with plain POST (aka Http-Post)? Other than returning a 500 Error HTTP status code, is there a standard for reporting errors or raising exceptions in this case?
Change the response object to contain a status filed, and error message (or only error message, and check at the receiver if empty), and set it properly instead of throwing an exception.
I've always just returned the 500 status code, along with a textual description of the error. Just make sure it's documented so the client can handle it correctly.