Mule 4: Call SOAP Service with attachment - mule

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

Related

Hosting the endpoint in the BizTalk process using non UTF-8 encoding

There is a problem with encoding using WCF detailed described here : blog post
WCF: Text Message Encoding and ISO-8859-1 Encoding
I'm getting similar error in response :
A message sent to adapter "WCF-BasicHttp" on send port "XXXX" with URI "http://XXXXXXXX:8080/index.php" is suspended.
Error details: System.ServiceModel.ProtocolException: The content type text/xml; charset=ISO-8859-1 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.
I'd like to create a simple proxy WS in BizTalk Environment. I created 1 Receive Location using WCF-BasicHttp / WCF-Custom (neither worked) adapter and send port (SOAP WCF-BasicHttp). Send port is subscribing Receive Location as mentioned here:
Best approach to simple proxy on BIZTALK
I created endpoint in the BizTalk process mentioned here: Codit Blog Hosting WCF HTTP receive location inside BizTalk, without using IIS.
I cannot set other textEncoding than UTF-8, while trying to set ISO-8859-1 I get the error:
"The text encoding ISO-8859-1 used in the text message format is not supported. Parameter name: encoding"
Is there any way to run this using some custom encoders in BizTalk environment?
I managed to do it myself.
I deleted textMessageEncoding binding from Receive and Send WCF-Custom adapter
and instead of it I put customMessageEncoder binding with soap11 and proper iso encoding. Note that httpTransport should be last on binding list.

Accessing POST REST API in mulesoft

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.

cxf LOGGING of soap messages - reduce payload - delete binaryStreamList WildFly

Actually i have a problem with Webservice-Framework Apache CXF Integration/Intstalling in WildFly v.10 - org.apache.cxf.
Every SOAP message is logged in a special file soap.log. This is configured in standalone.xml of JBoss. The Problem is that the logged SOAP messages contains <-binaryStreamList><-bytes>...<-bytes> - Base64 Data - which is too much (unuseful and unreadble information). How can i disable the logging of Base64 crypted data in the <-binaryStreamList> section of logged SOAP messages?
EXAMPLE OF logged SOAP Message:
Payload: <-soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><-soap:Body><-raum>TEST<-/raum><-clientU
ser><-System><-/clientUser><-nummer>99999<-/nummer><-kNumber>9111111<-/kNumber><-nameOfFile>test.pdf<-/nameOfFile>
<-binaryStreamList>
<-bytes>JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PC9TdWJ0e
XBlL1R5cGUxL1R5cGUvRm9udC9CYXNlRm9udC9IZWx2ZXRpY2EvRW5jb2RpbmcvV2luQW5zaUVuY29kaW5nPj4KZW5kb2JqCjIgMCBvYmoKPDwvTW9kRGF0ZShEOjIwMTcwNzA1MTM1MDM5KzAyJzAwJykvQ3JlYXRpb25EYXRlKEQ6
MjAxNzA3MDUxMzUwMzkrMDInMDAnKS9Qcm9kdWNlcihpVGV4dK4gNS41LjYgqTIwMDAtMjAxNSBpVGV4dCBHcm91cCBOViBcKEFHUEwtdmVyc2lvblwpOyBtb2RpZmllZCB1c2luZyBpVGV4dK.....<-bytes>

How can I receive a request from remote request in Mule anypoint?

I am sending a request with XML Data to an anypoint URL after an order is created from my site. How can receive this data and save it as file and upload to a ftp?
I am new in mulesoft. Please help.
Are you exposing it via HTTP endpoint?
If so then to receive response just save the response payload.
flowVars.response = #[message.payload]
Then write to ftp path using ftp connector.
show your Xml config to help further.

Unable to programmatically set Content-Type in BizTalk Wcf-Custom response port

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: