How could I modify OData JSON payload before sending to the server? I am Using DataServiceContext to interact with WebApi OData Service.
Look at the BuildingRequest event on DataServiceContext.
I think what you are look for is request pipeline, which can modify the payload before sending. Please refer:
https://blogs.msdn.microsoft.com/odatateam/2013/07/26/using-the-new-client-hooks-in-wcf-data-services-client/
Related
I have an issue validating a request with a model when the user changes the content-type of the request in a serverless framework lambda-proxy integration
As per AWS docs, we can not change too much when using lambda-proxy integration
For example, the passthrough behavior that explains what happens when a validation model does not match the request type, can not be used on lambda-proxy integration.
My problem: I want to reject all requests that are not JSON so they must be forced to use the model validation. But at the same time, I do not want to change the integration type from lambda-proxy to lambda.
What can I do to solve this issue?
BR
One thing you can do is inspect the headers in the event object to confirm that it is the type you expect and if not return an error:
https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html
We can enforce the Content-Type header straight into the API Gateway like below.
References can be found here: https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html
I have started using WebClient in my Spring boot project recently.
Can somebody throw some light on the differences/usages between exchange and retrieve method in WebClient.
I undertand that exchange returns Mono<ClientResponse> and retrieve returns ResponseSpec, I just want to know when/why I should use each one of them.
Much Thanks.
Adding to #JArgente's answer.
According to the official documentation of the retrieve() method:
Perform the HTTP request and retrieve the response body.
...
This method is a shortcut to using exchange() and decoding the response body through
ClientResponse.
and the exchange() method
Perform the HTTP request and return a ClientResponse with the response status and headers. You can then use methods of the response to consume the body:
The retrieve() method decodes the ClientResponse object and hands you the ready-made object for your use. It doesn't have a very nice api for handling exceptions.
However on the other hand the exchange() method hands you the ClientResponse object itself along with the response status and headers. With exchange method you get fine grained control over your response objects and a better way to handle the response object and the exceptions.
If you just want to consume some api go with retrieve().
If you want a better control over your response objects, headers and exceptions, go with exchange().
Update 1
Starting from Spring 5.3, the exchange() method is deprecated due to possible memory/connection leaks. exchangeToMono() or exchangeToFlux() can be used instead.
Thanks #rhubarb for the update.
According to spring Webclient api documentation the difference between the two is that exchange retrieve in addition to the body other http response information like headers and status, while retrieve only returns body information.
So If you only need the body information you should use retrieve, because it is a shortcut for exchange and then get the body, but if you need other information like http status you must use exchange.
I'm using IBM API connect & IBM DataPower 2018.
I have a SOAP web service, and I need to do some customized logging for it by capturing the request\response payload.
When the service returns a valid XML, or even SOAP exception, I could easily handle such cases, and save the request\response payload in separate DB schema for operational purposes.
I updated the response payload by returning non XML response from the backend, like "ABCDEFGHI....".
when I call this service through datapower, it returns clear response.
<errorResponse>
<httpCode>400</httpCode>
<httpMessage>Bad Request</httpMessage>
<moreInformation>Invalid XML payload received.</moreInformation>
</errorResponse>
But I am unable to capture the message.body payload which is in my case "ABCDEFGHI..", the apim.getvariable('message.body') returns nothing.
My question:
How to capture the invalid response payload (none well XML) for SOAP service by using Gateway script?
You can't... as the the message will be rejected prior to processing since DataPower will set the message type to SOAP it will reject anything not being SOAP.
You would need to pass it through a "chaining" API (or service on the DataPower instance) which could capture the response payload.
I am receiving HTTP requests on a Tibco service using HTTP Receiver element, and I would like a way to extract or parse the Soap Body from the Request, without resorting to using the Soap Event Source element. Is there a way?
you can receive SOAP request across SOAP palette or service palette
You can use serviceagent for soap requests and map your request to related process , serviceagent will check your configuration and send your soap body to process directly
New to NiFi!
I'm using InvokeHTTP nifi processor (using this link as an example to implement my flow http://www.tomaszezula.com/2016/10/30/nifi-and-http-post-configuration/). I currently need to do POST in order to authenticate against a server I am using. I am able to POST successfully. However, I need to be able to get the data returned from the response of the POST that was executed. When I look at InvokeHTTPs output into the success queue all I see is the body which I had posted. Is there anyway for me to get the response into a flowfile?
Thanks in advance!
Apache NiFi's InvokeHTTP processor sends the response content to a separate relationship from the original flowfile. You will want to separately route this response relationship.
InvokeHTTP also has a Put Response Body In Attribute property, which you can set to capture the response as a attribute, rather than a separate flowfile. This might be useful for an auth token.