I have a requirement to invoke an external REST service, which returns the response as a json, and write the response to a CSV file. I'm using WSO2 Smooks mediator for the conversion. I was able to get that working with a hardcoded xml payload in a proxy service insequence, but when I switch to calling the external service, I ran into some issues.
Response from external service is as follows:
[
{
"name": "aaaa",
"city": "CL",
"age": "33"
},
{
"name": "bbbb",
"city": "KD",
"age": "21"
},
{
"name": "ccc",
"city": "GL",
"age": "14"
},
{
"name": "dddd",
"city": "NE",
"age": "45"
}
]
smooks-config
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">
<params>
<param name="stream.filter.type">SAX</param>
<param name="default.serialization.on">true</param>
</params>
<json:reader rootName="json" keyWhitspaceReplacement="_">
<json:keyMap>
<json:key from="date&time" to="date_and_time" />
</json:keyMap>
</json:reader>
<resource-config selector="json">
<resource>org.milyn.delivery.DomModelCreator</resource>
</resource-config>
<ftl:freemarker applyOnElement="json">
<ftl:template>
<!--
<#ftl ns_prefixes={"D":"http://ws.apache.org/ns/synapse"}>${json.name},${json.city},${json.age}
-->
</ftl:template>
<param name="quote">"</param>
<param name="includeFieldNames">true</param>
<param name="csvFields">name,city,age</param>
<param name="seperator">,</param>
<param name="messageType">CSV</param>
<param name="templateDataProvider">input</param>
</ftl:freemarker>
</smooks-resource-list>
Proxy service snippet
<inSequence>
<log level="full">
<property name="STATUS" value="Calling external service.."/>
</log>
<call>
<endpoint>
<http method="GET" uri-template="http://demo8466012.mockable.io/simpleuserdata"/>
</endpoint>
</call>
<log level="full"/>
<smooks config-key="conf:/smooks-csv-config.xml">
<input type="xml"/>
<output type="text"/>
</smooks>
<log level="custom">
<property name="STATUS" value="PROCESSED MSG******"/>
</log>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
<property name="messageType" scope="axis2" value="plain/text"/>
<property name="ContentType" scope="axis2" value="plain/text"/>
<log level="full">
<property expression="//*[local-name() = 'text']/text()" name="inputContent"/>
</log>
<property expression="//*[local-name() = 'text']/text()" name="inputContent"/>
<!-- Write to CSV using a class mediator or file connector -->
</inSequence>
I couldn't figure out a correct way to write the smooks config I believe root cause is there. This is the error I'm getting.
[2021-06-08 01:29:14,345] ERROR {org.apache.synapse.registry.AbstractRegistry} - Error reading registry resource file : conf:/smooks-csv-config.xml org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "json"
at [row,col {unknown-source}]: [10,65]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMSerializableImpl.build(OMSerializableImpl.java:78)
at org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:722)
at org.apache.axiom.om.impl.llom.OMElementImpl.detach(OMElementImpl.java:700)
at org.wso2.carbon.mediation.registry.WSO2Registry.lookup(WSO2Registry.java:198)
at org.apache.synapse.registry.AbstractRegistry.getResource(AbstractRegistry.java:66)
at org.apache.synapse.config.SynapseConfiguration.getEntry(SynapseConfiguration.java:867)
at org.apache.synapse.core.axis2.Axis2MessageContext.getEntry(Axis2MessageContext.java:260)
at org.wso2.carbon.mediator.transform.SmooksMediator.createSmooksConfig(SmooksMediator.java:209)
at org.wso2.carbon.mediator.transform.SmooksMediator.mediate(SmooksMediator.java:104)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:260)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:807)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:305)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:578)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:195)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:284)
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)
Caused by: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "json"
at [row,col {unknown-source}]: [10,65]
at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:606)
at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:479)
at com.ctc.wstx.sr.InputElementStack.resolveAndValidateElement(InputElementStack.java:507)
at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2977)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2837)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1072)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 21 more
Appreciate if someone can point out the exact issue.
You are missing the JSON namespace declaration.
xmlns:json = "http://www.milyn.org/xsd/smooks/json-1.2.xsd"
Related
I am converting a csv file, where each csv record is getting converted to json. I am using an iterator mediator to send each json object to an endpoint by modifying it using payload-factory mediator. But I get this VFS error at the end. How can I fix this?
ERROR {VFSTransportSender} - Error while attaching VFS file system properties. null
[2022-07-20 19:30:46,925] ERROR {VFSTransportSender} - Unable to determine out transport information to send message
[2022-07-20 19:30:46,929] ERROR {Axis2Sender} - {proxy:TestProxy} Access-Control-Allow-Credentials:true,Access-Control-Allow-Headers:Authorization, Content-Type, fluent.account,Access-Control-Allow-Methods:POST, PUT, GET, OPTIONS, DELETE,Access-Control-Allow-Origin:*,Access-Control-Expose-Headers:flex.type, flex.version,Access-Control-Max-Age:3600,Cache-Control:no-cache, no-store, max-age=0, must-revalidate,Connection:keep-alive,Content-Type:application/json;charset=UTF-8,Date:Wed, 20 Jul 2022 14:00:47 GMT,Expires:0,Pragma:no-cache,Server:nginx/1.10.3 (Ubuntu),Transfer-Encoding:chunked,X-Content-Type-Options:nosniff,X-Frame-Options:DENY,X-XSS-Protection:1; mode=block, Unexpected error sending message back org.apache.axis2.AxisFault: Unable to determine out transport information to send message
at org.apache.axis2.transport.base.AbstractTransportSender.handleException(AbstractTransportSender.java:234)
at org.apache.synapse.transport.vfs.VFSTransportSender.writeFile(VFSTransportSender.java:331)
at org.apache.synapse.transport.vfs.VFSTransportSender.sendMessage(VFSTransportSender.java:189)
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:119)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:213)
at org.apache.synapse.mediators.builtin.RespondMediator.mediate(RespondMediator.java:46)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:263)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:820)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:322)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:608)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:207)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:298)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Synapse Configs
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="TestProxy" startOnLoad="true" transports="http https vfs" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<smooks config-key="smooks_conf">
<input type="text"/>
<output type="xml"/>
</smooks>
<log level="full"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<log>
<property expression="json-eval($)" name="Response"/>
</log>
<call-template target="Template"/>
<log>
<property name="Info" value="Before Iteration"/>
</log>
<iterate continueParent="true" expression="$body//ProductData/Product" id="Iterate-over-products" xmlns:ns="http://org.apache.synapse/xsd">
<target>
<sequence>
<log>
<property name="Info" value="Inside Iteration"/>
</log>
<payloadFactory media-type="json">
<format>
{
"ref": "$1",
"name": "$2",
"summary": "This is a HP",
"attributes": [
{
"name": "imageUrl",
"type": "STRING",
"value": "$3"
},
]
}
}
</format>
<args>
<arg evaluator="json" expression="$.Product.ProductCode" />
<arg evaluator="json" expression="$.Product.ProductName" />
<arg evaluator="json" expression="$.Product.ProductUrl"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<call>
<endpoint>
<http method="post" uri-template""=>
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<log>
<property expression="json-eval($)" name="product"/>
</log>
</sequence>
</target>
</iterate>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.vfs.Streaming">true</parameter>
<parameter name="transport.PollInterval">1</parameter>
<parameter name="transport.vfs.FileURI">file://C://in</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file://C:/out</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.csv</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file://C:/history</parameter>
</proxy>
All the logs just before the iterate mediator get printed. The flow stops from the iterate mediator and produce the VFS transport error
Since you are using a custom connector within the template I'm assuming your connector is not properly written which overrides the current message context. Hence after the connector, there is no content to Iterate over. In order to get around this issue save the message to a property after the Smooks mediator and then restore the message before the Iterate mediator. For this, You can use the Enrich Mediator.
To Save the payload
<enrich>
<source type="body"/>
<target type="property" property="jsonPayload"/>
</enrich>
To restore the payload
<enrich description="Restore original payload">
<source clone="false" property="jsonPayload" type="property"/>
<target type="body"/>
</enrich>
Additional notes: When you are using Iterate Mediator It should be always accompanied by an Aggregate mediator. You can read more about this here.
Could you please advice how to get more than one row?
My API source:
<inSequence xmlns="http://ws.apache.org/ns/synapse">
<property expression="json-eval($.vendorId)" name="vendorId" scope="default" type="STRING"/>
<dblookup>
<connection>
<pool>
<dsName>MyDS</dsName>
</pool>
</connection>
<statement>
<sql><![CDATA[select * from db_view v where v.vendorId = nvl(?, v.vendorId)]]></sql>
<parameter expression="$ctx:vendorId" type="VARCHAR"/>
<result column="vendorId" name="vendorId"/>
<result column="vendorName" name="vendorName"/>
</statement>
</dblookup>
<filter xpath="boolean($ctx:vendorId)">
<then>
<payloadFactory media-type="json">
<format>{"result": { "vendorId" : "$1","vendorName" : "$2"}}</format>
<args>
<arg evaluator="xml" expression="$ctx:vendorId" literal="false"/>
<arg evaluator="xml" expression="$ctx:vendorName" literal="false"/>
</args>
</payloadFactory>
</then>
<else>
<payloadFactory media-type="json">
<format>{"response" : { "code" : "01","message" : "fail"}}</format>
</payloadFactory>
</else>
</filter>
</inSequence>
My db view returns 5 rows, but I get only the first row from the GET request:
{"result": { "vendorId" : "123", "vendorName" : "My Vendor N1" }}
Also if I pass the parameter vendorId = 321, the api should return 0 rows. At the current moment it ALWAYS returns the first row from view. Why and how to make it work?
Thanks in advance
CALLOUT Mediator:
<resource methods="GET" uri-template="/get/supplier/{filterQuery}">
<inSequence>
<property name="operation" value="view" scope="default" type="STRING"/>
<log level="full" separator="|">
<property name="operation" expression="get-property('operation')"/>
<property name="step" value="request"/>
</log>
<property name="filterQuery" expression="get-property('uri.var.filterQuery')" scope="default" type="STRING"/>
<log level="full" separator="|">
<property name="filterQuery" expression="$ctx:filterQuery"/>
</log>
<callout serviceURL="http://...:8280/services/serviceName" action="/vendors/$ctx:filterQuery">
<source type="envelope"/>
<target key="response"/>
</callout>
<log level="custom" separator="|">
<property name="MESSAGE" expression="$ctx:response"/>
</log>
<property name="res" expression="$ctx:response" scope="default" type="OM"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>
<property name="contentType" value="application/json" scope="transport" type="STRING"/>
<payloadFactory media-type="json">
<format>{"vendorId": "$1","vendorName": "$2"}</format>
<args/>
</payloadFactory>
<log level="full" separator="|">
<property name="operation" expression="$ctx:operation"/>
<property name="step" value="response"/>
</log>
<respond/>
</inSequence>
<faultSequence>
<payloadFactory media-type="json">
<format>{"response" : {"code" : "01", "message" : "fail"}}</format>
<args/>
</payloadFactory>
</faultSequence>
</resource>
This is normal behavior. As you can read in DBLookup Mediator documentation :
The DBLookup mediator can set a property from one row in a result set. It cannot return multiple rows. If you need to get multiple records, or if you have a table with multiple parameters (such as URLs), you can use the WSO2 Data Services Server to create a data service and invoke that service from the ESB using the Callout mediator instead.
You can not use dblookup madiator as mentioned but you can use DataSources.
Brief datasource example for Get Method dataservice;
<data name="RDBMSDataService" serviceStatus="active" transports="http https local">
<config enableOData="false" id="Datasource">
<property name="driverClassName">com.mysql.jdbc.Driver</property>
<property name="url">jdbc:mysql://localhost:3306/Employees</property>
<property name="username">root</property>
<property name="password">password</property>
</config>
<resource method="GET" path="Employee/{EmployeeNumber}">
<call-query href="GetEmployeeDetails">
<with-param name="EmployeeNumber" query-param="EmployeeNumber"/>
</call-query>
</resource>
<query id="GetEmployeeDetails" useConfig="Datasource">
<sql>select EmployeeNumber, FirstName, LastName, Email, Salary from Employees where EmployeeNumber=:EmployeeNumber</sql>
<result outputType="json">{
"Employees":{
"Employee":[
{
"EmployeeNumber":"$EmployeeNumber",
"FirstName":"$FirstName",
"LastName":"$LastName",
"Email":"$Email",
"Salary":"$Salary"
}
]
}
}</result>
<param name="EmployeeNumber" sqlType="STRING"/>
</query>
</data>
You can create this .dbs file and deploy it. Then you can call this component like http://localhost:8290/services/RDBMSDataService/Employee/{EmployeeNumber} with specific parametres then it will return json :
{
"Employees": {
"Employee": [
{
"EmployeeNumber": "5012",
"FirstName": "Will",
"LastName": "Smith",
"Email": "will#smith.com",
"Salary": "13500.0"
},
{
"EmployeeNumber": "5013",
"FirstName": "Parker",
"LastName": "Peter",
"Email": "peter#parker.com",
"Salary": "15500.0"
}
]
}
}
You can take the value from context like :
<property expression="json-eval($.Employees)" name="EmployeeList" scope="default" type="STRING"/>
I'm using wso2esb 4.7.0 and wso2dss 3.0.0..I have created dataservice to update a record from table..My Dss configuration is as follows
<query id="trial_query" useConfig="default">
<sql>update muser set username=? where userid=?</sql>
<param name="username" ordinal="1" sqlType="STRING"/>
<param name="userid" ordinal="2" sqlType="BIGINT"/>
</query>
<operation name="trial_op">
<call-query href="trial_query">
<with-param name="username" query-param="username"/>
<with-param name="userid" query-param="userid"/>
</call-query>
</operation>
After that i have created a ESB configuration as :
<target>
<inSequence>
<property name="username"
expression="//username/text()"
scope="default"
type="STRING"/>
<property name="userid"
expression="//userid/text()"
scope="default"
type="STRING"/>
<log level="full"/>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<payloadFactory media-type="xml">
<format>
<p:trail_op xmlns:p="http://ws.wso2.org/dataservice">
<p:username>$1</p:username>
<p:userid>$2</p:userid>
</p:trail_op>
</format>
<args>
<arg evaluator="xml" expression="get-property('username')"/>
<arg evaluator="xml" expression="get-property('userid')"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address uri="http://192.168.1.23:9764/services/Capp_muser_dataservice/trail_op"
format="soap12"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
and this is also working..Now i wanted to add a sequence mediator in esb and It's configuration is as :
<property name="messageType" value="application/json" scope="axis2"></property>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:s="http://ws.wso2.org/dataservice" name="username" expression="get-property('username')" scope="default" type="STRING"></property>
<log>
<property name="username" value="UPDATED SUCCESSFULLY"></property>
</log>
<send></send>
I'm sending request with curl command as :
curl -v -H "Accept:application/json" -H "Content-Type:application/json" -d '{"username":"Harry","userid":"347367127872701992"}' http://youtility-desktop:8282/services/capp1
Now, he issue is when i'm adding sequence in send mediator ESB throws an error as :
ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder(AbstractOMMetaFactory.java:73)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder(AbstractOMMetaFactory.java:79)
at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLBuilderFactory.java:196)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:55)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:116)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:91)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:381)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:222)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2116)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2022)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1114)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 17 more
Still the configuration is working fine with errors too..
I have tried the same code in wso2esb 4.8.0 and wso2dss 3.1.0.Here ESB is working fine but error occurred with wso2dss 3.1.0 . It show error like:
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:username
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: Capp_muser_dataservice
Location: /Capp_muser_dataservice.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: trail_op
Current Params: {}
at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:107)
at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:112)
at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.executeInOnly(DSOMDataSource.java:80)
at org.wso2.carbon.dataservices.core.dispatch.SingleDataServiceRequest.processSingleRequest(SingleDataServiceRequest.java:127)
... 40 more
Caused by: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:username
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: Capp_muser_dataservice
Location: /Capp_muser_dataservice.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: trail_op
Current Params: {}
at org.wso2.carbon.dataservices.core.engine.CallQuery.extractParams(CallQuery.java:208)
at org.wso2.carbon.dataservices.core.engine.CallQuery.executeElement(CallQuery.java:177)
at org.wso2.carbon.dataservices.core.engine.CallQueryGroup.executeElement(CallQueryGroup.java:111)
at org.wso2.carbon.dataservices.core.engine.OutputElement.execute(OutputElement.java:89)
at org.wso2.carbon.dataservices.core.description.operation.Operation.execute(Operation.java:71)
at org.wso2.carbon.dataservices.core.engine.DataService.invoke(DataService.java:548)
at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:101)
... 43 more
Why the errors occurred? Is their any problem with soap format during send mediator or i have to add some properties in esb configuration?What should i do to resolve this issue?Please let me know..
I'm using wso2esb 4.7.0 and wso2dss 3.0.0.I have created a dataservice to update table in wso2dss and it's working fine.Now i have called this service in wso2esb via send mediator as:
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="username"
expression="//username/text()"
scope="default"
type="STRING"/>
<property name="userid"
expression="//userid/text()"
scope="default"
type="STRING"/>
<log>
<property name="username" expression="get-property('username')"/>
<property name="userid" expression="get-property('userid')"/>
</log>
<payloadFactory media-type="xml">
<format>
<p:trail_op xmlns:p="http://ws.wso2.org/dataservice">
<p:username>$1</p:username>
<p:userid>$2</p:userid>
</p:trail_op>
</format>
<args>
<arg evaluator="xml" expression="get-property('username')"/>
<arg evaluator="xml" expression="get-property('userid')"/>
</args>
</payloadFactory>
<header name="Action" value=""/>
<property name="SOAPAction" value="" scope="transport"/>
<send>
<endpoint>
<address uri="http://192.168.1.23:9764/services/Capp_muser_dataservice/"
format="soap12"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
This is also working fine..The issue occurred when i'm calling a sequence in send mediator like :
<send receive="Capp_Login_seq1">
<endpoint>
<address uri="http://192.168.1.23:9764/services/Capp_muser_dataservice/"
format="soap11"/>
</endpoint>
</send>
My request is :
curl -v -H "Accept:application/json" -H "Content-Type:application/json" -d '{"username":"sps","userid":"337217709387286044"}' http://youtility-desktop:8282/services/Capp_LoginProxy
It shows error in esb :
ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder(AbstractOMMetaFactory.java:73)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder(AbstractOMMetaFactory.java:79)
at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLBuilderFactory.java:196)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:55)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:116)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:91)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:62)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:232)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:443)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:222)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2116)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2022)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1114)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 20 more
Is it issue of soap request or anything else?
please let me know..
Remove the endpoint format and check.
I'm using wso2esb 4.7.0 and wso2dss 3.0.0..I have written a query in wso2dss.It's working fine in dss. also but when i wish to work with wso2esb in sequence mediator it shows error as above
ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder(AbstractOMMetaFactory.java:73)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder(AbstractOMMetaFactory.java:79)
at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLBuilderFactory.java:196)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:55)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:116)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:91)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:62)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:232)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:443)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:222)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2116)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2022)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1114)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 20 more
.
.
My proxy service is :
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="username"
expression="//username/text()"
scope="default"
type="STRING"/>
<property name="userid"
expression="//userid/text()"
scope="default"
type="STRING"/>
<log>
<property name="username" expression="get-property('username')"/>
<property name="userid" expression="get-property('userid')"/>
</log>
<payloadFactory media-type="xml">
<format>
<p:trail_op xmlns:p="http://ws.wso2.org/dataservice">
<p:username>$1</p:username>
<p:userid>$2</p:userid>
</p:trail_op>
</format>
<args>
<arg evaluator="xml" expression="get-property('username')"/>
<arg evaluator="xml" expression="get-property('userid')"/>
</args>
</payloadFactory>
<header name="Action" value=""/>
<property name="SOAPAction" value="" scope="transport"/>
<send receive="Capp_Login_seq1">
<endpoint>
<address uri="http://192.168.1.23:9764/services/Capp_muser_dataservice/"
format="soap12"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
and sequence is:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="Capp_Login_seq1">
<property name="messageType" value="application/json" scope="axis2"/>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:s="http://ws.wso2.org/dataservice" name="userid" expression="get-property('userid')" scope="default" type="STRING"/>
<log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="userid" expression="get-property('userid')"/>
</log>
<send/>
</sequence>
I'm sending request like:
curl -v -H "Accept:application/json" -H "Content-Type:application/json" -d '{"username":"Harry","userid":"347367127872701992"}' http://youtility-desktop:8282/services/Capp_LoginProxy
How should i fix the error? Please let me know..
I got the same issue in ESB 5 and DAS 3. It could get fixed by adding relevant messageFormatters and messageBuilders in axis2.xml located in esb/repository/conf/axis2.xml
In my scenario, these two entries were added to axis2.xml
messageFormatter contentType="text/html"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
messageBuilder contentType="text/html" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>