Escape characters appearing in incoming message in Mule - mule

My mule application polls XML file from an external endpoint, processes the XML file using XPath expressions, and forwards the payload to appropriate flows for processing.
I am testing the flows by providing the below XML file as inbound message using SoapUI or Mozilla post:
<Employee><Applicant empid="1" firstname="simon" surname="O'Brien"/></Employee>
I am receiving the XML file inside mule flow as below which is perfect and the way I want:
<Employee><Applicant empid="1" firstname="simon" surname="O'Brien"/></Employee>
But when I poll the same XML file from external endpoint, escape characters are still appearing in incoming message:
eg. eg. <Employee><Applicant empid="1" firstname="simon" surname="O'Brien"/></Employee>
I want to receive message with apostrophe (') in place of (').
Can you please advise where I am wrong? Why it is behaving differently for external endpoint and SoapUI?

Related

The request does not contain a \"file\" part or \"metadata\" part

I have gone through number of forums including the current forum as well, but I couldn't find concrete answer.
Problem Description: Mule sub flow expects JSON (Content-Type=application/json) as input. An attachment with input JSON, should be sent across with http request to third party REST Service.
Following is the source code used.
Sourcecode of Mule subflow
But the third party REST service is responding with Bad request with error message as "code": 400,. "error": "The request does not contain a \"file\" part or \"metadata\" part. However when tried with Postman, the request was successful as shown below
Request successful in Postman
what is wrong with the code?
First, do not specify the Content-Type since the multipart format requires a special boundary section. The proper header will be generated for you once an attachment is present in the Mule Message. If you hard code it, you will have problems.
Second, if the attachment is suppose to be a JSON, then put application/json as the attachment contentType instead of application/octet-stream.
Third, if the problems persists I would suggest enabling HTTP wire logging (<AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="DEBUG"/>) to actually compare the Postman and Mule requests.

Query parameter values starting with # is not getting considered in Postman

I developed one application in Mulesoft for calling a SOAP webservice. While making GET call to a SOAP web service from Postman, query parameter value starting with # is not getting considered by my Mulesoft mapping.
e.g: http://localhost:8080/appName?queryParam1=#abc
In my mule application, the value for queryParam1 is coming as empty value. Could some one explain the technical reason for this. Is # is considered as escape character from Postman or Mulesoft Transform Message activity? Thanks in advance
I also faced the same issue in my API, in URI anywhere in between comes the '#' character the rest of your URI will go blank and the 404 HTTP error will occur.
I suggest you to get the value in query parameter without # character and later in the API code or flow prefix it. This will work.
Hope this will resolve your problem.
You will have to encode characters such as #. Refer this link for complete list of such characters. In your example:
Change: http://localhost:8080/appName?queryParam1=#abc
To: http://localhost:8080/appName?queryParam1=%23abc

how to parse incoming XML file in HTTP request and generate s response based on incoming XML data in Tibco BW

I am new to TIBCO BW development. I need your expert opinion, as I am stuck to create a response XML file. Here is the scenario.
I get a XML file in the HTTP request and after parsing the incoming request XML structure, I have to create a response document which will act as a stub to the incoming request.
First I create a HTTP Receiver which will act as receiving the XML file in the HTTP request. Then I used Parse XML to parse the incoming XML document is correct or wrong. After this activity I am stuck, since I create the Render XML activity after this but it does not fetch the data even after I map the incoming request parsed by Parse XML activity, I can see during Testing time that it is getting the whole XML in the Input but even after mapping the output with input from Parsing, I get NULL values, hence facing errors.
Please let me know where I am doing wrong, or should I use any other method to catch the incoming values, such that I can create a proper response XML document to be used as Response.
Once you received the HTTP request, parsed the HTTP Post Data using the "Parse XML" activity, I really advice you to use a "Mapper" to map your input (received and parsed as an XML) to a XML output schema. This output can easily be returned after.
For example,
My HTTP client send me an XML like this
And I want to return an XML like this with the addition of a and b
The process :
And the mapper
And the end, you can send the XML HTTP response like this :
EDIT (comment) :
To edit the prefix namespaces in a process. You must click on the process (left hand menu) and on the bottom side, there is a button "Namespace Registry"
if you click on it you'll be able to change the prefix name.
But bear in mind, this kind of manipulation can break the existing mapping in the process because everything is XML based in Tibco BW.

spray autochunked requests with multipart/form-data

I'm using spray-can and spray-routing to support a REST service that includes an operation to upload files. This operation accepts multipart/form-data and the formFields directive works well.
When I try to use the spray request chunking support though, I find that the formFields directive is not working as the whole multipart message is chunked and not just the one part that is large.
Has anyone got any advice on how the handle large multipart messages in spray-can?
All I can think of right now is to put the whole request data in a temp file and to use something like org.apache.commons.fileupload.MultipartStream to parse the request.

Function Unit Test sending multipart/form-data to a Mule flow

I am using JMeter to send Multipart Messages like this:
Raw Post body
Body
Send files with the request
path Parameter Name Mime type
file1.jmx Payload multipart/form-data
test.jpg Attachment
However we would like to move this over to a Function Unit Test. Is there a best practice way to do this in Mule? Do I just send a mule message with attachments? Would this be a good replication of a http Multipart message?
msg.addAttachment(name, dataHandler)
MuleMessage result = client.send("http://localhost:8090/", msg, 200 * 1000);
For this type of tests, I like to use Apache's Common HTTP Client because it is independent of Mule (so it simulates a "neutral" HTTP client) and it's easy to use from a functional test method.