How to Use HTTP Receive GET Message in Orchestration? - get

I have set up a HTTP Receive (req-response) adapter and the message appears to be getting to the message box. When I create an orchestration using a direct bound logical port, I am getting the message but everything I have tried to read the message body has failed (using passthrough pipeline, XML pipeline with allow unrecognized files = true) but I get exceptions any time I try to use the incoming message (message assignments, sending the message to a custom module to try to read the part(s)).
Rather than go into details on exceptions, can anyone point to instructions on what the proper way to access/use the body of the HTTP Get messages within an orchestration? To explain what I am trying to do, I want to take the query string (body) and send it verbatim to another orchestration for processing, so I simply want to extract the body (query string) from the message.

For a GET request without a body you need to use the WCF-WebHttp adapter rather than the deprecated BTSHTTPReceive.dll
With the WCF-WebHttp you can use the Variable Mapping to populate message context properties with the URI parameters.

So the answer was to NOT use the HTTP adapter for GET requests. I did not realize the HTTP adapter has effectively been deprecated. For basic GET requests I had to switch to the WCF-WebHTTP adapter and make sure to include the property in the property schema and then make sure to set the schema in the variable mapping as the property schema, not the message type schema of the incoming message. I wish the Microsoft documentation was more clear that the HTTP adapter cannot be used for very basic GET requests in which a body is not provided in the request.

Related

What is the JSON schema to create Dialog flow CX agent via binary import?

https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents/restore
Where can I get more information regarding the schema of input file and how do I parse .blob file received from exporting some agent?
TLDR: It is not possible to create a readable JSON from the .blob file and this behavior is intended.
This is because there might be users that will create an agent from JSON only. Doing this might bypass all the design time check and validation and will result in a lot of internal errors in Dialogflow.
As a workaround if you want to check something (ex. Flow, Intents) in JSON format you can send a request on the following endpoints to get these:
Agent resources:
Call ListIntents, ListEntityTypes, ListWebhooks, ListFlows
Flow resources:
Call ListPages, ListTransitionRouteGroups

node-red wait for async query for http-response

I have REST-endpoint done with node-red which do some async tasks, for example odbc-query to the database.
When I'm resulting query to the http-response. It's just hangs on browser.
Looks like I need forward req and res object to the http-response. But how I do it?
Here is the flow:
[{"id":"a35e6901.509a1","type":"http in","z":"ec714e97.d73b58","name":"","url":"/get","method":"get","upload":false,"swaggerDoc":"","x":287.8571472167969,"y":1660.357177734375,"wires":[["7c116e0a.f8d67"]]},{"id":"98e22918.79bc4","type":"sqldbs","z":"ec714e97.d73b58","mydb":"8df7f8b0.bd44c","querytype":"select","name":"","x":723.5714111328125,"y":1644.6428833007812,"wires":[["de837ef9.5c1cf8"]]},{"id":"7c116e0a.f8d67","type":"function","z":"ec714e97.d73b58","name":"","func":"msq.topic = \"Select * from User\"\nreturn msg;","outputs":1,"noerr":0,"x":469.28570556640625,"y":1613.9286499023438,"wires":[["98e22918.79bc4"]]},{"id":"de837ef9.5c1cf8","type":"http response","z":"ec714e97.d73b58","name":"","statusCode":"","headers":{},"x":922.1428833007812,"y":1677.8570861816406,"wires":[]},{"id":"8df7f8b0.bd44c","type":"sqldbsdatabase","z":"","host":"127.0.0.1","port":"1433","db":"test","dialect":"mysql"}]
You need to make sure that it's the same message object that flows from the http-in node all the way to the http-out node.
This message object will have fields of msg.req and msg.res and the msg.res field will be used by the http-out node to send the response back to the browser.
Any node that takes an input and then forwards it on should preserve these field and not just create a new object for the output. All the built in nodes do this correctly and as should all the published 3rd party nodes. If you find one that does not follow this pattern you should raise a bug with the maintainer.
Your flow looks ok, but I've never used the DB nodes you have so can't comment on those.

Logic App Send Message error with JSON

I'm using Logic App to send a message to a service bus on Azure. The logic app starts with a HTTP Request for the trigger which contains a JSON payload in the body. The 'Body' of the request is set as the Content of the Send Message action. Since the payload is JSON when posting I set the Content-Type to application/json. This generates an error on the Send Message action;
{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'Send_message.' inputs at line '1' and column '1221': 'The template language function 'encodeBase64' expects its parameter to be a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#encodeBase64 for usage details.'."}
So tried changing the Content-Type to text/plain and it works? Is this a bug or should convert the JSON to a text value somehow before using it in the Send Message action?
Sending a message to service bus requires the message content to be base64 encoded. Since your content is a JSON, you would need to stringify it explicitly prior to encoding, i.e. use #encodeBase64(string(jsonContent))
Changing the content type to text/plain has the same effect, since in that case the content is treated as a string to begin with.

Access to requestContent within AfterRequest Script soapui

I'm trying to simulate an asynchronous response on a webservice mock. The goal is to response a synchronous acknowledge message and then a delayed message back to the replyTo address. The approach I have selected uses mock service that will handle the acknowledge and then run a test case that will handle the processed message back to the replyTo. I'm using OnRequest Script to generate the acknowledged message and AfterRequest Script to run the test case that will emulate the delay and the response back to the replyTo.
So the question is which script object I can use to have access to the requestContent. I have seen examples using:
def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent )
but the mockRequest instance is not available on AfterRequest, Which object I can use instead to have a holder with the request content?
I did find that
def holder = new com.eviware.soapui.support.XmlHolder( mockResult.getMockRequest().requestContent )
do the trick, but now I find that running a test script in AfterRequest delays the synchronous response back, Why could this be happening? Isn't AfterRequest's script executed after the mock service response back? Do i have to explicitly execute something at Dispatch or at OnRequest in order to summit back the response before AfterRequest code being executed?
I know this is really old question, but I just faced the same issue myself. I have no idea why it works as it works, but you can avoid the problem by accessing the request content in OnRequest, then store needed information to context and use the context in AfterRequest to get the information you need.

Accessing Request, Response, Service and Db Context, etc. in ServiceStack

In my previous project, I use a framework (Agatha RRSL) similar to ServiceStack, in that everything is made of Request, Response and Handler. It also has Interceptors that can attach to handler and you can inject other interfaces to the handler as well. I can use this to open a transaction BeforeHandling, access to both request and response in AfterHandling, create audit, save to database and close transaction if needed.
I try to experiment similar with SerivceStack. But seems with Filters, I can't grab request and response together?
With custom ServiceRunner. When I try to debug OnAfterExecute(...), I can see the name of my request dto in IRequestContext {ServiceStack.ServiceHost.HttpRequestContext}. But just the name, I couldn't figure out how to retrieve the actual request object to work with the response object.
Another thing I haven't figure out is if it's possible to inject the auto wired service interface into it, like a db context or audit service. Maybe this one is too far ahead in the pipeline?
The final thing is, it seems I can only register one custom service runner? With Interceptor, I can drop a bunch of them, and they will wrap around each other.
Any thoughts? Thanks
The RequestContext also contains the HttpRequest and HttpResponse which you can get access with:
var httpReq = RequestContext.Get<IHttpRequest>();
var httpRes = RequestContext.Get<IHttpResponse>();
See the docs on Accessing HTTP Specific features for more info.

Resources