WSO2 SP upgrading from DAS - wso2

I am trying to upgrade from WSO2 DAS to SP; which involves rewriting the event flow definition with Siddhi SQL script.
my object is that all changes be restricted within Siddhi SQL script(thus within SP).
I am using DAS as a simple "Message Broker" in a micro service context.
as shown in the diagram:
there are three(3) micro services: A, B, C; service A calls service B, and C.
service A issues an "wso2event" with the wso2 data agent;
the event is received by a receiver (type="wso2event") in the DAS;
two(2) publishers (eventAdapterType="soap") were used to form two SOAP messages and published respectively to service B and C
below are my artifacts definitions:
stream:
{
"name": "ip3c",
"version": "1.0.0",
"nickName": "ip3c.receiverservice.senderservice.follow",
"description": "follow event from receiver to sender and userevent",
"metaData": [
{
"name": "sender",
"type": "STRING"
}
],
"correlationData": [
{
"name": "host",
"type": "STRING"
}
],
"payloadData": [
{
"name": "message",
"type": "STRING"
}
]
}
receiver:
<?xml version="1.0" encoding="UTF-8"?>
<!-- gbb2.receiverservice.follow -->
<eventReceiver name="gbb2" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="receiving.events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="ip3c" version="1.0.0"/>
</eventReceiver>
publisher 1:
<?xml version="1.0" encoding="UTF-8"?>
<!-- pnbu.senderservice.follow -->
<eventPublisher name="pnbu" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="ip3c" version="1.0.0"/>
<mapping customMapping="enable" type="xml">
<inline>
<sen:follow xmlns:sen="http://gubnoi.com/SenderService/">
<sender>{{meta_sender}}</sender>
<host>{{correlation_host}}</host>
<message>{{message}}</message>
</sen:follow>
</inline>
</mapping>
<to eventAdapterType="soap">
<property name="soapHeaders">SOAPAction: http://gubnoi.com/SenderService/follow</property>
<property name="url">http://sender.gubnoi.com:10102/services/SenderService/</property>
</to>
</eventPublisher>
publisher 2:
<?xml version="1.0" encoding="UTF-8"?>
<!-- tvzh.userevent.receiverfollow -->
<eventPublisher name="tvzh" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="ip3c" version="1.0.0"/>
<mapping customMapping="enable" type="xml">
<inline>
<use:save xmlns:use="http://gubnoi.com/UserEvents/">
<title>u5khurw3</title>
<obj>{{meta_sender}}</obj>
<host>{{correlation_host}}</host>
<bucket>{{message}}</bucket>
</use:save>
</inline>
</mapping>
<to eventAdapterType="soap">
<property name="soapHeaders">SOAPAction: http://gubnoi.com/UserEvents/save</property>
<property name="url">http://userevents.gubnoi.com:10304/services/UserEvents/</property>
</to>
</eventPublisher>
I searched around, and could not find any useful examples.
Can anyone please give any help
thanks

WSO2 Stream Processor has a documentation on upgrading from a previous release. You can refer the documentation to create siddhi artifact from your streams, receivers and publishers.

Related

Javascript application is unable to generate access token from WSO2 gateway URL

