Can you use the xpath3 to copy the contents to the filename? - xpath

Im am trying to get the xml tag to be a part of the file name but im not getting any value. Am I doing something wrong? Im getting an error or a null value when I change the transformer
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:pop3="http://www.mulesoft.org/schema/mule/pop3" 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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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/pop3 http://www.mulesoft.org/schema/mule/pop3/current/mule-pop3.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
<flow name="email_notificationFlow">
<file:inbound-endpoint path="C:\Users\pd00h\Desktop\Knauf\testxML" responseTimeout="10000" doc:name="File"/>
<file:file-to-byte-array-transformer doc:name="File to Byte Array"/>
<set-variable variableName="order" value="#[xpath3('//ns0:Payload/WhsDockets/WhsDocket/Reference')]" doc:name="Variable"/>
<logger message="#[flowVars.order]" level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="C:\Users\pd00h\Desktop\Knauf" outputPattern="Knauf-#[message.id].xml" responseTimeout="10000" doc:name="File"/>
</flow>
</mule>
Sample Input File
<?xml version="1.0" encoding="utf-8"?><XmlInterchange xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1" xmlns="http://www.edi.com.au/EnterpriseService/">
<InterchangeInfo>
<Date>2016-02-19T09:31:34.969+09:00</Date>
<XmlType>LightWeight</XmlType>
<Source>
<EnterpriseCode>AWH</EnterpriseCode>
<CompanyCode>ADL</CompanyCode>
<OriginServer>ADL</OriginServer>
</Source>
<Target />
<EDIOrganisation EDICode="AWHLOG_AU" OwnerCode="AWHLOG_AU">
<OrganisationDetails>
<Name>AWH LOGISTICS</Name>
<Location Country="Australia" City="Adelaide">AUADL</Location>
<Addresses>
<Address AddressType="MAIN">
<AddressLine1>Gillman Wool Complex</AddressLine1>
<AddressLine2>GRAND TRUNKWAY,</AddressLine2>
<AddressCode>Gillman Wool Complex</AddressCode>
<CityOrSuburb>GILLMAN</CityOrSuburb>
<StateOrProvince>SA</StateOrProvince>
<PostCode>5013</PostCode>
<TelephoneNumbers>
<TelephoneNumber NumberType="Business">+618 8240 8400</TelephoneNumber>
<TelephoneNumber NumberType="Fax">+618 8240 0080</TelephoneNumber>
</TelephoneNumbers>
<Email>containers#awh.com.au</Email>
<Language>ENG</Language>
<Location>AUADL</Location>
<Sequence>1</Sequence>
<AddressCapabilities>
<AddressCapability AddressType="MAIN" />
<AddressCapability IsMainAddress="true" AddressType="OFC" />
<AddressCapability IsMainAddress="true" AddressType="PAD" />
</AddressCapabilities>
</Address>
</Addresses>
</OrganisationDetails>
</EDIOrganisation>
</InterchangeInfo>
<Payload>
<WhsDockets>
<WhsDocket>
<Identifier>
<Client EDICode="KNAINSBNE" OwnerCode="KNAINSBNE">
<OrganisationDetails>
<Name>Knauf Insulation Pty Ltd</Name>
<Location Country="Australia" City="Brisbane">AUBNE</Location>
<Addresses>
<Address AddressType="MAIN">
<AddressLine1>2/44 BorthwickAve</AddressLine1>
<AddressCode>2/44 BorthwickAve</AddressCode>
<CityOrSuburb>MURARRIE</CityOrSuburb>
<StateOrProvince>QLD</StateOrProvince>
<PostCode>4172</PostCode>
<TelephoneNumbers>
<TelephoneNumber NumberType="Business">+61 (7) 3393-7300</TelephoneNumber>
<TelephoneNumber NumberType="Mobile">+61 (438) 488-000</TelephoneNumber>
<TelephoneNumber NumberType="Fax">+61 (7) 3343-1898</TelephoneNumber>
</TelephoneNumbers>
<Email>orders.au#knaufinsulation.com</Email>
<Language>ENG</Language>
<Location>AUBNE</Location>
<Sequence>1</Sequence>
<AddressCapabilities>
<AddressCapability AddressType="MAIN" />
<AddressCapability IsMainAddress="true" AddressType="OFC" />
</AddressCapabilities>
</Address>
</Addresses>
</OrganisationDetails>
</Client>
<Reference>2363867</Reference>
<DocketType>WOH</DocketType>
<ActionType>CON</ActionType>
</Identifier>
<DocketDetail>
<WarehouseCode>ROC</WarehouseCode>
<CustomerReference>3330826</CustomerReference>
<Units>80</Units>
<Packages>0</Packages>
<Pallets>0</Pallets>
<Weight DimensionType="KG">673</Weight>
<Cubic DimensionType="M3">7.624</Cubic>
<TransportInsurance>0.0000</TransportInsurance>
<ShipperCODAmount>0.0000</ShipperCODAmount>
<CustomerOrderDetail>
<OrderType>ORD</OrderType>
<DateRequired>2015-08-25T00:00:00</DateRequired>
<Consignee AddressType="CEA">
<AddressLine1>71-83 Kenny Street</AddressLine1>
<CityOrSuburb>PORTSMITH</CityOrSuburb>
<StateOrProvince>QLD</StateOrProvince>
<PostCode>4870</PostCode>
<CompanyName>Bunnings Cairns Central Warehouse</CompanyName>
<CountryCode>AU</CountryCode>
<ContactName>The Import Manager</ContactName>
</Consignee>
</CustomerOrderDetail>
<CustomAttributes />
</DocketDetail>
<DocketLines>
<DocketLine>
<Product>E2271</Product>
<Description>R 3 0 145mm x 580mm x 1160mm</Description>
<QuantityFromClientOrder>4</QuantityFromClientOrder>
<QuantityActuallyOrdered>4</QuantityActuallyOrdered>
<ProductUQ>MST</ProductUQ>
<LineAttributes />
<LineNumber>1</LineNumber>
<Confirmation>
<Lines>
<Line>
<Quantity>16</Quantity>
<QuantityUQ>PAC</QuantityUQ>
</Line>
</Lines>
<Quantity>16</Quantity>
</Confirmation>
</DocketLine>
<DocketLine>
<Product>E4386</Product>
<Description>R 2 0 90mm x 580mm x 19000mm</Description>
<QuantityFromClientOrder>4</QuantityFromClientOrder>
<QuantityActuallyOrdered>4</QuantityActuallyOrdered>
<ProductUQ>MST</ProductUQ>
<LineAttributes />
<LineNumber>2</LineNumber>
<Confirmation>
<Lines>
<Line>
<Quantity>32</Quantity>
<QuantityUQ>PAC</QuantityUQ>
</Line>
</Lines>
<Quantity>32</Quantity>
</Confirmation>
</DocketLine>
<DocketLine>
<Product>450521</Product>
<Description>XPS300 30 x 600 x 1200 B1 / On / SE</Description>
<QuantityFromClientOrder>20</QuantityFromClientOrder>
<QuantityActuallyOrdered>20</QuantityActuallyOrdered>
<ProductUQ>PC</ProductUQ>
<LineAttributes />
<LineNumber>3</LineNumber>
<Confirmation>
<Lines>
<Line>
<Quantity>20</Quantity>
<QuantityUQ>PC</QuantityUQ>
</Line>
</Lines>
<Quantity>20</Quantity>
</Confirmation>
</DocketLine>
<DocketLine>
<Product>450523</Product>
<Description>XPS300 50 x 600 x 1200 B1 / On / SE</Description>
<QuantityFromClientOrder>12</QuantityFromClientOrder>
<QuantityActuallyOrdered>12</QuantityActuallyOrdered>
<ProductUQ>PC</ProductUQ>
<LineAttributes />
<LineNumber>4</LineNumber>
<Confirmation>
<Lines>
<Line>
<Quantity>12</Quantity>
<QuantityUQ>PC</QuantityUQ>
</Line>
</Lines>
<Quantity>12</Quantity>
</Confirmation>
</DocketLine>
</DocketLines>
</WhsDocket>
</WhsDockets>
</Payload>
Can you use this to complex XML structures?

Add namespace-manager
replace file:file-to-byte-array-transformer
with byte-array-to-string-transformer
fix xpath usage
updated code:
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns:pop3="http://www.mulesoft.org/schema/mule/pop3" 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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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/pop3 http://www.mulesoft.org/schema/mule/pop3/current/mule-pop3.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
<mulexml:namespace-manager
includeConfigNamespaces="true">
<mulexml:namespace prefix="ns0"
uri="http://www.example.com/something.xsd" />
</mulexml:namespace-manager>
<flow name="email_notificationFlow">
<file:inbound-endpoint path="C:\Users\pd00h\Desktop\Knauf\testxML"
responseTimeout="10000" doc:name="File" />
<byte-array-to-string-transformer
doc:name="Byte Array to String" />
<set-variable variableName="order"
value="#[xpath3('//ns0:WhsDockets/ns0:WhsDocket/ns0:Reference')]"
doc:name="Variable" />
<logger message="#[flowVars.order]" level="INFO" doc:name="Logger" />
<file:outbound-endpoint path="C:\Users\pd00h\Desktop\Knauf"
outputPattern="Knauf-#[message.id].xml" responseTimeout="10000"
doc:name="File" />
</flow>
</mule>
Sample xml file:
<?xml version='1.0' encoding='UTF-8'?>
<ns0:WhsDockets xmlns:ns0="http://www.example.com/something.xsd">
<ns0:WhsDocket>
<ns0:Reference>GotIt!</ns0:Reference>
</ns0:WhsDocket>
</ns0:WhsDockets>
Cheers

