I am trying to consume RESTAPI in MULE, endpoint I am trying to access is type POST. How can I set JSON payload while sending request ?
By default, the body of an HTTP request from Mule is the payload of the message. You can use the Transform Message component, or the Set Payload component to set the payload before the HTTP request.
Related
How can I send the multipart request without Mtom enable in Mule 4 by Web Service consumer connector?
This is content of attachment:
<ee:set-variable variableName="AddAttachmentReq" ><![CDATA[%dw 2.0
output application/java
---
{
"TestImage.JPG": readUrl("https://savannahw2.sg-host.com/wp-content/uploads/2020/02/image-24.png", 'application/octet-stream')
}
]]></ee:set-variable>
Case1: Disable MTOM (I catch the request in SoapUI mockup Service)
I can't see the attachment file: The base64 of attachment is inline the soap:Body.
I got the response error message:
AddDocument : Specified File: TestImage.JPG not found.
Disable MTOM
Case2: Enable MTOM
I can see the attachment file.
But Mtom enable auto adjust code in the soap body:
<TestImage.JPG>
<xop:Include href="cid:TestImage.JPG" xmlns:xop="http://....
</TestImage.JPG>
I got the response error message:
org.apache.axis2.databinding.ADBException: Unexpected subelement {http://....com/AddDocServiceImp/}TestImage.JPG
Mtom Enable
I need send the request like this:
SOAPUI Request
The WSDL had no element for contain the content of attachment like: content, binaryAttachment, attachments,...
UPDATE
I had resolve this issue by using HTTP Request component to mimic WSC consume operation.
Link: Workaround for various issues with Mule 4 Web Service Consumer Connector
I have issue in send json data usingi web request node to,I have used web request node to send request on specific web service URL(created web service in java) and in web service received json data pass by web request post data but in web service post data are not received.I have successfully done invoked flowgear specific workflow endpoint via web request URL and pass static json data into post data property in web request node it is work and store data into database.
URL->http://...
Header-> I have not set any header(I have test set contenttype header but same issue is occur)
ContentType->application_json
Method->POST
Post data->{"Account":"1","Name":"testingaccount","Contact_Person":"abc","Telephone":"12345"}
ResponseBody->Column \u0027test_customer_name\u0027 cannot be null
Please help me what is missing in web request node configuration?
Can any please help me about how to make HTTP call using the PATCH method in an HTTP Adapter in IBM Worklight?
The PATCH method is not supported. Per the HTTP adapter documentation:
You can use the HTTP adapter to send GET, POST, PUT, and DELETE HTTP
requests and retrieve data from the response body. Data in the
response can arrive in XML, HTML, or JSON formats.
You can submit feature requests via: http://www.ibm.com/developerworks/rfe/
I am attempting to receive JSON messages into BizTalk using the bLogical REST Start Kit for BizTalk (http://biztalkrest.codeplex.com/).
I am able to successfully receive a message, transform it, and return a response from my Orchestration, but when I transform the response back out through the BizTalkRESTResponseHandler, the HTTP Content-Type is being forced back to 'application/xml', even though I'm explicitly setting it to 'application/json'. The Content-Type is confirmed by tracing the Request and Response in Fiddler, as well as SoapUI.
The Accept: value on the Request is 'application/json'
Any ideas how I can trace further into the Wcf-Custom adapter stack to see where the Content-Type is being reset?
You can solve this by adding a HttpResponseMessageProperty before returning the message in the IDispatchMessageInspector. You can either do this directly in the BizTalkRESTResponseHandler IDispatchMessageInspector or in a separate one.
To do it in the BizTalkRESTResponseHandler get the source and add the following 3 lines of code in the BeforeSendReply method just above the "reply = newReply" in the end.
HttpResponseMessageProperty prop = new HttpResponseMessageProperty();
newReply.Properties.Add(HttpResponseMessageProperty.Name, prop);
prop.Headers.Add("Content-Type", "application/json;charset=utf-8");
Now instead of getting:
You will get this:
I want to send something like:
<GetColors>
<Credentials username="test" password="test" />
<GetColors>
Once I receive the request, I want to read in the Credentials, verify it. If it is verified, I will send back a soap response. How can I do this?
With build in stuff you can't. You can turn off the SOAP processing by either using REST service or custom binding with MessageVersion.None and you must build valid SOAP response manually like any other XML document.