Status Code validator in Web service consumer in mule - web-services

I have three questions...
Just like HTTP requester in mule we have success code validator , i want same for web service consumer so that in response if i am getting status code 500 , i want to make it as success scenario ( means it is consider as success state).
Also if i want to increase response time out for web service consumer in mule how can i achieve it??
Suppose i am using scatter and gather and inside there i placed 3 separate flows , at the end i know scatter-gather will respond as an array than i have to write below logic in Mel expression..how i can do that please advice.
Logic:- if payload[1] && payload[1] && payload[2] == null that return "myvalue" else default payload
Can you please answer for all three question ..
Cheers,
b

If you're getting failure response, your exception flow will be triggered.
You can use catch inside choice strategy and catch a relevant exception and set payload inside catch accordingly.
You can proxy your consumer, or your can use deprecated HTTP connector connection configuration, see this.
https://docs.mulesoft.com/mule-user-guide/v/3.8/web-service-consumer#proxy-the-web-service-consumer
Looks like you want to use if-else condition, for one can use a Groovy script or Choice router.
Hope this helps.
Cheers!

Related

How to Log the message after request callback in web service outbound gateway

can you help me on how I can print the request message before completing the webservice call and after request-callback
<int:chain input-channel="tmsoapInChannel" output-channel="dest-channel">
<ws:header-enricher>
<ws:soap-action value="http://bnst.l/tm/TWebService/vrrrectieRequest"/>
</ws:header-enricher>
<ws:outbound-gateway uri="http://bnst.l/tm/TWebService" request-callback="WSAHeaderCallback"/>
</int:chain>
<int:logging-channel-adapter id="loggit" log-full-message="true" channel="justLog" />
I have implemented doWithMessage, and would like to see what message is going.
This would be better done via ClientInterceptor. However there is already built-in feature in the Spring WS project for you: https://docs.spring.io/spring-ws/docs/3.0.1.RELEASE/reference/#logging
Or borrow an idea from the PayloadLoggingInterceptor and implement similar logic in the ClientInterceptor.

catching Talend error in web Application

I have created a Talend job and deployed it as a Axis Web Service.
I am calling this Web Service from my Web Application.
My application and web service are deployed over Tomcat server.
For Valid Inputs:
Runs Perfectly.
For Invalid Inputs:
It throws Error/exceptions in Tomcat Server.
I want this Errors into my application. I didn't get any error related information in the Response sent by web service.
Error message on Tomcat Server
XML response of Web service
If I understand your question you are not so much asking how to fix this error, but how to get feedback about your error. There are several ways but here is a simple method.
Add a tLogCatcher to your job, and point its output to a tSendMail component. You can run the output thru a tMap do things like adding HTML formatting. You can also create a joblet with these two components and use the joblet in every job so you do not have to recreate it every time.
The diagram below shows a real simple case where I add tLogCatcher and tSendMail directly to the job. When there is an error it will send me an email with the details. You can use any of the columns in row11, I am only using job and message in my example.
This error : For input string "fabrik"
is generated by the tFileInputExcel component when encountering a non valid field (expected : integer ; given : string). You can't directly catch this error with the tFileInputExcel component (it's just printed out on the console).
However, you can use a tSchemaComplianceCheck component after your tFileInputExcelComponent : it will throw an error if a data is not valid for your schema. This component has a reject link to catch the error.
tFileInputExcel->tSchemaComplianceCheck->tMap->tMSOutput
If you use tLogCatcher component to catch the error then, at the end of the flow, you can add a tBufferOutput component. Keep the fields with the information you want for.
component configuration
The result will be like this (note that they are shown in the same order):
result

Continuing with Spring integration flow after SoapFault

Our application integration flow is defined as splitter -> ws gateway -> aggregator
The splitter splits request into a list of account numbers; so that for each account number a web service call is initiated and the responses from multiple web service calls are aggregated in the aggregator.The channel between splitter and ws gateway is defined with dispatcher "commonj WorkManagerTaskExecutor" so that each webservice call is initiated parallelly in different threads.
If at least some of the web service call responds properly; even if all other calls result in SoapFault; we need to handle the scenario by using the data from the successful responses with a warning message quoting the error message from the fault response.
The issue is that resolveFault() method of FaultMessageResolver defined in the ws gateway does not return anything and the control never reaches the aggregator if at least one of the parallel web service call fails. Is there any way to handle such a scenario.
You can inject SoapFaultMessageResolver to the <int-ws:outbound-gateway> (fault-message-resolver). This one has pretty simple code:
public void resolveFault(WebServiceMessage message) throws IOException {
SoapMessage soapMessage = (SoapMessage) message;
throw new SoapFaultClientException(soapMessage);
}
So, you failed WS invocation will end up with an Exception.
Add <int-ws:request-handler-advice-chain> to your <int-ws:outbound-gateway> and place there an instance of ExpressionEvaluatingRequestHandlerAdvice. specify its errorChannel and do some agnostic logic in that sub-flow and send some specific message to your aggregator. Don't forget to carry sequenceDetails headers with that messages.
Having all messages in group aggregator will be able to release is as normal one.
In the end you can analyze result List for errors and normal responses.

CICS web service requestor GET CONTAINER returns neither data nor error

I am developing a CICS web service requestor application to consume a distributed web service.
I used the web services assistant DFHWS2LS to transform the wsdl to copybooks successfully.
I have no problem issuing the PUT CONTAINER and INVOKE SERVICE api commands, but when I issue GET CONTAINER I am not receiving any containers or data. No response codes or error messages, but no data. Any ideas on how to debug this would be greatly appreciated.
Thanks,
I have never seen RESP be DFHRESP(NORMAL) and RESP2 be zero and have nothing returned by the server.
Verify the WSDL specifies that something is, in fact, returned by the web service.
Check the RESP and RESP2 values returned by the INVOKE SERVICE API. You don't mention these explicitly, and I presume the former is DFHRESP(NORMAL) and the latter is 0, but you might have coded NOHANDLE so I thought I'd ask.
Take a look in the TD queue mapped to CSSL (the default is the MSGUSR DD) for your CICS region. This is where CICS logs messages when it runs into an error while processing your SOAP request. Look for messages prefixed DFHPI.
Try pinging the endpoint from a TSO session running on the same LPAR as your CICS region, it's possible you're being stopped by a firewall.
In your comment you indicate the requestor is "seeing whitespace on the <SOAP-ENV:Envelope tag>". This isn't something under your direct control. The CICS "plumbing" code takes care of formatting the SOAP message. You may want to ask your CICS Systems Programmer to look for APARs related to the problem and install any associated PTFs.
You could verify the requestor's claim by using the transport handler in Appendix A.3 of this redbook. You'll have to modify your pipeline configuration file to execute the handler.

Timestamp of server from a web service call

Is there a way that I can retrieve the timestamp of a web service call? I'm trying to get the time of the server hosting the web service.
Easiest thing to do is to just log them in the server implementation of your service contract, you can use PostSharp to make some attributes to take of this aspect.
For instance, you can write a Trace attribute which simply logs a debug message when a method is invoke. Here's one I wrote a while back which tracks how long a method takes and log a warning message if it takes longer than a set threshold:
http://theburningmonk.com/2010/03/aop-method-execution-time-watcher-with-postsharp/
I came across some 'trace' attribute example before, if you want I can look for it for ya.