We have on premise WSO2 stack for managing the api subscription where there are client applications created in the wso2 store URL for generating access tokens. One of the development team in our organization is trying to generate the access token from the client id and secret by the means of javascript. The tokens are not getting generated and resulting into CORS issue. I have checked the documentations for similar issues and I have made change in the TokenAPI.xml file located under the <API_M>/repository/deployment/server/synapse-configs/default/api directory by adding the outsequence property. Unfortunately this did not solve the issue. I have read a few documentations and verified the cors configuration in the api manager.xml file it looked fine to me.
const token =
"Base64(consumer-key:consumer-secret)";
const url = "https://<gateway_Url>/token";
const res = axios({
method: "post",
url: url,
data: "grant_type=client_credentials",
headers: {
"Authorization": `Basic ${token}`,
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json"
},
});
cat /data/wso2/wso2am-2.6.0/repository/deployment/server/synapse-configs/default/api/_TokenAPI_.xml
<api xmlns="http://ws.apache.org/ns/synapse" name="_WSO2AMTokenAPI_" context="/token">
<resource methods="POST" url-mapping="/*" faultSequence="_token_fault_">
<inSequence>
<property name="uri.var.portnum" expression="get-property('keyManager.port')"/>
<property name="uri.var.hostname" expression="get-property('keyManager.hostname')"/>
<send>
<endpoint>
<http uri-template="https://{uri.var.hostname}:{uri.var.portnum}/oauth2/token">
<timeout>
<duration>60000</duration>
<responseAction>fault</responseAction>
</timeout>
</http>
</endpoint>
</send>
</inSequence>
<outSequence>
<property name="Access-Control-Allow-Headers" scope="transport" value="authorization,Access-Control-Allow-Origin,Content-Type,Action"></property>
<send/>
</outSequence>
</resource>
<handlers>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerCacheExtensionHandler"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.common.SynapsePropertiesHandler"/>
</handlers>
</api>
Error - Access to XMLHttpRequest at 'https://api-uat.ucl.ac.uk/token' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
You might have to add the CORS handler to the token API under handlers.
<handler class= "org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
<property name="apiImplementationType" value="ENDPOINT"/>
</handler>

wso2 issues using call mediator on magento2 api

I'm trying to create a service chain using a wso2 sequence with a payload factory and call mediator.
I'm using wso2 3.2.0 and Magento 2.4.1.
My goal is to ask Magento a token using admin credentials, and returning the token to the client. The payload to make the request should be defined inside the sequence, and there should also be other call mediators after the first one.
I've defined my API with the following definition, and I'm using dynamic endpoints
openapi: 3.0.1
info:
title: Magento
version: v1
servers:
- url: /
security:
- default: []
paths:
/call:
get:
parameters: []
responses:
'200':
description: ok
security:
- default: []
x-auth-type: None
x-throttling-tier: Unlimited
x-wso2-application-security:
security-types:
- oauth2
optional: false
post:
parameters: []
responses:
'200':
description: ok
security:
- default: []
x-auth-type: None
x-throttling-tier: Unlimited
x-wso2-application-security:
security-types:
- oauth2
optional: false
components:
securitySchemes:
default:
type: oauth2
flows:
implicit:
authorizationUrl: 'https://test.com'
scopes: {}
x-wso2-cors:
corsConfigurationEnabled: false
accessControlAllowOrigins:
- '*'
accessControlAllowCredentials: false
accessControlAllowHeaders:
- authorization
- Access-Control-Allow-Origin
- Content-Type
- SOAPAction
- apikey
- testKey
accessControlAllowMethods:
- GET
- PUT
- POST
- DELETE
- PATCH
- OPTIONS
x-wso2-production-endpoints:
type: default
x-wso2-sandbox-endpoints:
type: default
x-wso2-basePath: /magento/v1
x-wso2-transports:
- http
- https
x-wso2-response-cache:
enabled: false
cacheTimeoutInSeconds: 300
The sequence for my API looks like so,
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="service_chain_request_magento" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
<property name="FORCE_HTTP_1.0" scope="axis2" type="STRING" value="true"/>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<payloadFactory media-type="json">
<format>{"username":"<username>","password":"<pwd>"}</format>
<args/>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<call blocking="true">
<endpoint>
<http method="post" uri-template="http://<magento_ip>/index.php/rest/all/V1/integration/admin/token">
<timeout>
<duration>6000</duration>
<responseAction>fault</responseAction>
</timeout>
</http>
</endpoint>
</call>
<enrich>
<source type="body" clone="true"/>
<target type="property" action="child" property="body_of_first_call"/>
</enrich>
<log level="full"/>
</sequence>
Where everything inside <> is, of course, replaced with proper values.
When I try to call my API POST - https://<ip>:8243/magento/v1/call using this sequence, I get the following result:
{
"message": "One or more input exceptions have occurred.",
"errors": [
{
"message": "\"%fieldName\" is required. Enter and try again.",
"parameters": {
"fieldName": "username"
}
},
{
"message": "\"%fieldName\" is required. Enter and try again.",
"parameters": {
"fieldName": "password"
}
}
],
}
even though, inspecting the logs, this is the response:
INFO - LogMediator {api:admin--Magento:vv1} To: http://<magento_ip>/index.php/rest/all/V1/integration/admin/token, MessageID: c6b5eb10-89a1-42df-9f0d-098d605dae91, correlation_id: c6b5eb10-89a1-42df-9f0d-098d605dae91, Direction: request, Payload: "brni5ub8o4vfltfups9swrwk3biw3cd4"
As what I can understand, the Payload field is correctly returning the expected response from Magento rest APIs, but it looks like the REST client I'm using (both Postman and the wso2 console) are returning the error response from the API, like the request is made a second time without the post body.
If I replace the call mediator with the To header like this:
<header name="To" scope="default" value="http://<magento_ip>/index.php/rest/all/V1/integration/admin/token"/>
the call just works and returns the expected payload, but then I cannot chain other call mediators.
Here's the specs about the Magento API I'm calling https://magento.redoc.ly/2.4.2-admin/tag/integrationadmintoken
How can I resolve this?
Thanks in advance

WSO2 Micro Integrator Validate Mediator fails with Unsupported Operation

Working with Integration Studio in Windows 10.
When I try Validate my Payload from REST API body with Sequence with Validate Mediator I get an Error.
Error:
[2020-03-10 11:07:29,295] INFO {TRACE_LOGGER} - Building message. Sequence <SequenceMediator> is content aware
[2020-03-10 11:07:29,309] ERROR {org.apache.synapse.mediators.base.SequenceMediator} - Unsupported Operation org.apache.axiom.om.OMException: Unsupported Operation
at org.apache.axiom.om.impl.llom.OMTextImpl.getInputStream(OMTextImpl.java:422)
at org.apache.synapse.mediators.builtin.ValidateMediator.mediate(ValidateMediator.java:231)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:214)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.config.xml.AnonymousListMediator.mediate(AnonymousListMediator.java:37)
at org.apache.synapse.config.xml.SwitchCase.mediate(SwitchCase.java:69)
at org.apache.synapse.mediators.filters.SwitchMediator.mediate(SwitchMediator.java:134)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:331)
at org.apache.synapse.rest.API.process(API.java:440)
at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:149)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:95)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:325)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:98)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:367)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:412)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:181)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Then I try to validate from it:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="Reserves" statistics="enable" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
<validate cache-schema="false" source="json-eval($)">
<schema key="conf:/schemas/ReservesRoot.json"/>
<on-fail>
<payloadFactory media-type="json">
<format>{"Error":$1"}</format>
<args>
<arg evaluator="xml" expression="$ctx:ERROR_MESSAGE"/>
</args>
</payloadFactory>
<property name="HTTP_SC" scope="axis2" type="STRING" value="500"/>
<respond/>
</on-fail>
</validate>
</sequence>
JSON Schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"Type": {
"type": "string"
}
},
"required": [
"Type"
]
}
When I get the schema in property I see the schema's string.
<property value="get-property('registry', 'conf:/schemas/ReservesRoot.json')" name="ReservesSchema"/>
<log>
<property expression="get-property('ReservesSchema')" name="JSON_P"/>
</log>
This issue occurs when the JSON-schema saved in the registry does not have the correct media-type (must be application/json). Could you please double-check this in Integration studio Resources Editor view.
You can access the resources editor view by right click on registry resource project -> Registry resource editor
This issue occurs with Micro integrator. Micro integrator does not have rdbms registry artifacts. Hence we cannot specify the media type. The work around is to add local entry file with the validation json schema and refer it in synapse.
<validate cache-schema="false">
<schema key="createotpvalidate"/>
<on-fail>
<payloadFactory media-type="json">
<format>{"Error":$1"}</format>
<args>
<arg evaluator="xml" expression="$ctx:ERROR_MESSAGE"/>
</args>
</payloadFactory>
<property name="HTTP_SC" scope="axis2" type="STRING" value="500"/>
<respond/>
<!-- <schema key="conf:/schema/CreateOTPSchema.json"/> -->
</on-fail>
</validate>
Local Entry file:
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="createotpvalidate" xmlns="http://ws.apache.org/ns/synapse"><![CDATA[{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "request_type": { "type": "string" },"mobile": { "type": "string" },"otp": { "type": "string" } }, "required": [ "request_type","mobile","otp" ] }]]></localEntry>

