calling rest api after dataweaver component of mule - rest

I have an api which accepts a json payload.
I am calling this api just after the data weaver component of mule where I am building this json payload.

this just means that the API you are calling is answering with a 500 Internal Server error and the exception is throw becouse the http requester is configured to do so. If you don't want to throw the exception and just continue with the execution even when a 500 error is returned you can add the code 500 the the property "Success Status Code Validator":
<http:request config-ref="HTTP_Request_Configuration" path="/" method="GET">
<http:success-status-code-validator values="200, 201, 500"/>
</http:request>

Related

200 with Error body instead of 4xx response from AWS API Gateway

I'm using API Gateway to get access to S3 Bucket through REST API. Everything works as I would expect except when I want to fetch data from a wrong file/folder. Instead of 4xx code I get 200 with Error in the xml format:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>dir/dir2/dir3/file.ext</Key>
<RequestId>XXXX</RequestId>
<HostId>YYYY/J+ZZZZ/XXX/YYYY/ZZZ=</HostId>
</Error>
Is there any way to get non-200 response code? In the documentation there is an example with the NoSuchKey and info about "An appropriate 3xx, 4xx or 5xx HTTP status code"

HTTP status code for failed serialization

I have a GET /v2/developer/jhUxad8 endpoint which get developer from database and serialize it to json.
What http status code should I return when serialization fail?
https://www.codetinkerer.com/2015/12/04/choosing-an-http-status-code.html
What http status code should I return when serialization fail?
If I'm understanding you correctly, the server understands the request, and is trying to fulfill it, but because of a data problem is unable to do so.
500 Internal Server Error
The 500 (Internal Server Error) status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

How to prevent BizTalk 2013/R2 WCF-WebHttp Rest SendPort from Suspending on Http Status=400

I'm calling a vendor's REST service from a BizTalk orchestration using a WCF-WebHttp SendPort.
Even though I capture this System.Exception in an orchestration with a scope.exception, the SendPort remains suspended. Is there anyway to prevent the Susepend (WCF-CustomBehavior or Binding?) How do most BizTalk consumers of external REST services deal with this?
There are many different errors, some for security, some for data/configuration that might be returned with a 400 status, here is one example:
A message sent to adapter "WCF-WebHttp" on send port "spP44WebHttp"
with URI "https://test.abc.com/api/v3" is suspended. Error details:
System.Net.WebException: The remote server returned an unexpected
response: (400) Bad Request. {"httpStatusCode":400,"httpMessage":"Bad
Request","errorMessage":"Unable to handle shipment
request","errors":[{"severity":"ERROR","message":"Customer-X does not
support these accessorials:
AIRPU","source":"SYSTEM"}],"supportReferenceId":"e0117674-9f83-4b42-b861-2e9b9f636323"}
When you have a Scope/Exception around any other two-way WCF send, such as WCF-SQL, it doesn't leave the SendPort suspended when you catch the error, does it?
Related: BizTalk Catch Http Response Code
Update 1: I found this TechNet Post which seems to be on target:
https://social.technet.microsoft.com/wiki/contents/articles/33238.biztalk-server-2013-r2-handle-exceptions-from-rest-services-in-orchestration.aspx
However, it states they could not catch the errors. I can catch the 400 errors, but what I don't like is the Suspended SendPort.
Update 2: I'm trying a custom behavior, where I was going to reset the status code in the BeforeSendReply. But using the debugger, I see the following methods run: Validate(), AddBindingParameters(), ApplyClientBehaviors(), BeforeSendRequest(), BUT - I never see the BeforeSendReply() run. So if BizTalk adapter doesn't like the 400 status, does that stop it from getting back into the Custom Behavior?

WSO2 REST request box not working

I get the following error when I send a REST request with a request_box payload to WSO2 using WSO2 Tryit tool:
<axis2ns539:DataServiceFault xmlns:axis2ns539="http://ws.wso2.org/dataservice">
<axis2ns539:ds_code>UNKNOWN_ERROR</axis2ns539:ds_code>
This is what is echoed on the console:
[2017-12-08 20:01:22,939] [] ERROR - ServerWorker Error processing POST request for : /services/TestICM.HTTPEndpoint/request_box
org.apache.axis2.AxisFault: DS Fault Message: Input Message and request_box Axis Operation didn't match.
I tried also with Postman and got the same error.
Thank you very much

SoapUI endpoint error randomly

I don't understand something about SoapUI and his mockservice's behaviour.
I'm using the client of SoapUI (testcase) and a Java EE application with JAX-RPC.
My problem is :
when I'm trying to call any webservice, from my Java Client, or the testcase of SoapUI, the mockservice return a well message at first call, and the error below at the second call, with the same call or not.
But if I'm waiting, It works ...
So, I have enabled the option in SOAPui : "close HTTP connection after each SOAP request" and it works all the time...
So my question is :
"Is it a normal behaviour of the mockservice, and how to implement this with my java client ?"
Thank you all.
<soapenv:Fault>
<faultcode>Server</faultcode>
<faultstring>Missing operation for soapAction [] and body element [null] with SOAP Version [SOAP 1.1]</faultstring>
</soapenv:Fault>
OK,
I found a solution on the forum of SoapUI : http://www.soapui.org/forum/viewtopic.php?t=5648
It is when you have the settings flag "HTTP Settings/Logs wire content of all mock requests" set to true.
=> Uncheck the flag and it works fine!
Thanks a lot !
I had the same problem, using SoapUI 5.1.2 Pro.
After receiving first asynchronous response to the MockService, the MockService
stopped and could not receive any more responses for the request I sent.
The error message was:
Thu Jul 02 12:59:44 CEST 2015:ERROR:An error occurred [Missing operation for soapAction [XXXX] and body element [null] with SOAP Version [SOAP 1.1]], see error log for details
In SoapUI Settings:
File->Preferences->Http Settings: "Enable Mock HTTP log", uncheck box:
"Logs wire content of all mock requests".
Now I receive several asynchronous responses in a row, and give response back on them.
The same problem may happen when two mock services run with the same endpoint address (including port and path) on SoapUI.