Related

Combine two queries using WSO2 ESB

I've been trying to figure out how to get WSO2's ESB to make calls to two different APIs and combine their results into a single response, and running into nothing but trouble. At its most basic, I've got two backends I'm making requests to that respond something like this:
http://example.com/items:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<response xmlns="http://example.com/response">
<query name="items" xmlns="http://example.com/query">
<row>
<id>1</id>
<name>Item 1</name>
</row>
<row>
<id>2</id>
<name>Item 2</name>
</row>
</query>
</response>
</soapenv:Body>
</soapenv:Envelope>
http://example.com/parts:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<response xmlns="http://example.com/response">
<query name="parts" xmlns="http://example.com/query">
<row>
<id>1</id>
<part>Part 1.1</part>
</row>
<row>
<id>1</id>
<part>Part 1.2</part>
</row>
<row>
<id>1</id>
<part>Part 1.3</part>
</row>
<row>
<id>2</id>
<part>Part 2.1</part>
</row>
<row>
<id>2</id>
<part>Part 2.2</part>
</row>
</query>
</response>
</soapenv:Body>
</soapenv:Envelope>
I'd like to request both of those, then combine their results to look something like this:
<items>
<item>
<id>1</id>
<name>Item 1</name>
<parts>
<part>
<id>1</id>
<name>Part 1.1</name>
</part>
<part>
<id>1</id>
<name>Part 1.2</name>
</part>
<part>
<id>1</id>
<name>Part 1.3</name>
</part>
</parts>
</item>
<item>
<id>2</id>
<name>Item 2</name>
<parts>
<part>
<id>2</id>
<name>Part 2.1</name>
</part>
<part>
<id>2</id>
<name>Part 2.2</name>
</part>
</parts>
</item>
</items>
Basically, every response from both APIs has a list of rows, each of which contains an id element. The ids in the call to /items are unique within that response, and each row in the response from parts has an id that ties it to a row from /items.
I've got the following API definition in the ESB:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/item_list" name="ItemList" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/">
<inSequence>
<header name="Content-Type" scope="transport" value="text/xml; charset=utf-8"/>
<clone>
<target>
<sequence>
<send>
<endpoint>
<address format="soap11" uri="http://example.com/items"/>
</endpoint>
</send>
</sequence>
</target>
<target>
<sequence>
<send>
<endpoint>
<address format="soap11" uri="http://example.com/parts"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</inSequence>
<outSequence>
<aggregate>
<correlateOn expression="//*[name()='response']/*[name()='query']/*[name()='row']/*[name()='id']" />
<completeCondition>
<messageCount max="2" min="2"/>
</completeCondition>
<onComplete expression="//*[name()='response']/*[name()='query']/*[name()='row']">
<send/>
</onComplete>
</aggregate>
</outSequence>
<faultSequence/>
</resource>
</api>
The inSequence here is heavily simplified, but it does send two valid queries and gets back the expected responses. The outSequence as it's written here never sends a response to the client or logs an error on the server. If I remove the correlateOn element from aggregate, I get back a single row, seemingly at random, from one of the two API calls. I think correlateOn is something I want to be using here, but I can't find any useful documentation on it from either WSO2 or Apache, so I'm sure I'm using it incorrectly. My XPath background is pretty weak, so I'm sure that expression could also use some work.
Am I at least on the right track here with the clone/aggregate pattern? How would I go about combining the results from these two queries into something similar to my example? If I can get something even sort of close, I should be able to do the rest with XSLT.
take a look at this demo:
Backend 1 with the items response:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="items"
transports="https http"
startOnLoad="true">
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<response xmlns="http://example.com/response">
<query xmlns="http://example.com/query" name="items">
<row>
<id>1</id>
<name>Item 1</name>
</row>
<row>
<id>2</id>
<name>Item 2</name>
</row>
</query>
</response>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<log level="full"/>
<loopback/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
Backend 2 with the parts response:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="parts"
transports="https http"
startOnLoad="true">
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<response xmlns="http://example.com/response">
<query xmlns="http://example.com/query" name="parts">
<row>
<id>1</id>
<part>Part 1.1</part>
</row>
<row>
<id>1</id>
<part>Part 1.2</part>
</row>
<row>
<id>1</id>
<part>Part 1.3</part>
</row>
<row>
<id>2</id>
<part>Part 2.1</part>
</row>
<row>
<id>2</id>
<part>Part 2.2</part>
</row>
</query>
</response>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<log level="full"/>
<loopback/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
My API calling backend 1 and backend 2 and transforming with xslt:
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
name="ItemList"
context="/item_list">
<resource methods="POST" uri-template="/">
<inSequence>
<header name="Action" scope="default" value="urn:mediate"/>
<call>
<endpoint>
<address uri="http://localhost:8283/services/items.itemsHttpSoap11Endpoint"
format="soap11"/>
</endpoint>
</call>
<enrich>
<source type="inline" clone="true">
<Payloads/>
</source>
<target type="property" property="Items"/>
</enrich>
<enrich>
<source clone="true" xpath="$body/*"/>
<target action="child" xpath="$ctx:Items"/>
</enrich>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body/>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<call>
<endpoint>
<address uri="http://localhost:8283/services/parts.partsHttpSoap11Endpoint"
format="soap11"/>
</endpoint>
</call>
<enrich>
<source clone="true" xpath="$body/*[name()='response']/*[name()='query']"/>
<target type="property" property="Parts"/>
</enrich>
<enrich>
<source type="property" clone="true" property="Parts"/>
<target action="child" xpath="$ctx:Items"/>
</enrich>
<enrich>
<source type="property" property="Items"/>
<target type="body"/>
</enrich>
<xslt key="transformTwoSourcesToOneResult"/>
<loopback/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
And my xslt transformation:
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="transformTwoSourcesToOneResult" xmlns="http://ws.apache.org/ns/synapse">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://example.com/query"
xmlns:ns1="http://example.com/response"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:exslt="http://exslt.org/common"
xmlns:saxon="http://saxon.sf.net/"
xmlns:syn="http://ws.apache.org/ns/synapse"
exclude-result-prefixes="ns0 ns1 xs">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="var1_instance_Payloads" select="."/>
<items>
<xsl:for-each select="$var1_instance_Payloads/syn:Payloads">
<xsl:variable name="var2_Payloads" select="."/>
<xsl:for-each select="$var2_Payloads/ns1:response/ns0:query/ns0:row">
<xsl:variable name="var2_row" select="."/>
<item>
<id>
<xsl:value-of select="number(string($var2_row/ns0:id))"/>
</id>
<name>
<xsl:value-of select="string($var2_row/ns0:name)"/>
</name>
<parts>
<xsl:for-each select="$var2_Payloads/ns0:query/ns0:row">
<xsl:variable name="var4_row" select="."/>
<xsl:if test="string((number(string($var2_row/ns0:id)) = number(string($var4_row/ns0:id)))) != 'false'">
<part>
<id>
<xsl:value-of select="number(string($var4_row/ns0:id))"/>
</id>
<name>
<xsl:value-of select="string($var4_row/ns0:part)"/>
</name>
</part>
</xsl:if>
</xsl:for-each>
</parts>
</item>
</xsl:for-each>
</xsl:for-each>
</items>
</xsl:template>
</xsl:stylesheet>
</localEntry>
The API response:
<items xmlns="http://ws.apache.org/ns/synapse" xmlns:syn="http://ws.apache.org/ns/synapse" xmlns:saxon="http://saxon.sf.net/" xmlns:exslt="http://exslt.org/common">
<item>
<id>1</id>
<name>Item 1</name>
<parts>
<part>
<id>1</id>
<name>Part 1.1</name>
</part>
<part>
<id>1</id>
<name>Part 1.2</name>
</part>
<part>
<id>1</id>
<name>Part 1.3</name>
</part>
</parts>
</item>
<item>
<id>2</id>
<name>Item 2</name>
<parts>
<part>
<id>2</id>
<name>Part 2.1</name>
</part>
<part>
<id>2</id>
<name>Part 2.2</name>
</part>
</parts>
</item>
</items>

