Asserts folder mock jsons are not accessible on azure deployed angular webapp - json

I have an angular application deployed in azure webapp.
I have used mock jsons to load data for few apis, which are residing in assets/jsons folder.
I am able to access a text file which is residing in same path via url like below
https://{myapp}.azurewebsites.net/assets/jsons/users.txt
But when I try to access a json file which is residing in same path like below I am getting error
https://{myapp}.azurewebsites.net/assets/jsons/insights.json
"The resource you are looking for has been removed, had its name
changed, or is temporarily unavailable."
I have added that folder(s) to assets in angular.json
"build": {
"builder": "#angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/web",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets",
"src/assets/jsons"
],
"styles": [
"./node_modules/#angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
}
Application is not working as it is not able to load the data from jsons.Can you please assist in overcoming this issue?

Adding a file with web.config under src/ with below contents
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
And including it in angular.json assets section helped to get it fixed.
"assets": [
"src/favicon.ico",
"src/assets",
"src/web.config"
],
Thanks to reference link provided by Misha Mashina.

Related

BizTalk - Concatenation of repetitive node with output to json array

I have something like below as input xml. As you can see, the node MIF can come multiple times (one or two times).
<Transactions>
<Events>
<Properties>
<ENT_SUB_TYP />
<MIF_ACT_PER>Not app</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
<Transactions>
<Events>
<Properties>
<ENT_SUB_TYP />
<MIF_ACT_PER>3</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
<Transactions>
<Events>
<Properties>
<ENT_SUB_TYP />
<MIF_ACT_PER>6</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
<Transactions>
<Events>
<Properties>
<ENT_SUB_TYP />
<MIF_ACT_PER>3</MIF_ACT_PER>
<MIF_ACT_PER>6</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
The corresponding JSON output file is supposed to look something like below:
{
"Transactions": [
{
"Events": [
{
"Properties": [
{
"ENT_SUB_TYP": [
"NOT_APP"
]
},
{
"MIF_ACT_PER": [
"NOT_APP"
]
}
]
}
]
},
{
"Events": [
{
"Properties": [
{
"ENT_SUB_TYP": [
"NOT_APP"
]
},
{
"MIF_ACT_PER": [
"3"
]
}
]
}
]
},
{
"Events": [
{
"Properties": [
{
"ENT_SUB_TYP": [
"NOT_APP"
]
},
{
"MIF_ACT_PER": [
"6"
]
}
]
}
]
},
{
"Events": [
{
"Properties": [
{
"ENT_SUB_TYP": [
"NOT_APP"
]
},
{
"MIF_ACT_PER": [
"3",
"6"
]
}
]
}
]
}
]
}
Now, I do think that the output schema (showing only the interesting part) is supposed to become something like below but I am only guessing. I dont know how the regular BizTalk JSON translator interprets the output schema.
<Properties>
<ENT_SUB_TYP>NOT_APP</ENT_SUB_TYP>
</Properties>
<Properties>
<MIF_ACT_PER>3</MIF_ACT_PER>
<MIF_ACT_PER>6</MIF_ACT_PER>
</Properties>
How can I do this in the mapper? No matter how I try I just cant figure out how to use the functoids. And I dont understand XSLT so that goes out of the window as well (at least for me. If anyone understands how to, ie. use xslt and and the scripting functoid, that would be good as well). Any help to solve this issue is greatly appreciated!
Update:
This picture represents the faulty output which gives me the '3' and '6' in their own properties node whereas, as stated before, I would like to have them in in one properties node.
Update 2:
According to Mr. Dijkgraaf's suggestion I am updating the post. Hopefully this time it will be clear enough to understand my issue and also my confusion.
The four example input below are barebones of the real input examples I use during development. Data has been masked.
<?xml version="1.0" encoding="utf-8"?>
<ns0:Masterdata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://Masterdata/">
<EntityType xmlns="">CRD</EntityType>
<Transactions xmlns="">
<EntityType>CRD</EntityType>
<Events>
<Properties>
<ENT_SUB_TYP>NOT_APP</ENT_SUB_TYP>
<MIF_ACT_PER>NOT_APP</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
</ns0:Masterdata>
<?xml version="1.0" encoding="utf-8"?>
<ns0:Masterdata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://Masterdata/">
<EntityType xmlns="">CRD</EntityType>
<Transactions xmlns="">
<EntityType>CRD</EntityType>
<Events>
<Properties>
<ENT_SUB_TYP>NOT_APP</ENT_SUB_TYP>
<MIF_ACT_PER>3</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
</ns0:Masterdata>
<?xml version="1.0" encoding="utf-8"?>
<ns0:Masterdata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://Masterdata/">
<EntityType xmlns="">CRD</EntityType>
<Transactions xmlns="">
<EntityType>CRD</EntityType>
<Events>
<Properties>
<ENT_SUB_TYP>NOT_APP</ENT_SUB_TYP>
<MIF_ACT_PER>6</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
</ns0:Masterdata>
<?xml version="1.0" encoding="utf-8"?>
<ns0:Masterdata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns0="http://Masterdata/">
<EntityType xmlns="">CRD</EntityType>
<Transactions xmlns="">
<EntityType>CRD</EntityType>
<Events>
<Properties>
<ENT_SUB_TYP>NOT_APP</ENT_SUB_TYP>
<MIF_ACT_PER>3</MIF_ACT_PER>
<MIF_ACT_PER>6</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
</ns0:Masterdata>
Now, the output of the mapping using the above example with the '4' and '6' gives me below:
<ns0:Masterdata xmlns:ns0="http://Masterdata">
<Transactions>
<EntityType>CRD</EntityType>
<Events>
<Properties>
<ENT_SUB_TYP>NOT_APP</ENT_SUB_TYP>
</Properties>
<Properties>
<MIF_ACT_PER>3</MIF_ACT_PER>
</Properties>
<Properties>
<MIF_ACT_PER>6</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
</ns0:Masterdata>
The mapping is exactly as the picture in the first update shows. And that mapping gives me, if I use the last example file that contains both the '4' and '6', the JSON below.
{
"Transactions": [
{
"EntityType": "CRD",
"Events": [
{
"Properties": [
{
"ENT_SUB_TYP": [
"NOT_APP"
]
},
{
"MIF_ACT_PER": [
"3"
]
},
{
"MIF_ACT_PER": [
"6"
]
}
]
}
]
}
]
}
Now, regarding the source schema and target schema in the mapping, this is what I did. The source schema worked as a blueprint for the target schema. As you can see, the target schema in the mapping does contain a choice node. So this means that nodes that have data in them (in other words do fulfill the logical string functoid requirement) will be sent to the target and output xml.
Regarding the source and target schema, I really wish that I could share them with you. But a confidentialty clause prevents me from doing that.
I think I could perhaps create a dummy schema but then I am not sure that I would actually be able to implement your suggested solution to the real schema. There really isn't anything particular at all with the schemas except for the choice node in the target schema. I really hope this will be enough.
I have tried to follow Mr. Dijkgraafs solution as to make the target schema as simple as possible but there really is nothing to simplify. (Yes, I am the first to admit that I am far from an expert but still, I do have a few years of experience.)
What can be said about the mapping then? The target system requires every property in the source schema to come as a child node of a properties node. It is easier to show it than to explain it. See picture below.
I am doing something wrong regarding the looping functoid (which results in the 4 and 6 coming in their own Properties node instead of them both coming in one).
I can also tell that my value mapping functoid looks like this:
Finally, I hope this will be enough but I am open to suggestions if anyone needs more input. And also, thanks a lot for your patience with me and my incomplete descriptions.
No concatenation needed, you just need to define your schema correctly and the JSON Encoder will put the repeating elements into arrays.
First of all your sample input XML doesn't have a root node, so I'm going to add one as well as a namespace, as without it the JSON Encoder does not use the schema definition and instead gives slightly inconsistent results. If your input doesn't have a namespace, you can have one schema to parse the input, and a second schema that you map to that does have the namespace, or have a Pipeline component add the namespace.
Input
<ns0:Transaction xmlns:ns0="https://SO72306470">
<Transactions>
<Events>
<Properties>
<ENT_SUB_TYP />
<MIF_ACT_PER>Not app</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
<Transactions>
<Events>
<Properties>
<ENT_SUB_TYP />
<MIF_ACT_PER>3</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
<Transactions>
<Events>
<Properties>
<ENT_SUB_TYP />
<MIF_ACT_PER>6</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
<Transactions>
<Events>
<Properties>
<ENT_SUB_TYP />
<MIF_ACT_PER>3</MIF_ACT_PER>
<MIF_ACT_PER>6</MIF_ACT_PER>
</Properties>
</Events>
</Transactions>
</ns0:Transaction>
Schema that matches this.
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch2.SO72306470_JSON" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch2.SO72306470_JSON" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Transactions">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Events">
<xs:complexType>
<xs:sequence>
<xs:element name="Properties">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="ENT_SUB_TYP" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="MIF_ACT_PER" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Then it is a fairly simple map where map back to the same schema and you just need a bit of logic to set the ENT_SUB_TYPE when it is empty.
And a Send Pipeline with the JSON Encoder, and where you set the RemoveOuterEnvelope to True
Drop through the file and the output is.
{
"Transactions": [
{
"Events": [
{
"Properties": {
"ENT_SUB_TYP": [
"NOT_APP"
],
"MIF_ACT_PER": [
"Not app"
]
}
}
]
},
{
"Events": [
{
"Properties": {
"ENT_SUB_TYP": [
"NOT_APP"
],
"MIF_ACT_PER": [
"3"
]
}
}
]
},
{
"Events": [
{
"Properties": {
"ENT_SUB_TYP": [
"NOT_APP"
],
"MIF_ACT_PER": [
"6"
]
}
}
]
},
{
"Events": [
{
"Properties": {
"ENT_SUB_TYP": [
"NOT_APP"
],
"MIF_ACT_PER": [
"3",
"6"
]
}
}
]
}
]
}

