Mule loses payload after data mapper call - csv

I am using Mule 3.6.1 and have a flow that reads a CSV file and then splits the file and passes in each record to the datamapper. I can see that the record is present prior to data mapper but once the message leaves the datamapper, the payload is empty.
How can I fix this? Please note that the Choice will have 3 possible datamappers to select in the completed flow.
The flow is:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:amqp="http://www.mulesoft.org/schema/mule/amqp" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd">
<context:property-placeholder location="mule-app.properties" />
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<import class="org.mule.util.StringUtils" />
<import class="org.mule.util.ArrayUtils" />
</expression-language>
</configuration>
<data-mapper:config name="test_mapper" transformationGraphPath="csv_to_json_1.grf" doc:name="test_mapper"/>
<flow name="read-file" >
<file:inbound-endpoint path="${file.unprocessed.location}" moveToPattern="#[message.inboundProperties['originalFilename']]" moveToDirectory="${file.processed.location}" responseTimeout="10000" doc:name="Files" mimeType="text/csv" >
<file:filename-regex-filter pattern="test.csv" caseSensitive="true"/>
</file:inbound-endpoint>
<object-to-string-transformer doc:name="Object to String"/>
<splitter expression="#[rows=StringUtils.split(message.payload,'\n\r'); ArrayUtils.subarray(rows,1,rows.size())]" doc:name="Splitter"/>
<set-property propertyName="testFilename" value="#[flowVars.originalFilename]" doc:name="Set Filename"/>
<choice doc:name="Choice">
<when expression="#[message.outboundProperties.'testFilename'=='test.csv']">
<data-mapper:transform config-ref="CSV_To_JSON" doc:name="CSV To JSON"/>
</when>
<otherwise>
<logger level="INFO" doc:name="Logger"/>
</otherwise>
</choice>
<object-to-string-transformer doc:name="Object to String"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
and CSV input file:
DeptID,Dept,Staff
5LL/A,Human Resources,4.00
and GRF file showing data mappings:
<?xml version="1.0" encoding="UTF-8"?><Graph __version="3.5.0" author="" created="Wed May 25 14:20:34 BST 2016" description="CSV To JSON" guiVersion="3.4.4.P" id="1464184235950" licenseCode="Unlicensed" licenseType="Unknown" modified="Wed May 25 14:20:34 BST 2016" modifiedBy="" name="CSV_To_JSON" preview-file="C:/test.csv" revision="1.0" showComponentDetails="false">
<Global>
<Metadata __referenceCounter="1" _dataStructure="SINGLE_DIMENSIONAL_COLLECTION" _type="Input" id="f79c6373-b266-4a78-91c9-3a731304eef1">
<Record fieldDelimiter="," name="test" recordDelimiter="\n\\|\r\n\\|\r" type="delimited">
<Field containerType="SINGLE" label="DeptID" name="DeptID" size="10" type="string"/>
<Field containerType="SINGLE" label="Dept" name="Dept" size="10" type="string"/>
<Field containerType="SINGLE" eofAsDelimiter="true" label="Staff" name="Staff" size="10" type="string"/>
<Field __artificialType="_id" auto_filling="global_row_count" name="__id" type="long"/>
</Record>
</Metadata>
<Metadata __index="0" __referenceCounter="1" __sourcePath="{}/test" _dataStructure="SINGLE_DIMENSIONAL_COLLECTION" _id="__id" _type="Output" id="4b092da3-e786-4f90-8e22-d9d5e8d7a7b1">
<Record fieldDelimiter="," name="test" recordDelimiter="\n\\|\r\n\\|\r" type="delimited">
<Field __artificialType="_id" __systemManaged="true" name="__id" type="string"/>
<Field __index="1" __sourcePath="{}/test/Dept" containerType="SINGLE" label="Dept" name="Dept" type="string"/>
<Field __index="0" __sourcePath="{}/test/DeptID" containerType="SINGLE" label="DeptID" name="DeptID" type="string"/>
<Field __index="2" __sourcePath="{}/test/Staff" containerType="SINGLE" label="Staff" name="Staff" type="string"/>
</Record>
</Metadata>
<Dictionary>
<Entry id="DictionaryEntry0" input="true" name="inputPayload" output="false" type="object"/>
<Entry id="DictionaryEntry1" input="false" name="outputPayload" output="true" type="object"/>
</Dictionary>
</Global>
<Phase number="0">
<Node charset="UTF-8" enabled="enabled" fileURL="dict:inputPayload" guiName="CSV READER" guiX="20" guiY="20" id="DATA_READER0" quoteCharacter="both" quotedStrings="true" skipRows="1" trim="true" type="DATA_READER">
<attr name="_data_format"><![CDATA[CSV]]></attr>
<attr name="__dataSourceDefinition"><![CDATA[C:/test.csv]]></attr>
</Node>
<Node enabled="enabled" guiName="Foreach 'test' -> 'test'" guiX="460" guiY="20" id="FOREACH_TEST_TEST" transformClass="com.mulesoft.datamapper.transform.MelRecordTransform" type="REFORMAT">
<attr name="melScript"><![CDATA[//MEL
//START -> DO NOT REMOVE
output.__id = num2str(input.__id);
//END -> DO NOT REMOVE
output.DeptID = input.DeptID;
output.Dept = input.Dept;
output.Staff = input.Staff;
]]></attr>
</Node>
<Node cacheInMemory="true" charset="UTF-8" enabled="enabled" fileURL="dict:outputPayload" guiName="JSON WRITER" guiX="900" guiY="20" id="JSON_WRITER0" type="JSON_WRITER">
<attr name="mapping"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<clover:collection clover:name="test" xmlns:clover="http://www.cloveretl.com/ns/xmlmapping">
<item clover:inPort="0">
<DeptID>$0.DeptID</DeptID>
<Dept>$0.Dept</Dept>
<Staff>$0.Staff</Staff>
</item>
</clover:collection>]]></attr>
<attr name="_data_format"><![CDATA[JSON]]></attr>
</Node>
<Edge debugMode="true" fromNode="DATA_READER0:0" guiBendpoints="" id="Edge0" inPort="Port 0 (in)" metadata="f79c6373-b266-4a78-91c9-3a731304eef1" outPort="Port 0 (output)" toNode="FOREACH_TEST_TEST:0"/>
<Edge debugMode="true" fromNode="FOREACH_TEST_TEST:0" guiBendpoints="" id="Edge1" inPort="Port 0 (in)" metadata="4b092da3-e786-4f90-8e22-d9d5e8d7a7b1" outPort="Port 0 (out)" toNode="JSON_WRITER0:0"/>
</Phase>
</Graph>