Mule- error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'magento:config'

I am trying to run in Anypoint Studio a project with maven using magento connector ver 2.2.0.
This is my project's xml file:
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:magento="http://www.mulesoft.org/schema/mule/magento" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/magento http://www.mulesoft.org/schema/mule/magento/current/mule-magento.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<magento:config name="Magento" username="test" password="test$" address="http://127.0.0.1:8000.com/api/v2_soap/" doc:name="Magento"/>
<flow name="magentoFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/magento" doc:name="HTTP"/>
<magento:get-product config-ref="Magento" doc:name="Magento" productId="1"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
and this is the error:
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'magento:config'. One of '{"http://www.springframework.org/schema/beans":beans, "http://www.springframework.org/schema/beans":bean, "http://www.springframework.org/schema/context":property-placeholder, "http://www.springframework.org/schema/beans":ref, "http://www.mulesoft.org/schema/mule/core":global-property, "http://www.mulesoft.org/schema/mule/core":configuration, "http://www.mulesoft.org/schema/mule/core":notifications, "http://www.mulesoft.org/schema/mule/core":abstract-extension, "http://www.mulesoft.org/schema/mule/core":abstract-shared-extension, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-extension, "http://www.mulesoft.org/schema/mule/core":abstract-agent, "http://www.mulesoft.org/schema/mule/core":abstract-security-manager, "http://www.mulesoft.org/schema/mule/core":abstract-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-shared-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-connector, "http://www.mulesoft.org/schema/mule/core":abstract-shared-connector, "http://www.mulesoft.org/schema/mule/core":abstract-global-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy, "http://www.mulesoft.org/schema/mule/core":abstract-flow-construct, "http://www.mulesoft.org/schema/mule/core":flow, "http://www.mulesoft.org/schema/mule/core":sub-flow, "http://www.mulesoft.org/schema/mule/core":abstract-model, "http://www.mulesoft.org/schema/mule/core":abstract-interceptor-stack, "http://www.mulesoft.org/schema/mule/core":abstract-filter, "http://www.mulesoft.org/schema/mule/core":abstract-transformer, "http://www.mulesoft.org/schema/mule/core":processor-chain, "http://www.mulesoft.org/schema/mule/core":custom-processor, "http://www.mulesoft.org/schema/mule/core":abstract-empty-processor, "http://www.mulesoft.org/schema/mule/core":invoke, "http://www.mulesoft.org/schema/mule/core":set-payload, "http://www.mulesoft.org/schema/mule/core":abstract-global-intercepting-message-processor, "http://www.mulesoft.org/schema/mule/core":custom-queue-store, "http://www.mulesoft.org/schema/mule/core":abstract-processing-strategy}' is expected.
What's missing?
Does the following work?
<?xml version="1.0" encoding="UTF-8"?>
<mule
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:magento="http://www.mulesoft.org/schema/mule/magento"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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/3.7/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.7/mule-http.xsd
http://www.mulesoft.org/schema/mule/magento http://www.mulesoft.org/schema/mule/magento/1.2/mule-magento.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/3.7/mule-json.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<magento:config name="Magento" username="test" password="test$" address="http://127.0.0.1:8000.com/api/v2_soap/" doc:name="Magento"/>
<flow name="magentoFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/magento" doc:name="HTTP"/>
<magento:get-product config-ref="Magento" doc:name="Magento" productId="1"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
Changes from your snippet:
Added the XML declaration line
Changed the location of the XSDs to specific versions instead of 'current'.
(Am not sure if this is needed since the XSDs might be coming from jars on the classpath)