Concatenate two JSON responses in wso2 esb

I have two json from two different endpoints, i need to concatenate to convert it into a single valid json. I did it, but the first WSO2 json returns it as a string (firstjson). I would like it to be all a json.
FIRST JSON
{
"first": true,
"second": {
"name": "manoj",
"age": "45"
},
"third": {
"fourth": [
{
"class": "test12",
"salary": "123456"
},
{
"class": "test23",
"salary": "15678"
}
],
"fifth": "hello"
}
}
SECOND JSON
[
{
"item1": "123456",
"item2": "5678"
},
{
"item1": "8976",
"item2": "abcd"
}
]
XML API
<api context="/concat" name="concat" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" url-mapping="/concatenare">
<inSequence>
<call>
<endpoint>
<http method="get" uri-template="http://www.mocky.io/v2/56b2d88c13000057518945d4">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<enrich>
<source clone="false" type="body"/>
<target property="first-json" type="property"/>
</enrich>
<log level="custom">
<property expression="get-property('first-json')" name="First json"/>
</log>
<call>
<endpoint>
<http method="get" uri-template="http://www.mocky.io/v2/56b2d87d1300007c518945d3">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<log level="custom">
<property expression="get-property('first-json')" name="*********BEFOREEEEEEEE"/>
</log>
<!-- <enrich>
<source clone="false" property="first-json" type="property"/>
<target type="body"/>
</enrich> -->
<payloadFactory media-type="xml">
<format>
<completeJson xmlns="">
<firstjson>$1</firstjson>
<secondjson>$2</secondjson>
</completeJson>
</format>
<args>
<arg evaluator="xml" expression="get-property('first-json')"/>
<arg evaluator="xml" expression="$body"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<send/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
RESPONSE API
{
"completeJson": {
"firstjson": "{\"first\":true,\"second\":{\"name\":\"manoj\",\"age\":\"45\"},\"third\":{\"fourth\":[{\"class\":\"test12\",\"salary\":\"123456\"},{\"class\":\"test23\",\"salary\":\"15678\"}],\"fifth\":\"hello\"}}",
"secondjson": {
"Body": [
{
"item1": 123456,
"item2": 5678
},
{
"item1": 8976,
"item2": "abcd"
}
]
}
}
}
Where am I wrong ?
Thanks in advance guys
Ok guys,
I solved it, I was wrong with the payloadFactory, the format it had to be of type json.
<payloadFactory media-type="json">
<format>
{
"completeJson" : {
"firstjson" : $1,
"secondjson" : $2
}}
</format>
<args>
<arg expression="get-property('first-json')" />
<arg expression="$body" />
</args>
</payloadFactory>
thanks anyway guys :)