In the splitter your are already stripping of the header.
In DataMapper you have the option 'Rows to Ignore' set to "1".
Set that to "0", or change the expression in your splitter.
Because now you tell DataMapper to ignore your one and only row!

You are ignoring the row coming into the datamapper and hence there is no mapping being done remove "rows to ignore".Then the mapper will work on the row coming inside

Related

ESB WSO2 - Connecting to a local MySQL database ["Registry entry defined with key: com.mysql.jdbc.Driver not found"]

First of all I want to say that I'm a beginner with ESB WSO2.
I want to connect to a MySQL DataBase and I get this error:
"Error DB Mediator datasource: null.Registry entry defined with key: com.mysql.jdbc.Driver not found."
"DataSource: null was not initialized for given JNDI properties"
This is my code:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/api/dbtask" name="api.dbtask" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence>
<dblookup>
<connection>
<pool>
<driver key="com.mysql.jdbc.Driver"/>
<url key="jdbc:mysql://localhost:3306/utilizatori"/>
<user key="root"/>
<password key="1234"/>
</pool>
</connection>
<statement>
<sql><![CDATA[SELECT * FROM people WHERE id=1;]]></sql>
<parameter expression="//m0:getQuote/m0:request/m0:symbol" type="VARCHAR" xmlns:m0="https://services.samples"/>
<result column="nume" name="nume"/>
</statement>
</dblookup>
<!--
<log level="custom">
<property name="ID" expression="get-property('id')" />
<property name="NAME" expression="get-property('nume')" />
<property name="AGE" expression="get-property('varsta')" />
</log>
-->
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
There is an issue with the connection pool you have added. The above format is used to get the configuration values from the registry [1],[2]. If you want to define the connection pool inline you need to use the following format [3].
<dblookup xmlns="http://ws.apache.org/ns/synapse">
<connection>
<pool>
<driver>org.apache.derby.jdbc.ClientDriver</driver>
<url>jdbc:derby://localhost:1527/esbdb;create=false</url>
<user>esb</user>
<password>esb</password>
</pool>
</connection>
<statement>
<sql><![CDATA[select * from company where name =?]]></sql>
<parameter expression="//m0:getQuote/m0:request/m0:symbol" type="VARCHAR" xmlns:m0="http://services.samples/xsd"/>
<result column="id" name="company_id"/>
</statement>
</dblookup>
[1]-https://docs.wso2.com/display/EI640/Managing+the+Registry
[2]-https://ei.docs.wso2.com/en/7.2.0/micro-integrator/references/mediators/dBLookup-Mediator/#connection-pool-configurations
[3]-https://ei.docs.wso2.com/en/7.2.0/micro-integrator/references/mediators/dBLookup-Mediator/#example

