I 'd like to know how to handle and to design the flow to consume three sequential calls type PUT with muleSoft. I 'll enter from main flow by VM Connector and I insert HTTP connector to consume PUT with data in payload. To handle the errors if the first, second and third request PUT response unsuccessful (example status code 400),Where can I handle it? Must I another flow? how can I do?
Above I have already done Flow call Request Put
Assuming that you will have the same request for all 3 outbound call that you are calling sequentially , what you can do is
just after the VM inbound save your request in a variable, then call
the first HTTP call as you are doing.
After the HTTP outbound call for first service, set the payload with your variable and call your second service using another HTTP
Same steps as step 2 you follow for your 3rd call
Regarding exception, you can check here for handling https://developer.mulesoft.com/docs/display/current/Catch+Exception+Strategy
And to control HTTP status code, if you are using Mule 3.6+ version, you can easily control HTTP status code with your http:request component as given here with Status Code Validator:- https://developer.mulesoft.com/docs/display/current/HTTP+Request+Connector
Related
We are currently using the dispatcher module in kamailio to get the availability of gateways via the dispatch list.
It uses a health check based on if it can talk to the gateway via SIP by default. However, I would like to know if we can make the check better by also checking via a http health check?
The reason for this is because when the gateway on the other end is in courtesy shutdown the dispatcher still sends calls to it even though we would like the box to shutdown. This leads to the gateway always staying up.
Alternatively there might be a better way of handling this by sending a message back in the sip packet to kamailio.
I have read through the documentation but I can't seem to find anything like what I am looking for.
The Dispatcher module has Event Routes that can be called when a SIP destination goes down / up. There are no Event Routes for HTTP as it's not constantly queried in it's own thread by Dispatcher.
Alternatively there might be a better way of handling this by sending a message back in the sip packet to kamailio.
You can however set the dispatcher state using the ds_mark_dst([state]) function. Through this you could add a custom header in any SIP message from your box that's shutting down to tell Kamailio's Dispatcher to not use it as a destination in the future.
If we added an imaginary header called "X-SetState" with the value "Shutdown" and send it from our box that's shutting down to Kamailio in a SIP message we could pick it up with something like this:
is_present_hf("X-SetState"){ //If custom header is present
xlog("Received state change request ($ru) with value $hdr(X-SetState)")
if($hdr(X-SetState) == "Shutdown"){ //If value of header is Shutdown
ds_mark_dst("dp"); //Mark destatination as disabled & probing
}
}
Obviously you'd need to add your own code to select the right dispatcher to mark inactive and ensure that the X-SetState header was only parsed if it came from your internal boxes you want to mark as down but you get the idea.
However, I would like to know if we can make the check better by also checking via a http health check?
Dispatcher at the moment has no support for monitoring HTTP state, but adding it wouldn't be that difficult to implement, if you're handy at C you could add support or add a feature request.
Alternatively you could write an script to monitor HTTP status of each device and the using Kamcmd / Kamctl set the dispatcher group to down if it doesn't get a response.
Is it possible to intercept the request going through Charles and immediately return 500 error code without sending this request to the server?
Can't find any information on this. All resources suggest to wait for the response and then change HTTP response code to 500.
I assume you have already tried adding a rewrite rule to make the request to be returned with the 500 status. Have you tried combining this with a map local, to an empty file on your disk, for instance? It may work.
If this doesn't work too, I think I would do a Map Remote to another path on my localhost (for instance: http://localhost:8081/exected-response-500) and make that URL to return the 500 status error (in my case I would use a basic Spring Boot app to achieve this).
Is there any way to send out two httpresponses for a single httprequest in play framework.
As as per the RFC of http we can send out two messages for a single request although as I am really novice in Play framework, can this be done.
If not what might be the best approach to solve this scenario
Little note: This solution does not use chucnked, and use the xmlHttp request instead. And also, there is no magic: two requests and two responses. So if you have a constraint on the front-end framework; this might not be the best answer.
You also commented this:
not at once , need to send ok response as an handshake then followed with the actual response which is calculated after extensive mathematical operations
So, if you don't have any constraints on your front-end framework; I would simply use the advantage of Javascript to send the second request, in the background, and get the second response back. Here how I would do it:
Update my views file to take a parameter, handShake of type Boolean. So when to user goes the page for the first time, the controller method response is false. After the first hand shake, the controller method, sends true with Ok response to the user. Only then when it is true the app itself sends another request, as an xmlhttp request via the javascript code, to the controller, and then the corresponding controller method, calculates what it needs to calculate and sends the response back.
This way you send two requests, and get back two responses, but you don't reload the whole page for the second request.
In Soap UI REST project, what is the significance or use of adding representations under a method(say POST). I see three types of representations - REQUEST, RESPONSE and FAULT
I think that it's only informative, it shows the different kind of interactions you send/received from the REST service.
You can add new ones manually but I think that this has nonsense because when you invoke the service if your receive a correct response a new entry of kind RESPONSE is added automatically specifying the media-type, http status code and name received from the service.
If instead you receive an error http status like 404, then a new entry of kind FAULT is added specifying also the media-type, http status and name for the fault.
The REQUEST type entry it's only added when you send a REST Request of POST type , if the REST Request is a GET then the entry is not added.
Hope it helps,
I am using PostMan as a REST client to test this API method Cisco ACL Analysis API. specifically POST /acl/trace or getAClTracksStd (first go to Policy Analysis)
Here is my PostMan HTTP test call
Does anyone who is familiar with PostMan understand why I am getting this "Request method 'GET' is not supported" error from the server? I am making a POST HTTP request, not GET.(Selected from Drop down menu) It make more sense for me to get a input invalid parameter error or something.
Just to show that the endpoint url works, heres a HTTP test request that works
(same link, host->host API -> GET /host/{startIndex}/{recordsToReturn}
There's two issues that I'm seeing with your REST call. First, the error you're seeing is because the call needs to be preceded by "https://". Second, remove the interface IDs parameter and values. You should get a response with data after making these changes.
Your json looks erronuous (comma after the destIp) - and the server probably always responds with a default confusing error message in this case. (Postman is very well tested and it sends POST).