WSO2 Identity Server XACML JSON Request results in "Indeterminate" [Couldn't find AttributeDesignator attribute]

I am try to send a JSON request to wso2 entitlement endpoint using POSTMAN
Here is my published policy in the identity server:
<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="samplePolicy" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides" Version="1.0">
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">
read
</AttributeValue>
<AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule Effect="Permit" RuleId="permit"/>
Here is JSON request I send:
{
"Request": {
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "read"
}
]
},
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "http://127.0.0.1/service/very_secure/"
}
]
}
}
}
Both blocks of the code came from this blog
https://medium.com/#gdrdabarera/how-entitlement-management-works-with-rest-api-via-xacml-in-wso2-identity-server-5-3-0-7a60940d040c#.4lxgiw6tn
But no matter what I tried it always give me "Indeterminate" response
Postman response screenshot
I also try my own policy and request but I always get the same response
What is going on?
Fixed with: Remove any white space before and after the "read" attribute value in the xml policy:
<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="samplePolicyforJSON" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides" Version="1.0">
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
<AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule Effect="Permit" RuleId="permit"></Rule>
</Policy>
Tested with:
XACML Request:
{
"Request": {
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "read"
}
]
},
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "http://127.0.0.1/service/very_secure/"
}
]
}
}
}
XACML Response:
{
"Response": [
{
"Decision": "Permit",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
}
}
]
}
And with:
XACML Request:
<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">http://localhost/secureAccess/resource</AttributeValue>
</Attribute>
</Attributes>
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
</Attribute>
</Attributes>
</Request>
XACML Response:
<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
<Result>
<Decision>Permit</Decision>
<Status>
<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
</Status>
</Result>
</Response>
If you followed all the steps correctly, It should work.
After adding the policy, please check whether the policy is correctly added.
eg. Remove unnecessary spaces in the policy
Publish it to the PDP correctly and try. You can also try in "try" option in the policy window in IS 5.3.0. Use only xml request because it does not works for JSON

