my iphone app is using soap web-services. I want to know how it would behave if the web-service returns a soap error?
I am using charles (HTTP Proxy) to catch the responses and modify the response before sending it to my iPhone app. What I'm trying to do is to modify a successful soap response, and turn it into a soap fault to see how my application behave.
QUESTION: How does a SOAP error response look like? (With restful all i had to do was to change the responseCode to 504, how can I achieve this with SOAP)?
How does a SOAP error response look like?
Here's an example of how a failed SOAP response might look like:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="en-US">The creator of this fault did not specify a Reason.</faultstring>
<detail>
<MyFault xmlns="http://schemas.datacontract.org/2004/07/ToDD" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<MyProperty>some value</MyProperty>
</MyFault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
As you can see there's a special <Fault> node in the body of the SOAP response which could contain any XML describing the SOAP fault. The custom XML should be in the <detail> child node.
Related
I am trying to use the Tsoap component within Talend to consume the API. I have tried the Soap UI Client (separate application) and was able to get the response.
However within the Tsoap component within the Soap Message, I have pasted the sample request and I get an error eery single time. Can anyone help!
" <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns=\"http://clients.mindbodyonline.com/api/0_5\">
<soapenv:Header/>
<soapenv:Body>
<GetSites>
<Request>
<SourceCredentials>
<SourceName>Test235</SourceName>
<Password>3IERKOFDNFEOFMKDFOEMFD=</Password>
<SiteIDs>
<int>-99</int>
</SiteIDs>
</SourceCredentials>
<XMLDetail>Full</XMLDetail>
<PageSize>0</PageSize>
<CurrentPageIndex>0</CurrentPageIndex>
</Request>
</GetSites>
</soapenv:Body>
</soapenv:Envelope>"
What am I doing wrong?? Can anyone help please.
Can you send the error what you are getting?
Try this if you haven't done (just a guess)
--> If you are using and HTTPS web service then make sure to setup the authentication( I used Trust serve with SLL and provided the keystore file path and password)
I'm using jboss fuse 6.1-final:
here is my simple route:
<route>
<from uri="cxf:bean:synchronousEndpoint"/>
<log message="Service invoked." />
<process ref="simpleProcessor"/>
</route>
and in the simpleProcessor I'm putting correct response(i.e corresponding JAXB object) to the context. But, it responds with fault:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Marshalling Error: java.lang.Object cannot be cast to org.w3c.dom.Element</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
here is stack trace:
Caused by: java.lang.ClassCastException: java.lang.Object cannot be cast to org.w3c.dom.Element
is there any hints or suggestions?
Bit hard to say without seeing some more code from the simpleProcessor. However it seems like you are using the wrong dataFormat parameter.
The cxf component has a dataFormat parameter which can be any of the following:
POJO: POJOs (Plain old Java objects) are the Java parameters to the
method being invoked on the target server. Both Protocol and Logical
JAX-WS handlers are supported.
PAYLOAD: PAYLOAD is the message payload (the contents of the
soap:body) after message configuration in the CXF endpoint is
applied. Only Protocol JAX-WS handler is supported. Logical JAX-WS
handler is not supported.
MESSAGE: MESSAGE is the raw message that is received from the
transport layer. It is not suppose to touch or change Stream, some of
the CXF interceptors will be removed if you are using this kind of
DataFormat so you can't see any soap headers after the camel-cxf
consumer and JAX-WS handler is not supported.
CXF_MESSAGE: New in Camel 2.8.2, CXF_MESSAGE allows for invoking the
full capabilities of CXF interceptors by converting the message from
the transport layer into a raw SOAP message
The default is POJO which means there is no XML being passed as a message Camel is passing objects. I suspect you might be trying to manipulate the response as XML and this is causing problems.
I ran into something similiar to this a while back where I was trying to convert the POJO into XML by trying to do a XPATH query on the XML when I was receiving a POJO.
I am invoking a WCF web-service (SOAP based) using Java client. The client is generated using apache cxf wsdl2java utility.
When the invoked service responds with a fault, I am not able to handle it using catch (javax.xml.ws.soap.SOAPFaultException), though when I invoke the service using SoapUI I see a valid soap response with fault envelope.
Code Snippet:
try{
iServiceInterface.postDataToSPOnline(USERNAME, PASSWORD,loExpense); }
catch(SOAPFaultException soapEx){
try {
//Not Invoked
System.out.println(“SOAPFaultException”);
} catch(Exception exp) {
//Not Invoked
System.out.println(“Exception”);
} finally {
//Control reaches here post calling the service
System.out.println(“Finally”);
}
SoapUI response on invoking the service when fault is returned in response:
<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:InternalServiceFault</faultcode>
<faultstring xml:lang="en-US">Object reference not set to an instance of an object.</faultstring>
<detail>
<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<InnerException i:nil="true"/>
<Message>Object reference not set to an instance of an object.</Message>
<StackTrace>at
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
<Type>System.NullReferenceException</Type>
</ExceptionDetail>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Would appreciate your suggestions in handling this scenario.
Thanks,
Wajid
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<WSResponseHeader xmlns="http://cio.xxx.com/commonheader/v3" xmlns:ns2="http://newhorizon.xxx.com/ABCservice">
<WSCorrelationId>?</WSCorrelationId>
</WSResponseHeader>
</S:Header>
<S:Body>
<ns2:newOrderResponse xmlns="http://cio.XXX.com/commonheader/v3" xmlns:ns2="http://newhorizon.XXXX.com/ABCservice">
<ns2:ABCOrderResponse>
<ns2:headerStatus>ERROR</ns2:headerStatus>
<ns2:lineResponse>
<ns2:sourceSystemRefLineNum>1</ns2:sourceSystemRefLineNum>
<ns2:lineStatus>ERROR</ns2:lineStatus>
<ns2:lineError>
<ns2:errorCode>122</ns2:errorCode>
<ns2:errorMessage>Billing Category Code is required. </ns2:errorMessage>
</ns2:lineError>
</ns2:lineResponse>
</ns2:ABCOrderResponse>
</ns2:newOrderResponse>
</S:Body>
</S:Envelope>
I have a soap web service code in ColdFusion which invokes an external web service and my app will pass some rows to it. The above is the format of response that the application will send back. There can be multiple <ns2:lineResponse> type blocks. Some blocks will have error tags, some may have success tags.
How can I iterate through this response to extract details from error tag blocks only?
When I try to make loops, it is counting <ns2:headerStatus>ERROR</ns2:headerStatus> also as child node.
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?