Durable flag on my topic consumer doesn't work?

trying to implement the Durable feature on a Topic consumer.
Placed a name to the jms consumer and also clientID. (Obviously added the durable="true")
Now as far as i've read. The Topic will register the consumer as "durable" when it gets running for the first time.
So basically i did this, deployed the producer and consumer. It gets registered as a durable consumer. Publish a message to the topic, the consumer gets it. Now i undeploy the consumer and publish another message the consumer should be receive whenever gets up. When I deploy the consumer again, i get the common temp-topic://XXXXXXXXXXXX destination doesn't exist.
Why is this happening? Shouldn't i be getting the "lost" message?
This is my current jms activemq connector configuration for the publisher:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.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/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd ">
<jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616" validateConnections="false" doc:name="Active MQ" maxRedelivery="1" persistentDelivery="true" durable="true" clientId="RoutingTopic">
<reconnect count="5" />
</jms:activemq-connector>
<message-properties-transformer name="MessagePropertiesTransformer" doc:name="Message Properties" overwrite="true">
<add-message-property key="BACKEND_SUBSCRIBER" value="#[flowVars['backend']]"/>
<add-message-property key="MULE_EVENT_TIMEOUT" value="60000"/>
</message-properties-transformer>
<flow name="jmsFlow1" doc:name="jmsFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="jms" doc:name="HTTP"/>
<set-variable variableName="#['id']" value="#[message.inboundProperties['id']]" doc:name="set dynamic id"/>
<set-variable variableName="#['backend']" value="#[message.inboundProperties['backend']]" doc:name="setting backend"/>
<set-payload value="#['This is a message test for id '] #[flowVars['id']]" doc:name="set random string as payload"/>
<choice doc:name="Choice">
<when expression="#[true]">
<processor-chain>
<jms:outbound-endpoint exchange-pattern="request-response" connector-ref="Active_MQ" doc:name="JMS Topic Requestor" transformer-refs="MessagePropertiesTransformer" topic="ESB.Topic">
</jms:outbound-endpoint>
</processor-chain>
</when>
<otherwise>
<processor-chain>
<logger message="This is the default case" level="INFO" doc:name="Logger"/>
</processor-chain>
</otherwise>
</choice>
</flow>
</mule>
This is one of the consumers, i got 2, but both are basically the same thing
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jbossts="http://www.mulesoft.org/schema/mule/jbossts" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.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/jbossts http://www.mulesoft.org/schema/mule/jbossts/current/mule-jbossts.xsd ">
<jms:activemq-connector name="UpCity_Connector" specification="1.1" brokerURL="tcp://localhost:61616" validateConnections="false" maxRedelivery="0" doc:name="Active MQ" clientId="RandomName" durable="true"/>
<flow name="jmsAdapterConsumerFlow1" doc:name="fmsAdapterConsumerFlow1">
<jms:inbound-endpoint exchange-pattern="request-response" connector-ref="UpCity_Connector" doc:name="JMS Replier Consumer" topic="ESB.Topic">
<jms:selector expression="BACKEND_SUBSCRIBER='randombackend'"/>
</jms:inbound-endpoint>
<set-payload value="#[payload + ' returned from a random backend']" doc:name="Add string to payload"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Thanks.
Durable Messaging is a little tricky in JMS, as your config/code will have to meet several criteria to get this to work correctly:
enable persistence in your broker's config (in ActiveMQ this is either done in the connection string as David posted, or in your configuration xml
create a durable subscriber (ActiveMQ API)
I'm not sure that mule creates durable subscribers. However, you can check that in ActiveMQ's web console. There you can get a list of the current durable subscriptions.