Aggregate multiple json responses with aggregate mediator in wso2 esb

I have defined a api in wso2 esb and it calls two internal APIs through recepient list and which are passing json responses as follows.(sample responses)
{
"name": "api1",
"response": "success",
"status": "1"
}
and
{
"name": "api2",
"response": "unsuccess",
"status": "2"
}
I need to pass the response by aggregating both of these responses as a single response. I red about payloadfactory and able to construct aggregated response. But i need to aggregate whatever the responses coming from these 2 apis and generate response as one single json object and pass by including both of these responses as follows
{
"response1": {
"name": "api1",
"response": "success",
"status": "1"
},
"response2": {
"name": "api2",
"response": "unsuccess",
"status": "2"
}
}
so how can a accomplish with WSO2ESB. I'm using latest version of ESB.
I have created three APIs and aggregated the API responses using Clone ,Below is my API which is used for aggregating responses of two API endpoints
<api xmlns="http://ws.apache.org/ns/synapse" name="aggregateResponse" context="/aggregate">
<resource methods="POST">
<inSequence>
<clone id="aggr">
<target>
<sequence>
<call>
<endpoint>
<http method="GET" uri-template="http://localhost:8280/getresponse1"/>
</endpoint>
</call>
<log>
<property name="Logger1" expression="json-eval($.)"/>
</log>
</sequence>
</target>
<target>
<sequence>
<call>
<endpoint>
<http method="GET" uri-template="http://localhost:8280/getResponse2"/>
</endpoint>
</call>
<log>
<property name="Logger1" expression="json-eval($.)"/>
</log>
</sequence>
</target>
</clone>
<payloadFactory media-type="json">
<format>{"responses":{ "name":"$1","response":"$2","status":"$3"}}</format>
<args>
<arg evaluator="json" expression="$.name"/>
<arg evaluator="json" expression="$.response"/>
<arg evaluator="json" expression="$.status"/>
</args>
</payloadFactory>
<loopback/>
</inSequence>
<outSequence>
<property name="res" scope="default">
<ResponseDetail xmlns=""/>
</property>
<aggregate id="aggr">
<completeCondition>
<messageCount min="-1" max="-1"/>
</completeCondition>
<onComplete expression="$body//responses" enclosingElementProperty="res">
<payloadFactory media-type="json">
<format>{"response1":$1 ,"response2":$2}</format>
<args>
<arg evaluator="json" expression="$.ResponseDetail.responses[0]"/>
<arg evaluator="json" expression="$.ResponseDetail.responses[1]"/>
</args>
</payloadFactory>
<send/>
</onComplete>
</aggregate>
</outSequence>
</resource>
</api>
API 1:
<api xmlns="http://ws.apache.org/ns/synapse" name="response1" context="/getresponse1">
<resource methods="GET">
<inSequence>
<payloadFactory media-type="json">
<format>{ "name": "api1", "response": "success", "status": "1"}</format>
<args/>
</payloadFactory>
<respond/>
</inSequence>
</resource>
</api>
API 2:
<api xmlns="http://ws.apache.org/ns/synapse" name="response2" context="/getResponse2">
<resource methods="GET">
<inSequence>
<payloadFactory media-type="json">
<format>{ "name": "api2", "response": "unsuccess", "status": "2"}</format>
<args/>
</payloadFactory>
<respond/>
</inSequence>
</resource>
</api>
Well, this is where enrich mediator becomes handy. Please try this out. I have not tested this since I am not doing WSO2 related stuffs now. But your feedback is warmly welcome. The pseudo code is something like this.
<call>
<endpoint>
<http method="GET" uri-template="http://www.mocky.io/v2/some-ep"/>
</endpoint>
</call>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="first-json"/>
</enrich>
<call>
<endpoint>
<http method="GET" uri-template="http://www.mocky.io/v2/another-ep"/>
</endpoint>
</call>
<enrich>
<source type="property" property="first-json" clone="true"/>
<target action="sibling" xpath="//"/>
</enrich>
</respond>