How to retreive data from xml using mysql extract value function

I want to retreive ReferenceNumber value present in
I have used the following query and I am getting empty result
SELECT EXTRACTVALUE('<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DCRequest xmlns="http://hello.com/dc/extsvc"> <Authentication type="Ond"> <UserId>hello</UserId> <Password>345545</Password> </Authentication> <RequestInfo> <SolutionSetId>1617</SolutionSetId> <SolutionSetVersion>85</SolutionSetVersion> <ExecutionMode>NewWithContext</ExecutionMode> <EnvironmentId>1</EnvironmentId> </RequestInfo> <Fields> <Field key="ApplicationData"> <![CDATA[<ApplicationData> <SkipFlag>false</SkipFlag> <Purpose>05</Purpose> <ReferenceNumber>1741759</ReferenceNumber> <SkipDSTuNtcFlag>false</SkipDSTuNtcFlag> <SkipDSTuIDVisionFlag>true</SkipDSTuIDVisionFlag> </ApplicationData>]]]]>> </Field> <Field key="Applicants"> <![CDATA[<Applicants> <Applicant> <ApplicantType>Main</ApplicantType> <ApplicantFirstName>rishi</ApplicantFirstName> <DateOfBirth>16061988</DateOfBirth> <Gender>2</Gender> <Emails> <Email> <EmailId>rishi543ta88#gmail.com</EmailId> <EmailIdType>02</EmailIdType> </Email> </Emails> <Telephones> <Telephone> <TelephoneNumber>76434475257</TelephoneNumber> <TelephoneType>01</TelephoneType> </Telephone> </Telephones> <Identifiers> <Identifier> <IdNumber>AMRPG4334N</IdNumber> <IdType>01</IdType> </Identifier> </Identifiers> <Addresses> <Address> <AddressLine1>43434345 road</AddressLine1> <City>Mumbai West</City> <PinCode>4005080</PinCode> <AddressType>052</AddressType> <ResidenceType>502</ResidenceType> <StateCode>257</StateCode> </Address> </Addresses> </Applicant> </Applicants>]]]]>> </Field> </Fields> </DCRequest>','/Fields/Field/ReferenceNumber')
First get all child of <Field key="ApplicationData">, then search for ReferenceNumber.
So you Need this:
SELECT EXTRACTVALUE(t, '//ReferenceNumber') AS ReferenceNumber FROM (
SELECT EXTRACTVALUE(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DCRequest xmlns="http://hello.com/dc/extsvc"> <Authentication type="Ond"> <UserId>hello</UserId> <Password>345545</Password> </Authentication> <RequestInfo> <SolutionSetId>1617</SolutionSetId> <SolutionSetVersion>85</SolutionSetVersion> <ExecutionMode>NewWithContext</ExecutionMode> <EnvironmentId>1</EnvironmentId> </RequestInfo> <Fields> <Field key="ApplicationData"> <![CDATA[<ApplicationData> <SkipFlag>false</SkipFlag> <Purpose>05</Purpose> <ReferenceNumber>1741759</ReferenceNumber> <SkipDSTuNtcFlag>false</SkipDSTuNtcFlag> <SkipDSTuIDVisionFlag>true</SkipDSTuIDVisionFlag> </ApplicationData>]]]]>> </Field> <Field key="Applicants"> <![CDATA[<Applicants> <Applicant> <ApplicantType>Main</ApplicantType> <ApplicantFirstName>rishi</ApplicantFirstName> <DateOfBirth>16061988</DateOfBirth> <Gender>2</Gender> <Emails> <Email> <EmailId>rishi543ta88#gmail.com</EmailId> <EmailIdType>02</EmailIdType> </Email> </Emails> <Telephones> <Telephone> <TelephoneNumber>76434475257</TelephoneNumber> <TelephoneType>01</TelephoneType> </Telephone> </Telephones> <Identifiers> <Identifier> <IdNumber>AMRPG4334N</IdNumber> <IdType>01</IdType> </Identifier> </Identifiers> <Addresses> <Address> <AddressLine1>43434345 road</AddressLine1> <City>Mumbai West</City> <PinCode>4005080</PinCode> <AddressType>052</AddressType> <ResidenceType>502</ResidenceType> <StateCode>257</StateCode> </Address> </Addresses> </Applicant> </Applicants>]]]]>> </Field> </Fields> </DCRequest>',
'DCRequest/Fields/Field[1]'
) AS t
) AS t1

