How can I access Deserialize request body object in a Filter? - servlet-filters

We have a dropwizard micro-services, and we need to access POST request body for one of end point in a filter.
How can I access Deserialize request body object in a Filter?

Related

Fetch Request body in webclient when using Mono zip to identify which request fails

I am using webclient to call 3 different external APIs in parallel using Mono zip. Now, if any error occurs in any of the API call, I have handled it through a common exception handler using ExchangeFilterFunction. Now, I want to know which particular request fails(out of 3 external API calls) ? Is there any way I can identify that? I also want to append the 'input request body' with the exception response I got from the API call. Can I fetch the request body for which the API Fails (in filter itself)?
In the ExchangeFilterFunction you have access to the request. You could "decorate" your request with some identifier and then use it to resolve the client.
You could add some request header to identify the client.
To keep it internal, you could use request attributes of the WebClient and then read it from the request object
webClient.get()
.uri("...")
.attributes((attributes) -> attributes.put("internal_client_id", clientId))

Can I pass in an object into a SOAP API request

The object required contains a string. When I pass in the string I receive an error. Is there a way to build up an object using XML in a SOAP request. According to my knowledge, SOAP requests have to be in XML format.

WSO2 EI - how to handle malformed JSON requests in API

I have created an API in WSO2 EI.
API is expecting the requests to be send as JSON.
If it is a malformed JSON which is sent, then I should be able to receive it and make appropriate changes to make it a proper JSON.
Any help is much appreciated.
As we are using json-eval($.) to get the message to property, it is not working for me. What else i could try instead of json-eval to get the message as string.
WSO2 EI has the property force.json.message.validation, which can be used to validate incoming JSON payload. Please refer doc to configure this property in 'passthru-http.properties' file.
Once the property is configured, if there is a malformed JSON payload in the request, the mediation flow will be directed to the fault/error sequence. So, you can define the mediation logic to make appropriate changes to the malformed content within the fault sequence of your API.

FromQuery with FromBody fallback

I have a method which accept POST and GET verbs, How can I get a property bind from the querystring if it's a GET request and from body if it's a Post Request?
Extra point if it can databind from JSON and from form encoded bodies.

Mule ESB Flow to pass parameters in Calling SOAP Webservice

I have created on flow in MuleESB which is calling a web-service without any parameter just sending it username, password and token in a property and it is working fine.
But the second API I want to post some parameters while calling soap request but I don't know how to use it I tried to pass through set payload but no response.
use Webservice consumer and add a transform message component beofre it. by doing so you can automatically map all the parameters which are required by the SOAP webservice, as datasence will automaticall download the meta deta of the service using the WSDL file.
Make sure you select application/xml as content type in Postman or SOAP UI and select POST.
Use CXF and select Operation as Proxy Service ,Provide details. Selct and provode (WSDL,MTOM enabled,SOAP Headers ,SOAP 1.2)
Make sure you posting XML request "POST" method in allowed methods.
Use 2 transformers. XML to DOM and DOM to XML.
Log the request using
#[message.payloadAs(java.lang.String)]
Use a groovy script transformer to retreive the entire payload.
def userSoapRequest = new XmlSlurper().parseText(payload);
def userId = userSoapRequest.userId.text();
message.setInvocationProperty('userId', userId);
6.Retrieve userId like above and similarly for all the elements.
7.Process them as you want.
Hope this helps