How to concatenate two JSON responses in wso2 esb

The two jsons i need to concatenate to convert it into a single valid json are :
{
"first": true,
"second": {
"name": "manoj",
"age": "45"
},
"third": {
"fourth": [{
"class": "test12",
"salary": "123456"
},
{
"class": "test23",
"salary": "15678"
}
],
"fifth": "hello"
}
}
and
[{
"item1": "123456",
"item2": "5678"
},
{
"item1": "8976",
"item2": "abcd"
}]
Is it possible to concatenate these two without using any jquery. I need something related to wso2 esb code. I tried using enrich and other mediators but no luck so far.
You can concat the jsons using WSO2 ESB Payload Factory mediator as follows,
<api xmlns="http://ws.apache.org/ns/synapse" name="ConcatAPI" context="/concat">
<resource methods="GET">
<inSequence>
<call>
<endpoint>
<http method="GET" uri-template="http://www.mocky.io/v2/56b2d88c13000057518945d4"/>
</endpoint>
</call>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="first-json"/>
</enrich>
<log level="custom">
<property name="First json" expression="get-property('first-json')"/>
</log>
<call>
<endpoint>
<http method="GET" uri-template="http://www.mocky.io/v2/56b2d87d1300007c518945d3"/>
</endpoint>
</call>
<payloadFactory media-type="xml">
<format>
<completeJson xmlns="">
<firstjson>$1</firstjson>
<secondjson>$2</secondjson>
</completeJson>
</format>
<args>
<arg evaluator="xml" expression="get-property('first-json')"/>
<arg evaluator="xml" expression="$body"/>
</args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<send/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Note that i have retrieved your jsons from mocked services from mocky.io web site.
Thanks.