SoapUI generates JSON property for namespace

I generate a WADL with CXF as described in CXF – Missing WADL method parameter element types with JSON JAX-RS services.
I tried to generate the JSON request body in SoapUI ("Recreates a default representation from the schema"), but I get the wrong JSON including namespace.
Code:
CXF configuration:
<bean id="wadlGenerator" class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
<property name="linkJsonToXmlSchema" value="true" />
</bean>
<jaxrs:server address="/rest/1" id="test" staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref bean="testResource" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider" />
<ref bean="wadlGenerator" />
</jaxrs:providers>
</jaxrs:server>
WADL:
<?xml version="1.0"?>
<application xmlns:prefix1="http://www.test.com/test" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://wadl.dev.java.net/2009/02">
<grammars>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.test.com/test" targetNamespace="http://www.test.com/test" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:import/>
<xs:element name="testModel" type="testModel"/>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.test.com/test" targetNamespace="http://www.test.com/test" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:complexType name="testModel">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="name" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</grammars>
<resources base="http://localhost:8080/test-app/services/rest/1">
<resource path="/test">
<method name="POST">
<request>
<representation mediaType="application/json" element="prefix1:testModel"/>
</request>
<response status="204"/>
</method>
</resource>
</resources>
</application>
JSON:
{
"#xmlns:test": "http://www.test.com/test",
"id": "?",
"name": "?"
}
Is that a bug/missing feature of SoapUI or is there something wrong with my WADL?

WSO2 ESB - XML to MySQL Database