Insertinto database with xpath query and multiple xpath expressions

I am new to xpath and I'm trying to use multiple expressions with the "|" Separator, however when I have the configuration xml set to:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.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">
<jdbc-ee:mssql-data-source name="MS_SQL_Data_Source" user="username" password="passcode" url="jdbc:sqlserver://DOMAIN\SQLEXPRESS:65183;databaseName=MULETEST" transactionIsolation="UNSPECIFIED" doc:name="MS SQL Data Source"/>
<jdbc-ee:connector name="Database" dataSource-ref="MS_SQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
<jdbc-ee:query key="InsertRecord" value="INSERT INTO databaseupdate(BuyerOrderNumber, OrderIssueDate) VALUES (#[xpath('//BuyerOrderNumber').text], #[xpath('//OrderIssueDate').text])"/>
</jdbc-ee:connector>
<flow name="Write_xml_file_to_databaseFlow1" doc:name="Write_xml_file_to_databaseFlow1">
<file:inbound-endpoint path="C:\mule" responseTimeout="10000" doc:name="File"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<splitter evaluator="xpath" expression="/Order/OrderHeader/OrderNumber|/Order/OrderHeader" doc:name="Splitter"/>
<jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="InsertRecord" queryTimeout="-1" connector-ref="Database" doc:name="Destination"/>
</flow>
</mule>
I get a NULLPointerException. My confusion lies in xpath queries, how do I hardcode multiple expression paths, and associate that with the xpath query using the insert?
Thanks.