wso2 server redeployment error "Faulty Carbon Applications."

I am getting an error whenever I tried to redeploy the app to the esb. I am trying to merge the 2 response from different api and then map and manipulate that response. I am also using the latest 5.0.0 BETA version both esb tooling and esb.
Here is the fault reason
org.apache.axis2.deployment.DeploymentException: API deployment from
the file :
/Users/me/Downloads/wso2esb-5.0.0-BETA2/tmp/carbonapps/-1234/1468999438631movieapiApp_1.0.0.car/movieAPI_1.0.0/movieAPI-1.0.0.xml
: Failed. at
org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:213)
at
org.wso2.carbon.application.deployer.synapse.SynapseAppDeployer.deployArtifacts(SynapseAppDeployer.java:131)
at
org.wso2.carbon.application.deployer.internal.ApplicationManager.deployCarbonApp(ApplicationManager.java:263)
at
org.wso2.carbon.application.deployer.CappAxis2Deployer.deploy(CappAxis2Deployer.java:72)
at
org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136)
at
org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:807)
at
org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144)
at
org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377)
at
org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254)
at
org.apache.axis2.deployment.RepositoryListener.startListener(RepositoryListener.java:371)
at
org.apache.axis2.deployment.scheduler.SchedulerTask.checkRepository(SchedulerTask.java:59)
at
org.apache.axis2.deployment.scheduler.SchedulerTask.run(SchedulerTask.java:67)
at
org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask.runAxisDeployment(CarbonDeploymentSchedulerTask.java:93)
at
org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask.run(CarbonDeploymentSchedulerTask.java:138)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
org.apache.axis2.deployment.DeploymentException: API deployment from
the file :
/Users/me/Downloads/wso2esb-5.0.0-BETA2/tmp/carbonapps/-1234/1468999438631movieapiApp_1.0.0.car/movieAPI_1.0.0/movieAPI-1.0.0.xml
: Failed. at
org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:201)
... 20 more Caused by:
org.apache.synapse.deployers.SynapseArtifactDeploymentException: API
deployment from the file :
/Users/me/Downloads/wso2esb-5.0.0-BETA2/tmp/carbonapps/-1234/1468999438631movieapiApp_1.0.0.car/movieAPI_1.0.0/movieAPI-1.0.0.xml
: Failed. at
org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.handleSynapseArtifactDeploymentError(AbstractSynapseArtifactDeployer.java:474)
at
org.apache.synapse.deployers.APIDeployer.deploySynapseArtifact(APIDeployer.java:71)
at
org.wso2.carbon.rest.api.ApiDeployer.deploySynapseArtifact(ApiDeployer.java:34)
at
org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:194)
... 20 more Caused by: org.apache.synapse.SynapseException: Duplicate
resource definition by the name: movieapi at
org.apache.synapse.config.SynapseConfiguration.handleException(SynapseConfiguration.java:1627)
at
org.apache.synapse.config.SynapseConfiguration.addAPI(SynapseConfiguration.java:414)
at
org.apache.synapse.deployers.APIDeployer.deploySynapseArtifact(APIDeployer.java:59)
... 22 more
and here's my api
<?xml version="1.0" encoding="UTF-8"?>
<api context="/movieapi" name="movieapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/*">
<inSequence>
<property name="ROOT" scope="default">
<root:movie xmlns:root="www.wso2esb.com"/>
</property>
<log level="full"/>
<clone continueParent="true" id="movie" sequential="true">
<target>
<sequence>
<send>
<endpoint>
<address format="rest" uri="https://api.themoviedb.org/3/movie/tt0918940?api_key=code&append_to_response=casts,images%22"/>
</endpoint>
</send>
</sequence>
</target>
<target>
<sequence>
<send>
<endpoint>
<address format="rest" uri="https://www.omdbapi.com/?type=movie&i=tt0918940"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</inSequence>
<outSequence>
<aggregate id="movie">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete enclosingElementProperty="ROOT" expression="//jsonObject" xmlns:dummy="http://org.dummy" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<datamapper config="gov:datamapper/movieapiMapping.dmc" inputSchema="gov:datamapper/movieapiMapping_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/movieapiMapping_outputSchema.json" outputType="JSON"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<respond/>
</onComplete>
</aggregate>
</outSequence>
<faultSequence/>
</resource>
</api>
and this is from the terminal
[2016-07-20 15:36:48,890] ERROR - DataMapperMediator DataMapper mediator : mapping configuration is null
The error you are getting in the terminal DataMapperMediator DataMapper mediator : mapping configuration is null is because the relevant registry resources are not deployed (more precisely, the configuration .dmc file). When you are deploying the capp, make sure that all the registry resources are included as well. Also when the capp deployment fails, can you check in the management console for any faulty services/APIs?
You get the error indicating Data mapper configurations null. So you have to add relevant configurations as you given in the proxy:
<datamapper config="gov:datamapper/movieapiMapping.dmc" inputSchema="gov:datamapper/movieapiMapping_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/movieapiMapping_outputSchema.json" outputType="JSON"/>
For example: You indicated about gov:datamapper/movieapiMapping.dmc
This should be available in governance registry.Please deploy relevant configs in to ESB.
Open the pom.xml file inside your CompositeApplication.
Edit it in the Design mode.
Under dependencies, you can see the artifacts which you can include.
Tick the checkbox near your relevant Registry artifact. Save pom file.
Now redeploy the application to the server or Regenerate your car file

WSO2 ESB proxy service Escaping JSON payload when passing to jaggery js

I am POSTing to a ESB (4.6.0) proxy service with a JSON payload. This is a pass through proxy service that routes to a jaggery JS app. The jaggery app is trying to access the JSON from the payload, but it is unable to because the JSON strings are escaped.
Here are the request headers (from web --> ESB):
POST /services/testJaggPS HTTP/1.1
Host: pb-dvwa8:7280
Content-Length: 29
Cache-Control: no-cache
Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
{
"PARAM": "hello world"
}
And here is the JSON response from the jaggery app:
{"RESPONSE" : {"test" : "hi", "PARAM" : null, "content" : "{\n \"PARAM\" : \"HELLO WORLD\" \n}"}}
Note that "content" (variable that stores JSON payload from web) is being escaped.
I have looked into message builders/formatters, but it has not solved this issue. Here is my current proxy service (probably don't need all of the message builders):
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testJaggPS"
transports="https http"
startOnLoad="true"
trace="disable">
<target endpoint="jaggRouter">
<inSequence>
<builder>
<messageBuilder contentType="application/xml"
class="org.apache.axis2.builder.ApplicationXMLBuilder"
formatterClass="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
<messageBuilder contentType="application/xop+xml"
class="org.apache.axis2.builder.MTOMBuilder"/>
<messageBuilder contentType="multipart/related"
class="org.apache.axis2.builder.MIMEBuilder"/>
<messageBuilder contentType="application/json"
class="org.apache.axis2.json.JSONBuilder"
formatterClass="org.apache.axis2.json.JSONMessageFormatter"/>
<messageBuilder contentType="application/x-www-form-urlencoded"
class="org.apache.axis2.builder.XFormURLEncodedBuilder"
formatterClass="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
<messageBuilder contentType="text/xml"
class="org.apache.axis2.builder.SOAPBuilder"
formatterClass="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
<messageBuilder contentType="application/soap+xml"
class="org.apache.axis2.builder.SOAPBuilder"
formatterClass="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
<messageBuilder contentType="application/json/badgerfish"
class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
</builder>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="contentType" value="application/json" scope="axis2"/>
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="contentType" value="application/json" scope="axis2"/>
<send/>
</outSequence>
</target>
</proxy>
And here is my jaggery code:
<%
// load core files
response.contentType = 'application/json';
var url = request.getRequestURL();
var theContent = request.getContent();
// note null 'PARAM' and escaped 'content'
response.content = {"RESPONSE" : {
"test" : "hi",
"PARAM" : theContent.PARAM,
"content" : theContent
}};
%>
There was an issue with Jaggery's automatic JSON parsing when you have additional stuff in the Content-Type header such as character encoding etc. It was fixed in master branch.
But, if you are trying with an earlier version, you will have to manually parse the content using JSON.parse(). i.e. replace your
var theContent = request.getContent();
line in Jaggery file, with
var theContent = JSON.parse(request.getContent());