I need a solution for a problem:
I just tried this example for the WSO2 ESB and it is working:
http://wso2.org/library/articles/2011/01/wso2-esb-example-file-processing
But I like to use an XML file as input and write this to a MySQL-DB.
The XML-file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Name>word</Name>
<Surname>processor</Surname>
<Phone>12333</Phone>
</soapenv:Body>
</soapenv:Envelope>
If i put this into my "in"-folder the file will be moved to the "out"-folder, but nothing is written into the database. There is no error message.
My Proxy-Service:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="FileProxy" transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<clone>
<target sequence="fileWriteSequence"/>
<target sequence="databaseSequence"/>
</clone>
</inSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">15</parameter>
<parameter name="transport.vfs.MoveAfterProcess">C:/wso2esb/testordner/out</parameter>
<parameter name="transport.vfs.FileURI">C:/wso2esb/testordner/in</parameter>
<parameter name="transport.vfs.MoveAfterFailure">C:/wso2esb/testordner/error</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
<parameter name="transport.vfs.ContentType">text/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<description></description>
</proxy>
And my Sequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse"
name="databaseSequence"
trace="enable"
statistics="enable">
<log level="full">
<property name="sequence" value="before-smooks"/>
</log>
<smooks config-key="smooks">
<input type="xml"/>
<output type="xml"/>
</smooks>
<log level="full">
<property name="sequence" value="after-smooks"/>
</log>
<log level="full">
<property xmlns:ns="http://org.apache.synapse/xsd"
name="name"
expression="//csv-record/name/text()"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="surname"
expression="//csv-record/surname/text()"/>
<property name="phone" value="//csv-record/phone/text()"/>
</log>
<iterate xmlns:ns2="http://org.apache.synapse/xsd"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:sec="http://secservice.samples.esb.wso2.org"
expression="//csv-set/csv-record">
<target>
<sequence>
<log level="full">
<property name="State" value="Iteration"/>
</log>
<log level="full" category="DEBUG"/>
<dbreport>
<connection>
<pool>
<password>passwort</password>
<user>esb</user>
<url>jdbc:mysql://localhost:3306/</url>
<driver>com.mysql.jdbc.Driver</driver>
</pool>
</connection>
<statement>
<sql>insert into info.info (name, surname, phone) values (?, ?, ?)</sql>
<parameter expression="//csv-record/name/text()" type="VARCHAR"/>
<parameter expression="//csv-record/surname/text()" type="VARCHAR"/>
<parameter expression="//csv-record/phone/text()" type="VARCHAR"/>
</statement>
</dbreport>
</sequence>
</target>
</iterate>
<log level="full" category="DEBUG"/>
</sequence>
I thought this would be a simple problem, but I'm not able to get it...
Like I said, it's working with a normal text-file, but not with XML. I tried different thinks and have no idea what else I could try...
Does someone know what's my mistake?
Update:
The log from the console:
[2013-04-12 09:35:55,687] INFO - DBReportMediator Successfully created data source for jdbc:mysql://localhost:3306/.
[2013-04-12 09:36:10,170] INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:
2CBD1753113A1373101365752170177, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope x
mlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
<Name>word</Name>
<Surname>processor</Surname>
<Phone>12333</Phone>
</soapenv:Body></soapenv:Envelope>
[2013-04-12 09:36:10,175] INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:
a9252cd8-fe73-4e85-9f41-0842872d3a73, Direction: request, sequence = before-smooks, Envelope: <?xml version='1.0' encodi
ng='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
<Name>word</Name>
<Surname>processor</Surname>
<Phone>12333</Phone>
</soapenv:Body></soapenv:Envelope>
[2013-04-12 09:36:10,178] INFO - LogMediator sequence = fileWriteSequence
[2013-04-12 09:36:10,246] INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:
a9252cd8-fe73-4e85-9f41-0842872d3a73, Direction: request, sequence = after-smooks, Envelope: <?xml version='1.0' encodin
g='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><csv-set/></soapenv
:Body></soapenv:Envelope>
[2013-04-12 09:36:10,249] INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:
a9252cd8-fe73-4e85-9f41-0842872d3a73, Direction: request, name = , surname = , phone = //csv-record/phone/text(), Envelo
pe: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><s
oapenv:Body><csv-set/></soapenv:Body></soapenv:Envelope>
[2013-04-12 09:36:11,254] WARN - TimeoutHandler Expiring message ID : urn:uuid:4c422f4e-aed5-4eaa-ad9b-e5407db20562; dr
opping message after global timeout of : 120 seconds
The fileWriteSequence looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse"
name="fileWriteSequence"
trace="enable"
statistics="enable">
<log level="custom">
<property name="sequence" value="fileWriteSequence"/>
</log>
<property xmlns:ns2="http://org.apache.synapse/xsd"
xmlns:ns="http://org.apache.synapse/xsd"
name="transport.vfs.ReplyFileName"
expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.xml')"
scope="transport"
type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:C:/wso2esb/testordner/out"/>
</endpoint>
</send>
</sequence>
Smooks config:
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
<!--Configure the CSVParser to parse the message into a stream of SAX events. -->
<resource-config selector="org.xml.sax.driver">
<resource>org.milyn.csv.CSVParser</resource>
<param name="fields" type="string-list">name,surname,phone</param>
</resource-config>
</smooks-resource-list>
I also changed the code of the databaseSequence above.
Thank you.
Your proxy service looks ok. But I have few concerns.
Why have you put the sql query as CDATA. Please see the sample available here.
You have not mentioned the database name in the connection url. May be it is not a problem since you have used the database.table format in your sql query.
After fixing and 1 and 2, if the issue still exists, try your proxy with only one sequence. i.e. Avoid the file write sequence temporarily and try only with the dbwrite sequence.
You can also log the entries which you are going to insert before the DBReport mediator. i.e. Right after the smooks mediator, put a log mediator and log the name, surname and phone. This will make sure you are trying to insert values which are correctly extracted from the message.

Filtering in WSO2

I want to build one proxy that:
1. Call Service that do Authorize and give result OK or Fail (1st Service)
2. If Result ‘OK’ then call a Service
The Problem is, when The 1st Service give back the Message :
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<result>
<status>OK</status>
<message></message>
</result>
</soapenv:Body>
</soapenv:Envelope>
And I give “filtering” at Out Sequence. Here is the XML :
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http" statistics="disable" trace="enable" startOnLoad="true">
<target endpoint="AuthorizationService">
<outSequence>
<log level="full" />
<filter xpath="/result/status='OK'">
<then>
<send>
<endpoint>
<address uri="http://192.168.1.140:8080/axis2/services/TaskService.TaskServiceHttpEndpoint/getTask" />
</endpoint>
</send>
</then>
<else>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch" />
<reason value="1" />
<role>2</role>
<detail>3</detail>
</makefault>
</else>
</filter>
<log level="full" />
</outSequence>
</target>
</proxy>
When I run my Application, the ESB always give the message :
16:08:59,358 [-] [HttpClientWorker-4] INFO Start : Log mediator
16:08:59,361 [-] [HttpClientWorker-4] INFO To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:0bc33821-c4f1-448e-a7dc-be4194be8e99, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><result><status>OK</status><message></message></result></soapenv:Body></soapenv:Envelope>
16:08:59,361 [-] [HttpClientWorker-4] INFO End : Log mediator
16:08:59,361 [-] [HttpClientWorker-4] INFO Start : Filter mediator
16:08:59,361 [-] [HttpClientWorker-4] INFO XPath expression : /result/status='OK' evaluates to false - executing the else path child mediators
Seems like the condition of the filtering is always false.What is the correct statement for the XPath in the filter?
Your proxy configuration should be look as follows
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http" statistics="disable" trace="enable" startOnLoad="true">
<target endpoint="AuthorizationService">
<outSequence>
<log level="full"/>
<filter source="/result/status" regex="ok">
<then>
<send>
<endpoint>
<address uri="http://192.168.1.140:8080/axis2/services/TaskService.TaskServiceHttpEndpoint/getTask"/>
</endpoint>
</send>
</then>
<else>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
<reason value="1"/>
<role>2</role>
<detail>3</detail>
</makefault>
<send/>
</else>
</filter>
</outSequence>
</target>
<description></description>
</proxy>
It seems that you may have given a wrong xpath expression. You can't give an xpath and a boolean expression both for the xpath value, i.e. it can't be "/result/status='OK'", but has to be "/result/status". Then, according to your sequence, it would fire the section after then, if this element is present. Since, you need to evaluate a boolean condition as well based on the xpath, I'll present an alternative based on the switch mediator (Same can be done for the filter by setting a property):
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http" statistics="disable" trace="enable" startOnLoad="true">
<target endpoint="AuthorizationService">
<outSequence>
<log level="full" />
<switch source="//result/status">
<case regex="OK">
<send>
<endpoint>
<address uri="http://192.168.1.140:8080/axis2/services/TaskService.TaskServiceHttpEndpoint/getTask" />
</endpoint>
</send>
</case>
<default>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch" />
<reason value="1" />
<role>2</role>
<detail>3</detail>
</makefault>
</default>
</switch>
<log level="full" />
</outSequence>
</target>
</proxy>