From ESB our api is making a call to the downstream service which in case of negative scenario is returning
`<html>
<head>
<meta content="HTML Tidy for Java (vers. 27 Sep 2004), see www.w3.org" name="generator"/>
<title/>
</head>
<body>invalid address type</body>
</html>`
but when we log inside esb we see this
QUIgaXMgaW52YWxpZCBhZGRyZXNzIHR5cGU=
Also when the message is send to the caller using respond , the caller gets HTMl again.
We had enabled the following in axis2
`<messageBuilder contentType="text/html"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
`
We want to transform the response into JSON and want to map body in the response before sending to the caller .
The HTML content will be treated as a XML segment by the ESB. SO you can perform any manupulation operation on this content. Can try the Payload Mediator or Enrich mediator with some XPath expressions.
we had observed that the content is coming as base64encoding string into the ESB, that was the reason we were not able to process it , so we did reqd decoding and processed as per our reqmt .
Related
I have a REST service wich uses hypermedias with siren content.
To be useable, the client have to send a Accept header with this value :
application/vnd.siren+json
But when i virtualize this service via Centrasite to the Mediator package, requests are rejected.
When i use an accept with only application/json requests are accepted but the content is without hypermedias links, so it is not useable.
I have changed the content-types.xml file in resources of package Mediator like that :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<content-types xmlns="http://contentTypes.mediator.softwareag">
<!-- Please enter the custom content-types
<content-type type="xml">
<name></name>
</content-type>
-->
<content-type type="json">
<name>application/vnd.siren+json</name>
</content-type>
</content-types>
With that, requests with siren are now accepted, but without hypermedias content (as with application/json)
How can i force Mediator to accept this accept header and tranfer it to the endpoint without changing it ?
I use a webMethods Integration Server 9.7 with IS_9.7_Core_Fix19 and a Mediator 9.7.0.0017-0490
Update :
After viewing endpoint logs, it seems that the header and the response are correct, but the response is truncated by mediator.
All the siren content is removed from the json response, but the response is still well formed, but incomplete, without any log in Mediator even in Debug mode.
Is it a Mediator problem, an axis one, or anything else ?
Aftere searching in Empower knowledge base, I've found this :
If the Content-Type header field specifies a content type for which no content
handler has been registered, Integration Server uses the default content
handler (ContentHandler_Default), which treats the content as text/html.
This explains why I have to change the content-types.xml file in the config directory of the WmMediator package.
Secondly, I've found that issue :
SMGME-6616 (Fix 18)
MultiRoot node elements of JSON type are not passed for a custom content type.
When a custom content type for JSON is executed and a multi root node
element is passed as a request for virtual rest API, then only the first
node is passed to the backend native API. This issue is resolved.
This seems a good explanation why I don't have the full content of my response, because with the Siren Hypermedia format, we have multiple roots in the json message.
So, no solution except patching.
Edit:
After patching, the problem is resolved
I need to configure JSON to JSON transformations with API Manager 2.0 very efficiently.
By default, WSO2 API Manager makes transformations JSON-> XML-> and after processing -> XML->JSON
I'd like to know how can I do so directly in JSON to reduce latencies.
Thank you for your help!!
By default, APIM uses PassThrough transport which does not build your message unless it needs to access your message body. So, your json won't be converted to XML in that case.
For example, if you have configured custom mediation and have a content-aware mediator like <log level="full"/>, APIM has to build (i.e. convert to XML) your message body so that it can log the entire message.
If you don't try to access the message body like that, json will be sent to backend as it is.
I want to generate a rest api in odoo so that it can be used in other languages. I have used below api's
http://URL_with_PORT/{}/xmlrpc/2/common
http://URL_with_PORT/{}/xmlrpc/2/object
but when I validated it using postman it is giving me error.
You don't need the curly braces in the URL. Just send it to the xmlrpc/2/common endpoint, as per...
http://<server:?port>/xmlrpc/2/common
You need to set the verb to POST, and the body to raw with XML.
Then send in the following XML in the form as per the documentation.
<?xml version='1.0'?>
<methodCall>
<methodName>version</methodName>
</methodCall>
This will return the server version info as per the examples used in the External API documentation in an XML response.
Postman isn't the best client to use XML-RPC calls, take a look at XML RPC GUI for developers in Windows?. You have to create a raw request and then send it. Using SoapUI would be much easier.
I have a problem in converting json to json in wso2 esb, actually I'm using payload factory in a proxy and I call the proxy with rest and json content. Here is my integration flow, I call a proxy and the proxy sends the request(with json content) to a jms message store then, I defined a message processor to consume messages from message store and send them to a defined endpoint(.net web api). but the problem is strings with numbers automatically get converted as integer elements: "orderId": 10000 ( I want it to be string "orderId": "10000") , but when I send the request directly from proxy to my end point (without using message broker) it works correctly. Could you please help me solve this problem?
For more details refer to my question with more details on this problem, and looks like this is a bug in wso2 esb 4.9.0
wso2 jira
For your problem need to change a JSON Message Formatters.
please follow the below steps for that.
change your working directory to [ESB Home]/repository/conf/axis2/axis2.xml
then you need to change JSON Message Formatters instead of JsonStreamFormatter use org.apache.axis2.json.JSONMessageFormatter.
<!--messageFormatter contentType="application/json" class="org.apache.synapse.commons.json.JsonStreamFormatter"/-->
<messageFormatter contentType="application/json"
class="org.apache.axis2.json.JSONStreamFormatter"/>
You can use the following builder and formatter in axis2.xml
org.apache.synapse.commons.json.JsonStreamBuilder
org.apache.synapse.commons.json.JsonStreamFormatter
Remove existing builder and formatter for the "application/json" and add the below.
Add under Formaters section
<messageFormatter contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamFormatter"/>
Add under Builders section
<messageBuilder contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamBuilder"/>
I'm using Cordys BOP and I have a REST web service that returns JSON format. I have a test service that I use, that returns XML and this works fine so I know that my HTTP connector works right. When I try to test my JSON service using the Test Web Service Operation UI, I get an error that says Invalid XML response.
How do I tell Cordys to expect a JSON response instead of an XML?
Is there a way to somehow wrap a JSON in XML through Cordys?
You probably need to change the header:
Content-type: application/json