When i tried to use the data mapper mediator I always get an error. I tried mapping the json response to xml.
[2016-07-14 14:05:26,684] ERROR - omdbapi DataMapper mediator : mapping failed
XML not well-formed. Error occurred while processing start element event
at org.wso2.carbon.mediator.datamapper.engine.input.readers.XMLReader.read(XMLReader.java:97)
at org.wso2.carbon.mediator.datamapper.engine.input.InputModelBuilder.buildInputModel(InputModelBuilder.java:52)
at org.wso2.carbon.mediator.datamapper.engine.core.mapper.MappingHandler.doMap(MappingHandler.java:59)
at org.wso2.carbon.mediator.datamapper.DataMapperMediator.transform(DataMapperMediator.java:244)
at org.wso2.carbon.mediator.datamapper.DataMapperMediator.mediate(DataMapperMediator.java:209)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:83)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:49)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:160)
at org.apache.synapse.rest.Resource.process(Resource.java:320)
at org.apache.synapse.rest.API.process(API.java:336)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:120)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:100)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:55)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:541)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:179)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:252)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
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)
Here is my api. I just use the omdbapi to give an example.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/omdbapi" name="omdbapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/*">
<inSequence>
<send>
<endpoint>
<address trace="disable" uri="http://www.omdbapi.com/"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<datamapper config="gov:datamapper/omdbapiConfig.dmc" inputSchema="gov:datamapper/omdbapiConfig_inputSchema.json" inputType="XML" outputSchema="gov:datamapper/omdbapiConfig_outputSchema.json" outputType="XML"/>
<respond/>
</outSequence>
<faultSequence/>
</resource>
</api>
If you are trying to map JSON-> XML, you need to specify in the Data Mapper Mediator configuration.
Make sure you set the input type as JSON.
And there have been beta2 release on wso2 esb. So try using beta2 packs for esb runtime and tooling. Use the latest pack and try.
Related
Scenario
I'm using Wso2 Email Connector for sending emails to our company's smtp server. Following is the code for connection and Api
Connection
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="techlogixSmtp" xmlns="http://ws.apache.org/ns/synapse">
<email.init>
<connectionType>SMTPS</connectionType>
<password>xxxx</password>
<host>smtp.techlogix.com</host>
<requireTLS>true</requireTLS>
<port>25</port>
<name>techlogixSmtp</name>
<username>xxxx</username>
</email.init>
</localEntry>
Api
<?xml version="1.0" encoding="UTF-8"?>
<api context="/email" name="EmailMicroService" port="8290" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/send">
<inSequence>
<log level="full"/>
<email.send configKey="techlogixSmtp">
<from>{json-eval($.from)}</from>
<to>{json-eval($.to)}</to>
<subject>{json-eval($.subject)}</subject>
<content>{json-eval($.content)}</content>
<contentType>{json-eval($.contentType)}</contentType>
<attachments>{json-eval($.attachments)}</attachments>
</email.send>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Question
I'm facing the ERROR {InvokeMediator} - {api:EmailMicroService} Sequence named Value {name ='null', keyValue ='techlogixSmtp'} cannot be found. What possible configuration is missing from my end which is causing this issue?
I made sure that updated Api is deployed on MicroIntegrator
As Sanoj, mentioned your Local Entry techlogixSmtp seems not deployed to the Runtime. So in your CompositeExporter Project make sure your techlogixSmtp is checked and the correct Server Role is selected. Please refer to the following image.
We're downgrading our ESB from 5.0.0 to 4.8.1 to match a different development environment and we've hit an unexpected snag: our APIs aren't returning anything.
We were originally using the mediator, which I'm gathering was changed between 4.8.1 and 5.0.0 and cannot in the older version be used as a response so we switched to This is a resource I have set up in an effort to get a smoke test up
<resource methods="GET" uri-template="/StaticTest">
<inSequence>
<log level="full"></log>
<loopback></loopback>
</inSequence>
<outSequence>
<log level="full"></log>
<payloadFactory media-type="json">
<format>{"asdf":"fdsa","blah":3}</format>
<args></args>
</payloadFactory>
<respond></respond>
</outSequence>
</resource>
I know the resource is being hit, because the logging statements make it into the logs. In fact, placing another mediator over the respond tag will display the following
[2017-05-09 15:48:19,968] INFO - LogMediator To: ,
MessageID: urn:uuid:6376072e-d005-497e-b7a1-9f89cff49099,
Direction: response,
Envelope: <?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<jsonObject>
<asdf>fdsa</asdf>
<blah>3</blah>
</jsonObject>
</soapenv:Body>
</soapenv:Envelope>
Which I have taken the liberty of formatting a bit. As you can see a soap envelope has been made matching my static JSON object, but SOAP UI is showing nothing. I get an HTTP 200, but no content. Any idea what could cause this?
When I create proxy with send mediator with Rest service Post HTTP Method in HTTP endpoint url. Selected the endpoint as HTTP endpoint on proxy and post the request xml without soap envelop, this perfectly works and get the response in the response window.
But when I use the call mediator with the same HTTP end point url configuration, this does not works. I would like to know can we use call mediator for Post HTTP method? When I use Call mediator for the GET HTTP method which require only query parameters and does not require any request xml this works absolutely fine.
Here is the further information:
However issue is resloved by using the address endpoint in callmediator. When I Invoke the proxy from external Restt client ot Soap UI, it does works. If I use the Try this Service option in wso2 ESB will fail with the results 1. When Soap12 endpoint is selected and 2 when HTTP end point is selected as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="postIDMPCall"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<organizationList xmlns="">
<xml content>
</organizationList>
</format>
<args/>
</payloadFactory>
<header name="_user" scope="transport" value="username"/>
<header name="_password" scope="transport" value="Password"/>
<call blocking="true">
<endpoint>
<address uri="http://<ip-address>:<port>/<resource-path>/UpdateOrganization"
format="rest"/>
</endpoint>
</call>
</inSequence>
</target>
</proxy>
Output: When soap12 endpoint is selected
Though posted the correct xml service does not recorgonize the correct xml format for soap12 endpoint.
FAILURE
Record is not processed successfully. Please Provide valid Request XML
When Http end point is selected
[2016-04-21 12:07:50,179] INFO - HTTPSender Unable to sendViaPost to url[http://://UpdateOrganization/mediate]
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
I think we can't use call mediator for this purpose because call mediator is context unaware mediator.
Your call should already perform a post out the box.
Did you try to set format="pox" if you expect simple xml as a response
I want to have a try with the new "registry" scope in ESB 4.9.0, but when I set up a simple proxy with the provided example in property mediator documentation, it cannot be saved and reports an error.
TID: [-1234] [] [2015-09-24 15:30:21,085] ERROR {org.wso2.carbon.proxyadmin.service.ProxyServiceAdmin} - Unable to save changes made for the proxy service : test_property. Restored the existing proxy... :: Only 'axis2' or 'transport' or 'axis2-client' or 'default' or 'operation' values are allowed for attribute scope for a property mediator, Unsupported scope registry {org.wso2.carbon.proxyadmin.service.ProxyServiceAdmin}
org.apache.synapse.SynapseException: Only 'axis2' or 'transport' or 'axis2-client' or 'default' or 'operation' values are allowed for attribute scope for a property mediator, Unsupported scope registry
Here is the proxy
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="test_property"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="conf:/Resource/foo" value="Sample Property Content" scope="registry"/>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
I am not sure if I need to set up some configuration first? I downloaded a new esb 4.9.0 package, and run separately. Thanks in advance!
You can retrieve properties from within the registry by using the registry scope.
<property name="fromRegistryToDefault" expression="get-property('registry','registryPath#propertyName')"/>
Documentation of retrieving properties from registry
But I don't think you can store new properties into the registry store directly from a Proxy inSequence. Do you have any documentation about that?
Version 4.9 does not allow this value for the scope of a property mediator.
Download the ESB 5.0.0 and you will see that your proxy works perfectly.
You can store in "registry" scope in this version.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="test_property"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<property name="conf:/Resource/foo"
scope="registry"
type="STRING"
value="Sample Property Content"/>
<log level="full"/>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
When I implement the scenario at http://wso2.com/library/tutorials/2013/12/lightweight-service-orchestration-for-non-blocking-backend-services-using-wso2-esb/ I get an error that says
"Proxy Service requires a valid in sequence or valid endpoint".
is there something I am missing from this demo? It seems straightforward enough. I have the latest ESB software as of today if that makes a difference. It is higher than 4.5 as the article says.
There is an error in this sample, proxy xml definition must be outside description tag :
<proxy xmlns="http://ws.apache.org/ns/synapse" name="studentRegistrationProxy" transports="https http" startonload="true" trace="disable">
<description></description>
<target>
<insequence>
<clone>
...
</clone>
</insequence>
<outsequence>
<aggregate>
...
</aggregate>
</outsequence>
<faultsequence>
</faultsequence>
</target>
</proxy>