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

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.

Related

How REST API works?

enter image description here
What this picture actually describes?
I have a confusion, which is, whenever we are sending a GET request to the server via a API,
are we sending it in JSON format ?Or, in HTML or any simple Text format?
On the other hand, whenever the API is sending a request (HTTP verb actually) to the server, is it using HTTP format? and the server also returns a response in HTTP format or in JSON format?
I know this question is very silly....but I am very new in API world.
The picture is not accurate, the server sends a response and the MIME type does not matter, it can be even RDF n-triples or images depending on the type of the service and what it supports. The protocol is always HTTP, though theoretically it is possible to use a different protocol. REST has some mandatory constraints, you can read about them in the Fielding dissertation or I wrote about them here and here.

REST API design: the endpoint which returns a report

I need to create an endpoint which return some form of a report. Something like:
api-v1/report?format=XML. And it report with custom XML-report.
What should I do in case xsl?
api-v1/report?format=XSL is it normal to answer on such request with XSL(Excel) file?
the resource (data) should be independent from the formatting/encoding
whether it is xml, json, xls, csv, etc should be determined through "content negotiation" usually accomplished by using the "accept" header.
One solution is to respond with the URL of where the file can be downloaded from, instead of sending the contents of the file.

Escape characters appearing in incoming message in 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?

How to set http headers in dotCMS

I'm trying to create a XML data feed with dotCMS. I can easily output the correct XML document structure in a .dot "page", but the http headers sent to the client are still saying that my page contains "text/html". How can I change them to "text/xml" or "application/xml"?
Apparently there's no way to do it using the administration console. The only way I found is to add this line of (velocity) code
$response.setHeader("Content-Type", "application/xml")
to the top of the page template.
Your solution is the easiest. However there are other options that are a bit more work, but that would prevent you from having to use velocity to do the XML generation, which is more robust most of the time.
DotCMS uses xstream to generate XML files (and vise versa). You could write a generic plugin to use this as well.
An JSONContentServlet exists in dotCMS that takes a query and generates json or xml (depending on your parameters). It is not mapped on a servlet by default, but that is easy to add.

i:nil="true" WCF REST request

I am using a data contract in WCF, but there is some unwanted response tags being sent in the xml file, I am not sure how to modify the data contract class so that I can avoid sending that unwanted response field. In the below XML file, all the text which is bolded and italics is unwanted. Thanks.
I have small problem in xml request and data is coming in the following format
<resller i:nil="true">
What is the reason for this...