I want to be able to use Logic Apps to put/post messages in an Azure Storage Queue, because I want to make use of the Managed Identity option that HTTP Logic App acion provides.
I have a Logic App that uses HTTP action to post XML messages to the queue and I have a "Put a message on a queue" action that puts JSON message to the queue for debugging purposes.
My ultimate goal is to be able to use the HTTP action with Managed Identity as Authentication but be able to post JSON messages to the queue like the "Put a message on a queue" action is able to.
You can certainly send JSON as message body. In fact you can send any text. You just have to ensure that the text you're sending as message body must be XML safe e.g. replace < with < etc. Generally Base64 encoded string messages are sent to ensure this.
From the REST API documentation:
A message must be in a format that can be included in an XML request
with UTF-8 encoding. To include markup in the message, the contents of
the message must either be XML-escaped or Base64-encode. Any XML
markup in the message that is not escaped or encoded will be removed
before the message is added to the queue.
Here is what worked for me:
Enabled "Managed Identity" on the Logic App.
Added Storage-Queue-Contributor permissions on the storage queue.
Used utcnow('R') to get this date format ("Tue, 08 Sep 2020 12:03:08 GMT")
for x-ms-date HTTP header (no doc from MS about this).
Inserted JSON data inside
<QueueMessage>
<MessageText>
{
"car": "Audi",
"year": 1983
}
</MessageText>
</QueueMessage>
Final result in Logic App designer:
Related
I am using Send Email connector (SMTP configuration) to send email to gmail. It is observed that sometimes email is sent with blank body. Though in the mule log I am able to see that the email body is constructed correctly just before the Send Email connector, but the email sent is having blank body.
Even though this issue is occurring very rarely but would like to know how we can avoid such situation and is there way to handle this situation? Also, what could cause this issue?
Thanks in advance
There could be two (and more) possibilities:
Your payload being json is not getting read correctly, try payload.^raw when working with email body json. Had to do this when sending a multipart/form-data containing json content for email service
Having said this is a rare scenario it could be possible that your error flow is itself throwing an error ( either while building the body / while calling email end-point) which throws off the body and in the 2nd flow error type being changed without a body the email is sent across? Check your flows make sure http calls are surrounded with Untill-successful scope..
With more info, we could dive deep. What do you think ?
currently I am working with mule. I have 3 flow: RequestFlow, ServiceResponse, and SendResponse.
On the first flow, I processed the request (transform the request parameter, write it into wmq, etc). FYI, wmq on this flow can only be used for write.
On the second flow, I read the response from server via another wmq, transform it into json, and send to VM. FYI, wmq on this flow only can be used for read.
On the third flow, I tried to send back the response to the first flow and generate a file.
To send back the response from flow 3 to flow 1, I try to use request-reply
But, unfortunately, when I tried to send a request, I found out that:
After it reach request-reply component on the first flow, it will directly go to the third flow.
And then, after mule processed all the operation on the third flow, it will send the response back to the request-reply component.
Do some logging (logger component on first flow)
Then, go to the flow, processed all the operation
Processed the third flow again
That's why, after all the process has been finished, my application will:
Generate 2 files (1 contain request xml and 1 contain json response)
Return the request xml to http
However, It's not what I want. The flow that I need is:
Mule processed the operation on first flow until the request-reply component
Go to the second flow and processed all the component
After it finish with second flow, it will goes to third flow. Proceed all the component
Send the reply back to request-reply component on the first flow
Do some logging (logger component in first flow)
And finish
Result from this application should be:
1 File contain JSON response
JSON Response on http
So, how to do so? Thanks in advance.
You don't show the flow that consumes the messages sent to the sender path by the VM outbound endpoint in request-reply: I'm assuming it's a flow that takes care of sending the message to the server.
It seems that all you miss is an VM outbound endpoint in SendResponse that would send the message to the response path, onto which the VM inbound is waiting in the request-reply.
PS. Of course, it's assumed the the server propagates the JMS correlation ID from the request message to the response message, otherwise Mule (nor any client for that matter) could ever reconnect the response to the request and the request-reply would fail.
PPS. You don't need an all router around the single VM outbound endpoint in request-reply.
Is there a way to send http request (to a specific url address) each time i receive email (Google account), with the content of the email received using Google App Engine?
As per your question, it seems that you already have an Incoming Email Handler in your App Engine application.
If the above is true, then in the Incoming Email Handler, you can parse out the message and if it meets your condition for invoking the http request, then you can definitely do that. You can use the URL Fetch service for the same.
One design decision you might want to do is whether you want to keep all your URL Fetch code inside of the incoming Email Handler or you want that to be handled externally via a Task Queue. In that case, I suggest that you can use the Task Queue to create a task when an incoming email comes in to your handler. Then the Task Queue logic can take care of one or more things, which includes invoking the HTTP Service, as you wanted.
I need to POST a JSON structure to a REST endpoint and process the data it returns (all of this is with JSON).
I am planning to use a HTTP outbound gateway for this purpose. Now the thing is that after I have transformed my object (payload of the message) into a JSON format and before I transmit it to the endpoint the payload should be dropped into a database so that in case the endpoint is not available the call can be retried.
As I want to
a) set the status accordingly after the call`
b) update the
respective row with a uuid from the REST endpoint
I need to somehow relate the uuid from my object (the business key) as part of the outbound message to the response of the REST endpoint that is placed on the reply channel. As I cannot ask the provider to return my uuid as part of the response how can I achieve this purely on the client side?
You can add a custom advice to the outbound endpoint using the request-handler-advice-chain. Simply subclass AbstractRequestHandlerAdvice. It's effectively an 'around' advice so you can store it in the DB before invoking the handler and update the status afterwards.
See 'Adding Behavior to Endpoints'
and specifically 'Custom Advice Classes'
When calling a web service from Force.com, I am getting:
System.CalloutException: Web service callout failed: Unexpected
element. Parser was expecting element
'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'
The network guys at the other end has asked to see the full response that Salesforce is getting from their server.
Is there a way to achieve that? I have tried running with debug level 'Finest' from execute anonymous, but that yields the same little message with no further detail.
The message you are getting is because an error is generated as Saleforce is trying to parse the response is and it isn't logged unfortunately.
The parsing error is happening because instead of a SOAP message response you are getting an HTML page. This usually happens when you are accessing a service that is protected behind a firewall. Which means you may be able to see the service when browsing on your computer but remember that Salesforce is outside of your firewall and thus any communication by Salesforce to your service will be blocked.
Couple of ways to address this but this wiki topic from Salesforce best covers the options:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_om_outboundmessaging_security.htm
The above is specific to outbound messaging but essentially the technology issues are the same.
Don't forget that Apex includes an HttpRequest Class that works as a lower layer than the SOAP APIs. You should be able to write up a test method that sends a hard-coded XML request to the server and dumps the HttpResponse so you can see it.
Adding my own best answer, based on some internet research:
You can use an external tool like Runscope as a webservice proxy to automatically forward requests and pass through responses and view the XML SOAP messages. This is not a native solution on SFDC but it does do the job.
https://www.runscope.com/
The issue is that Force.com is trying to parse a SOAP response that's actually just HTML. This happens sometimes when an error occurred server-side and the response is meant for a browser to display, rather than sending back an exception report via a properly formatted SOAP response.
If they can't figure out why they are not sending back a consumable SOAP response, then you can try using other tools (outside of Force.com) to make the same webservice call from your browser and then see what the HTML actually says on return.