How to customize the schema inlined inside an imported WSDL

I have a.wsdl & b.wsdl where a.wsdl imports b.wsdl.
Now I have to customize the schema inside b.wsdl using wsimport and JAXB. but using below customization is giving error that "XPath evaluation of "wsdl:definitions/wsdl:types/xsd:schema[#targetNamespace='b']" results in an empty target node
I am not able to find a way to customize the inlined schema in imported b.wsdl when generating the client code using wsimport.
<jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema[#targetNamespace='b']"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<jaxb:globalBindings>
<jaxb:javaType name="java.util.Calendar" xmlType="xsd:dateTime"
parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime"
printMethod="javax.xml.bind.DatatypeConverter.printDateTime" />
</jaxb:globalBindings>
</jaxws:bindings>
A.wsdl
<definitions targetNamespace="a"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:interface="b">
<import location="b.wsdl" namespace="b"/>
<service name="Service">
<port binding="interface:Binding" name="Port">
<soap:address location="https://localhost/sdk/vpxdService" />
</port>
</service>
</definitions>
B.wsdl
<definitions targetNamespace="b"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:b="b"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<schema
targetNamespace="b"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:b="b"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<complexType name="XYZ">
<sequence>
<element name="dynamicType" type="xsd:string" minOccurs="0" />
<element name="val" type="xsd:anyType" maxOccurs="unbounded" />
</sequence>
</complexType>
</types>
</schema>
</definitions>
After going through given website I modified the external binding file to use wsdlLocation="b.wsdl" instead of node="wsdl:definitions/wsdl:types/xsd:schema[#targetNamespace='b']" which did the magic.
This will make sure that the inline schema defined in WSDL will customized as required.
<bindings
xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl"
version="2.0">
<bindings wsdlLocation="b.wsdl">
<globalBindings>
<javaType name="java.util.Calendar" xmlType="xsd:dateTime"
parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
printMethod="javax.xml.bind.DatatypeConverter.printDate"
/>
</globalBindings>
</bindings>
</bindings>
http://fusesource.com/docs/framework/2.1/jaxws/JAXWSCustomTypeMappingOverview.html
Have you tried adding the following attributes to the <jaxws:bindings> element?
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
and
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
You're referencing the xsd and wsdl namespaces in your xpath expression, but until you define the URI's for them, they won't match up with the URI's in the target documents.

Resources