Unable to get response in JSON format after aggregation in WSO2 ESB -


i have proxy service search user in multiple systems , should return combined responses in json format.i responses combined instead of getting in json format responses in xml format. can see json responses in wso2 server logs below:

[2016-07-19 07:26:58,249]  info - logmediator to: http://www.w3.org/2005/08/addr essing/anonymous, wsaction: , soapaction: , messageid: urn:uuid:895c4303-6de5-49 88-a4d1-c06275582841, direction: response, component = application2, payload: { "findusers":[ {"id":"20","add_state":"0","remove_state":"0","supervisor_id_name":"","idc_id":" 3","backup_supervisor_name":"","backup_supervisor":"","business_unit_id":"","com pany":"companyb","creation_date":"2016-05-11 18:02:42.0","deletion_date":"","dep artment":"922","display_name":"kevin mollo (companyb)","email_address":"kevin.mo llo@companyb.com","exception_count":"","first_name":"kevin","is_terminated":"fal se","job_status":"active","last_name":"mollo","legacy_employee_id":"171352","sup ervisor_id":"","termination_date":"","title":"broadband technician","unique_id": "9000070","user_id":"user71","violation_count":""} ] } [2016-07-19 07:26:58,888]  info - logmediator to: http://www.w3.org/2005/08/addr essing/anonymous, wsaction: , soapaction: , messageid: urn:uuid:0cee9dc3-b6e6-48 81-9bdd-a89ec22999a7, direction: response, component = application1, payload: {"vi ewableidentityattributes":{"email":"kevin.mollo@companyb.com","cn":"kevin mollo" ,"last name":"mollo","first name":"kevin"},"assignedroles":[],"listattributes":[ "first name","last name","email","cn"]} 

however, don't response in json format after calling proxy url. below esb configuration:

<?xml version="1.0" encoding="utf-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse"        name="sprsapproxy"        transports="http,https"        statistics="disable"        trace="disable"        startonload="true">    <target>       <insequence>          <log/>          <clone>             <target>                <sequence>                   <property name="application" value="application1"/>                   <property name="messagetype"                             value="application/xacml+json"                             scope="axis2"                             type="string"/>                   <property name="authorization"                             expression="fn:concat('basic ', base64encode('username:password'))"                             scope="transport"/>                   <send>                      <endpoint>                         <address uri="http://hostname1:8080/identityiq/rest/identities/9000070"/>                      </endpoint>                   </send>                </sequence>             </target>             <target>                <sequence>                   <property name="application" value="application2"/>                   <property name="messagetype"                             value="application/json"                             scope="axis2"                             type="string"/>                   <send>                      <endpoint>                         <address uri="http://hostname2:8080/aveksa/command.submit?cmd=findusers&amp;format=json&amp;unique_id=9000070"/>                      </endpoint>                   </send>                </sequence>             </target>          </clone>       </insequence>       <outsequence>          <log level="full" description="">             <property name="component" expression="get-property('application')"/>          </log>          <aggregate>             <completecondition>                <messagecount min="2"/>             </completecondition>             <oncomplete expression="/">                <property name="messagetype"                          value="application/xacml+json"                          scope="axis2"                          type="string"                          description="messagetype"/>                <enrich>                   <source clone="true" xpath="/"/>                   <target type="body"/>                </enrich>                <send/>             </oncomplete>          </aggregate>       </outsequence>       <faultsequence>          <log level="full" category="warn"/>       </faultsequence>    </target>    <description/> </proxy> 

i response below:

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:header/><soapenv:body><jsonobject><findusers><id>20</id><add_state>0</add_state><remove_state>0</remove_state><supervisor_id_name></supervisor_id_name><idc_id>3</idc_id><backup_supervisor_name></backup_supervisor_name><backup_supervisor></backup_supervisor><business_unit_id></business_unit_id><company>companyb</company><creation_date>2016-05-11 18:02:42.0</creation_date><deletion_date></deletion_date><department>922</department><display_name>kevin mollo (companyb)</display_name><email_address>kevin.mollo@companyb.com</email_address><exception_count></exception_count><first_name>kevin</first_name><is_terminated>false</is_terminated><job_status>active</job_status><last_name>mollo</last_name><legacy_employee_id>171352</legacy_employee_id><supervisor_id></supervisor_id><termination_date></termination_date><title>broadband technician</title><unique_id>9000070</unique_id><user_id>user71</user_id><violation_count></violation_count></findusers></jsonobject><soapenv:envelope><soapenv:header/><soapenv:body><jsonobject><viewableidentityattributes><email>kevin.mollo@companyb.com</email><cn>kevin mollo</cn><last name>mollo</last name><first name>kevin</first name></viewableidentityattributes><listattributes>first name</listattributes><listattributes>last name</listattributes><listattributes>email</listattributes><listattributes>cn</listattributes></jsonobject></soapenv:body></soapenv:envelope></soapenv:body></soapenv:envelope> 

please let me know how can json response. appreciated.

you can set messagetype application/json instead of application/xacml+json in outsequence , try.

<property name="messagetype" value="application/json" scope="axis2" type="string" description="messagetype"/> 

also there no application/xacml+json message formatters , message builders shipped wso2 esb default. if need use these formats have write own formatters , builders , configure them in axis2.xml file.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -