How to write "anything goes" in Relax NG? - relaxng

Is there a way to write that there are completely no restrictions on content of an element in Relax NG?
In XML Schema something like this is apparently possible with
<xs:sequence>
<xs:any namespace="##targetNamespace" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
Can I do an equivalent of this in Relax NG?

I propose this solution, dividing attributes and elements declaration, and using mixed element to allow mixed content.
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<ref name="anyElement"/>
</start>
<define name="anyElement">
<element>
<anyName/>
<ref name="anyAttributes"/>
<mixed>
<zeroOrMore>
<ref name="anyElement"/>
</zeroOrMore>
</mixed>
</element>
</define>
<define name="anyAttributes">
<zeroOrMore>
<attribute>
<anyName/>
</attribute>
</zeroOrMore>
</define>
</grammar>

Okay, I don't know if this the best way, but I have adapted this from "any" definition in Relax NG spec.
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="Anything"/>
</start>
<define name="Anything">
<zeroOrMore>
<choice>
<element>
<anyName/>
<ref name="Anything"/>
</element>
<attribute>
<anyName/>
</attribute>
<text/>
</choice>
</zeroOrMore>
</define>
</grammar>

Related

WSO2 EI: Can I use mediator to request another API and pass its response to the body request?

In my case, I want to add a dynamic value ("Bearer" + {access-token}) to the header mediator .
So before the header mediator, I want to invoke a get-token API and extract {access-token} element from its response. How can I get that ? Thank you so much.
You can achieve such requirements with mediation sequences. You can refer to this blog for more detailed instructions on how to develop a sequence for your requirement. The blog is written for the API Manager product, but nevertheless, you can follow the same to get it done in the EI.
A sample mediation sequence will be as following
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="oauth2-sequence" xmlns="http://ws.apache.org/ns/synapse">
<!-- token generation to the oauth server's token endpoint -->
<!-- add the base64 encoded credentials -->
<property name="client-authorization-header" scope="default" type="STRING" value="MDZsZ3BTMnh0enRhOXBsaXZGUzliMnk4aEZFYTpmdE4yWTdLcnE2SWRsenBmZ1RuTVU1bkxjUFFh" />
<property name="request-body" expression="json-eval($)" scope="default" type="STRING" />
<property name="resource" expression="get-property('axis2', 'REST_URL_POSTFIX')" scope="default" type="STRING" />
<!-- creating a request payload for client_credentials -->
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root xmlns="">
<grant_type>client_credentials</grant_type>
</root>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args></args>
</payloadFactory>
<!-- set related headers to call the token endpoint -->
<header name="Authorization" expression="fn:concat('Basic ', get-property('client-authorization-header'))" scope="transport" />
<header name="Content-Type" value="application/x-www-form-urlencoded" scope="transport" />
<property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING" />
<property name="REST_URL_POSTFIX" value="" scope="axis2" type="STRING" />
<!-- change the token endpoint -->
<call blocking="true">
<endpoint>
<http method="POST" uri-template="https://localhost:9443/oauth2/token" />
</endpoint>
</call>
<!-- append the acquired access token and make the call to the backend service -->
<property name="bearer-token" expression="json-eval($.access_token)" scope="default" type="STRING" />
<property name="REST_URL_POSTFIX" expression="get-property('resource')" scope="axis2" type="STRING" />
<header name="Authorization" expression="fn:concat('Bearer ', get-property('bearer-token'))" scope="transport" />
<payloadFactory media-type="json">
<format>$1</format>
<args>
<arg evaluator="xml" expression="get-property('request-body')" />
</args>
</payloadFactory>
<!-- perform a send or call to complete the execution of the backend service call in EI -->
</sequence>
Hope this helps you to start with implementation.

Possible DB.TOXML bug? (UniVerse 11.3.1 on AIX)

Based on my understanding of the XMAP specification relative to DB.TOXML, the following XMAP represents a simple object model containing two child tables with the same parent table.
The command DB.TOXML CUST_ACT.XML XMAP_CustomerActivity.XML produces an XML file containing the records and fields from the parent table and one of the child tables as expected. However, the fields for each record of the other child table are repeated once within the record node. If I switch the child TableMaps, in the parent TABLECLASSMAP, the problem switches to the other child table.
It appears that when more than one (child) TableMap is specified in the parent map, fields from the table in the child map referenced by the first (child) TableMap entry are repeated TableMap times in record nodes of that table. This behavior was noticed during development of a process in a real-world UniVerse database environment with a more involved object model.
In order to confirm, I created simple CUSTOMER / CONTACT, CUSTOMER / ORDER files with a few test records for demonstration purposes. If this is a bug versus an XMAP configuration error on my part, then it appears either the XMAPCreate() API function or the XMAPAppendRec() API function may not correctly support this structure.
XMAP:
?xml version="1.0" encoding="UTF-8"?>
<!-- DOCTYPE U2XMAP SYSTEM "U2XMAP.DTD" -->
<U2XMAP version="1.0" Name="XMAP1" >
<!-- Table/Class map XCLASS_CLASS -->
<TABLECLASSMAP MapName="M1" StartNode="/Customers/Customer" TableName="CUSTOMERTBL">
<ColumnMap Node="CustKey" Column="CKEY"/>
<ColumnMap Node="Name" Column="CNAME" />
<TableMap Node="Orders/Order" MapName="M2" />
<TableMap Node="Contact/Methods" MapName="M3" />
</TABLECLASSMAP>
<TABLECLASSMAP MapName="M2" StartNode="Orders/Order" TableName="ORDERTBL">
<ColumnMap Node="CustKey" Column="C.KEY" />
<ColumnMap Node="OrderKey" Column="#ID" />
<ColumnMap Node="OrderDate" Column="ORDERDATE" />
<ColumnMap Node="ProductId" Column="PRODUCTID" />
</TABLECLASSMAP>
<TABLECLASSMAP MapName="M3" StartNode="Contact/Methods" TableName="CONTACTMETHTBL">
<ColumnMap Node="CustKey" Column="C.KEY" />
<ColumnMap Node="ContactKey" Column="#ID" />
<ColumnMap Node="Type" Column="TYPE" />
<ColumnMap Node="Address" Column="ADDRESS" />
</TABLECLASSMAP>
<RelatedTable>
<MapParentKey TableName="CUSTOMERTBL" Column="CKEY" KeyGenerate="No" />
<MapChildKey TableName="ORDERTBL" Column="CKEY" />
</RelatedTable>
<RelatedTable>
<MapParentKey TableName="CUSTOMERTBL" Column="CKEY" KeyGenerate="No" />
<MapChildKey TableName="CONTACTMETHTBL" Column="CKEY" />
</RelatedTable>
</U2XMAP>
RESULT:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Customers>
<Customer>
<CustKey>1</CustKey>
<Name>MOUSE, MICKEY</Name>
<Orders>
<Order>
<CustKey>1</CustKey>
<OrderKey>10</OrderKey>
<OrderDate>01-04-2022</OrderDate>
<ProductId>555R3232</ProductId>
<CustKey>1</CustKey>
<OrderKey>10</OrderKey>
<OrderDate>01-04-2022</OrderDate>
<ProductId>555R3232</ProductId>
</Order>
<Order>
<CustKey>1</CustKey>
<OrderKey>1</OrderKey>
<OrderDate>12-27-2021</OrderDate>
<ProductId>5323423</ProductId>
<CustKey>1</CustKey>
<OrderKey>1</OrderKey>
<OrderDate>12-27-2021</OrderDate>
<ProductId>5323423</ProductId>
</Order>
<Order>
<CustKey>1</CustKey>
<OrderKey>2</OrderKey>
<OrderDate>12-28-2021</OrderDate>
<ProductId>9299399</ProductId>
<CustKey>1</CustKey>
<OrderKey>2</OrderKey>
<OrderDate>12-28-2021</OrderDate>
<ProductId>9299399</ProductId>
</Order>
<Order>
<CustKey>1</CustKey>
<OrderKey>3</OrderKey>
<OrderDate>12-29-2021</OrderDate>
<ProductId>23492349</ProductId>
<CustKey>1</CustKey>
<OrderKey>3</OrderKey>
<OrderDate>12-29-2021</OrderDate>
<ProductId>23492349</ProductId>
</Order>
</Orders>
<Contact>
<Methods>
<CustKey>1</CustKey>
<ContactKey>1</ContactKey>
<Type>HOMEPH</Type>
<Address>444-555-6666</Address>
</Methods>
<Methods>
<CustKey>1</CustKey>
<ContactKey>2</ContactKey>
<Type>HOMEST</Type>
<Address>580 LIBERTY CIR</Address>
</Methods>
</Contact>
</Customer>
<Customer>
<CustKey>2</CustKey>
<Name>FROG, KERMIT</Name>
<Orders>
<Order>
<CustKey>2</CustKey>
<OrderKey>4</OrderKey>
<OrderDate>12-29-2021</OrderDate>
<ProductId>99338822</ProductId>
<CustKey>2</CustKey>
<OrderKey>4</OrderKey>
<OrderDate>12-29-2021</OrderDate>
<ProductId>99338822</ProductId>
</Order>
<Order>
<CustKey>2</CustKey>
<OrderKey>5</OrderKey>
<OrderDate>12-28-2021</OrderDate>
<ProductId>23874771</ProductId>
<CustKey>2</CustKey>
<OrderKey>5</OrderKey>
<OrderDate>12-28-2021</OrderDate>
<ProductId>23874771</ProductId>
</Order>
</Orders>
<Contact>
<Methods>
<CustKey>2</CustKey>
<ContactKey>3</ContactKey>
<Type>HOMEPH</Type>
<Address>777-888-9999</Address>
</Methods>
<Methods>
<CustKey>2</CustKey>
<ContactKey>4</ContactKey>
<Type>WORKPH</Type>
<Address>909-090-0909</Address>
</Methods>
</Contact>
</Customer>
<Customer>
<CustKey>3</CustKey>
<Name>BIRD, BIG</Name>
<Orders>
<Order>
<CustKey>3</CustKey>
<OrderKey>6</OrderKey>
<OrderDate>12-30-2021</OrderDate>
<ProductId>83776632</ProductId>
<CustKey>3</CustKey>
<OrderKey>6</OrderKey>
<OrderDate>12-30-2021</OrderDate>
<ProductId>83776632</ProductId>
</Order>
<Order>
<CustKey>3</CustKey>
<OrderKey>7</OrderKey>
<OrderDate>12-30-2021</OrderDate>
<ProductId>R29898W9</ProductId>
<CustKey>3</CustKey>
<OrderKey>7</OrderKey>
<OrderDate>12-30-2021</OrderDate>
<ProductId>R29898W9</ProductId>
</Order>
<Order>
<CustKey>3</CustKey>
<OrderKey>8</OrderKey>
<OrderDate>12-31-2021</OrderDate>
<ProductId>23884888</ProductId>
<CustKey>3</CustKey>
<OrderKey>8</OrderKey>
<OrderDate>12-31-2021</OrderDate>
<ProductId>23884888</ProductId>
</Order>
<Order>
<CustKey>3</CustKey>
<OrderKey>9</OrderKey>
<OrderDate>12-29-2021</OrderDate>
<ProductId>29993999</ProductId>
<CustKey>3</CustKey>
<OrderKey>9</OrderKey>
<OrderDate>12-29-2021</OrderDate>
<ProductId>29993999</ProductId>
</Order>
</Orders>
<Contact>
<Methods>
<CustKey>3</CustKey>
<ContactKey>5</ContactKey>
<Type>HOMEPH</Type>
<Address>405-040-5040</Address>
</Methods>
</Contact>
</Customer>
</Customers>
Any ideas? Thanks in advance. UniVerse 11.3.1 on AIX.
I also posted this question here but haven't gotten much exposure. (where you can better see highlighted in red the repeated entries).
Looks like it might be a bug to me. I tested it under Linux with 11.3.2 and I noticed the same behavior. It may be a system limitation, but if that were the case I would expect a failure on the mapping call as it seems to be pretty particular.
I would open a ticket with Rocket. I used the HS.SALES demo data that comes with UniVerse to replicate. I will provide it here for you to use in your report. It will be much easier for support to either confirm the bug or tell you what we are collectively doing wrong if they are already working with the same data.
<?xml version="1.0" encoding="UTF-8"?>
<!-- DOCTYPE U2XMAP SYSTEM "U2XMAP.DTD" -->
<U2XMAP version="1.0" Name="XMAP1" >
<!-- Table/Class map XCLASS_CLASS -->
<TABLECLASSMAP MapName="M1" StartNode="/Customers/Customer" TableName="CUSTOMER">
<ColumnMap Node="CustID" Column="#ID"/>
<ColumnMap Node="FirstName" Column="FNAME"/>
<ColumnMap Node="LastName" Column="LNAME" />
<ColumnMap Node="State" Column="STATE" />
<ColumnMap Node="ProductID" Column="PRODID" />
<TableMap Node="States/State" MapName="M2" />
<TableMap Node="Products/Product" MapName="M3" />
</TABLECLASSMAP>
<TABLECLASSMAP MapName="M2" StartNode="States/State" TableName="STATES">
<ColumnMap Node="StateName" Column="NAME" />
</TABLECLASSMAP>
<TABLECLASSMAP MapName="M3" StartNode="Products/Product" TableName="PRODUCTS">
<ColumnMap Node="Price" Column="LIST" />
<ColumnMap Node="Description" Column="DESCRIPTION" />
</TABLECLASSMAP>
<RelatedTable>
<MapParentKey TableName="CUSTOMER" Column="PRODID" KeyGenerate="No" />
<MapChildKey TableName="PRODUCTS" Column="PRODID" />
</RelatedTable>
<RelatedTable>
<MapParentKey TableName="CUSTOMER" Column="STATE" KeyGenerate="No" />
<MapChildKey TableName="STATES" Column="CODE" />
</RelatedTable>
</U2XMAP>
In the mean time if you are blocked and the mapping isn't overly complex you can probably just add I-Descriptors and TRANS (or XLATE) over to the other file to include it in parent dictionary and thus not require any additional table mapping.
Good Luck,

wso2esb 4.8.1 and 4.9.0 different behaviour onError

I have a registered onError sequence.
In version 4.8.1 SOAP envelop is available in onError sequence
while in 4.9.0 it is not.
in order to access SOAP message content in 4.9.0 after error (in onError sequence) I always have to copy it to some temp variable initially. it is very inconvenient.
could it be a bug or is it a new "feature" of 4.9.0?
this is my fault sequence. if i remove enrich mediator envelope comes empty from the sequence with an error. Without enrich mediator message contains empty soap envelope. It can be seen in the output of the log mediator and in the message stored in RabbitMQ backend. Actually, it is onError sequence of XXXXNotifySendSequence sequence (I added them both for the reference).
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="XXXXNotifyErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="mssg" expression="get-property('mssg')"/>
<property name="retry_count" expression="get-property('retry_count')"/>
</log>
<filter xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xpath="get-property('mssg')">
<then>
<enrich>
<source clone="true" property="mssg" type="property"/>
<target type="envelope"/>
</enrich>
<property name="mssg" action="remove"/>
</then>
<else/>
</filter>
<filter xmlns:ns="http://org.apache.synapse/xsd" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="http://org.apache.synapse/xsd" xpath="get-property('retry_count')">
<then>
<property name="retry_count" expression="number(get-property('retry_count'))+1" scope="default" type="STRING"/>
<filter xpath="get-property('retry_count') > 5">
<then>
<log>
<property name="Dropping--Count" expression="get-property('retry_count')"/>
</log>
<drop/>
</then>
<else>
<sequence key="XXXXNotifySendSequence"/>
</else>
</filter>
</then>
<else>
<property name="retry_count" value="1" scope="default" type="STRING"/>
<clone continueParent="true">
<target>
<sequence>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
<reason expression="get-property('ERROR_MESSAGE')"/>
</makefault>
<send/>
</sequence>
</target>
</clone>
</else>
</filter>
<clone>
<target>
<sequence>
<log level="custom">
<property name="STORE" value="store the message"/>
</log>
<store messageStore="XXXXRabbitMQNative"/>
</sequence>
</target>
</clone>
</sequence>
this is the sequence calling onError sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="XXXXNotifySendSequence"
onError="XXXXNotifyErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="XXXX" value="request start"/>
</log>
<enrich>
<source clone="true" type="envelope"/>
<target property="mssg" type="property"/>
</enrich>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<call>
<endpoint key="HTTPEndpoint"/>
</call>
<log level="full">
<property name="XXXX" value="request end"/>
</log>
</sequence>
I am not much sure why you written fault sequence in that way. but when i change like bellow its working. no need to enrich and assign to other property
Sequence:(same as yours - untouched)
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="XXXXNotifySendSequence"
onError="XXXXNotifyErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="XXXX" value="request start"/>
</log>
<enrich>
<source clone="true" type="envelope"/>
<target action="replace" property="mssg" type="property"/>
</enrich>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<call>
<endpoint key="HTTPEndpoint"/>
</call>
<log level="full">
<property name="XXXX" value="request end"/>
</log>
</sequence>
fault sequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="XXXXNotifyErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log>
<property expression="get-property('ERROR_CODE')"
name="========error-code=========" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="get-property('ERROR_MESSAGE')"
name="========error-message=========" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<makefault version="soap11">
<code value="soap11Env:VersionMismatch" xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/"/>
<reason expression="get-property('ERROR_MESSAGE')" xmlns:ns="http://org.apache.synapse/xsd"/>
<role>sample</role>
<detail>sample detail</detail>
</makefault>
<send/>
</sequence>
proxy: to call sequence
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="samplecall"
transports="http,https"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="XXXXNotifySendSequence"/>
<description/>
</proxy>
response: (since end point is not defined)
<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/">soap11Env:VersionMismatch</faultcode>
<faultstring>Couldn't find the endpoint with the key : HTTPEndpoint</faultstring>
<faultactor>sample</faultactor>
<detail>sample detail</detail>
</soapenv:Fault>
in log:
2015-11-08 17:19:55,250] INFO - LogMediator To: /services/samplecall.samplecallHttpSoap11Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:106d763f-cdc1-43d2-98a9-63d22d17eb81, Direction: request, XXXX = request start, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>
[2015-11-08 17:19:55,252] INFO - LogMediator To: /services/samplecall.samplecallHttpSoap11Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:106d763f-cdc1-43d2-98a9-63d22d17eb81, Direction: request, ========error-code========= = 305100, ========error-message========= = Couldn't find the endpoint with the key : HTTPEndpoint

WSO2 ESB having issues when I use multiple callout mediator calls with in a single sequence

I was trying to write a proxy service that has multiple calls involved where output from first service is used to create request to second service and eventually output from second service will be transformed before even i make the third one. Right now I am having issues at the second step itself.
Here is a proxy configuration that I have where output from service 1 is being used to create the payload for second service call.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="CreateListingFromGetLocation" statistics="disable"
trace="disable" transports="http https">
<target>
<inSequence>
<property action="set" name="userName" scope="default"
type="STRING" value="Rama"/>
<property action="set" name="password" scope="default"
type="STRING" value="Ramapass"/>
<property action="set" name="clientIP" scope="default"
type="STRING" value="1.11.111.111"/>
<payloadFactory>
<format>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Pool_GetNewSession>
<tem:Name>$1</tem:Name>
<tem:Password>$2</tem:Password>
<tem:ClientIP>$3</tem:ClientIP>
</tem:Pool_GetNewSession>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg expression="get-property('userName')"/>
<arg expression="get-property('password')"/>
<arg expression="get-property('clientIP')"/>
</args>
</payloadFactory>
<log category="INFO" level="custom" separator=",">
<property expression="//*" name="Triggering getSession API call.."/>
</log>
<callout action="urn:Pool_GetNewSession" serviceURL="http://localhost:8989/GetNewSession/">
<source type="envelope"/>
<target xmlns="http://tempuri.org/" xpath="//Pool_GetNewSessionResponse"/>
</callout>
<property action="set"
expression="//tem:Pool_GetNewSessionResult"
name="sessionId" scope="default" type="STRING" xmlns:tem="http://tempuri.org/"/>
<log category="INFO" level="custom" separator=",">
<property expression="get-property('sessionId')" name="SessionID"/>
</log>
<property action="set" name="siteId" scope="default"
type="STRING" value="51"/>
<property action="set" name="productId" scope="default"
type="STRING" value="8351"/>
<property action="set" name="perfDateList" scope="default"
type="STRING" value="12/13/2014 E"/>
<property action="set" name="marketingCode" scope="default"
type="STRING" value="Premium"/>
<property action="set" name="targetSystem" scope="default"
type="STRING" value="Govinda"/>
<payloadFactory>
<format>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Pool_SendXMLRequest>
<tem:Name>$1</tem:Name>
<tem:SiteID>$2</tem:SiteID>
<tem:sXMLInput>
<request>
<displaydata>
<fetch_display_data>
<fn_name>eapi_fetch_mkt_locations_mkt</fn_name>
<param type="operator">$1</param>
<param type="string">$2</param>
<param type="string">$3</param>
<param type="string">$4</param>
<param type="string">$5</param>
</fetch_display_data>
</displaydata>
</request>
</tem:sXMLInput>
<tem:TargetSystem>$6</tem:TargetSystem>
<tem:Session>$7</tem:Session>
</tem:Pool_SendXMLRequest>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg expression="get-property('userName')"/>
<arg expression="get-property('siteId')"/>
<arg expression="get-property('productId')"/>
<arg expression="get-property('perfDateList')"/>
<arg expression="get-property('marketingCode')"/>
<arg expression="get-property('targetSystem')"/>
<arg expression="get-property('sessionId')"/>
</args>
</payloadFactory>
<log category="INFO" level="custom" separator=",">
<property expression="//*" name="Triggering getLocation API call.."/>
</log>
<callout action="urn:Pool_SendXMLRequest" serviceURL="http://localhost:8989/GetLocation/">
<source type="envelope"/>
<target xpath="//result"/>
</callout>
<log category="INFO" level="full" separator=","/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
I have observed two things, the log mediator that was dumping the payload before even i make the second service call was showing the payload three times - not sure if I am missing something. Here is how the payload gets duplicated..
2014-04-18 09:32:27,961 [-] [PassThroughMessageProcessor-20] INFO CreateListingFromGetLocation Triggering getSession API call.. = <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Body><tem:Pool_GetNewSession><tem:Name>Rama</tem:Name><tem:Password>Ramapass</tem:Password><tem:ClientIP>1.11.111.111</tem:ClientIP></tem:Pool_GetNewSession></soapenv:Body></soapenv:Envelope><soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"></soapenv:Header><soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><tem:Pool_GetNewSession xmlns:tem="http://tempuri.org/"><tem:Name>Rama</tem:Name><tem:Password>Ramapass</tem:Password><tem:ClientIP>1.11.111.111</tem:ClientIP></tem:Pool_GetNewSession></soapenv:Body><tem:Pool_GetNewSession xmlns:tem="http://tempuri.org/"><tem:Name>Rama</tem:Name><tem:Password>Ramapass</tem:Password><tem:ClientIP>1.11.111.111</tem:ClientIP></tem:Pool_GetNewSession>RamaRamapass1.11.111.111
2014-04-18 09:32:27,972 [-] [PassThroughMessageProcessor-20] INFO CreateListingFromGetLocation SessionID = vf103lotgawlfltjjuldtamv|51
2014-04-18 09:32:27,980 [-] [PassThroughMessageProcessor-20] INFO CreateListingFromGetLocation Triggering getLocation API call.. = <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Body><tem:Pool_SendXMLRequest><tem:Name>Rama</tem:Name><tem:SiteID>51</tem:SiteID><tem:sXMLInput><request xmlns="http://ws.apache.org/ns/synapse"><displaydata><fetch_display_data><fn_name>eapi_fetch_mkt_locations_mkt</fn_name><param type="operator">Rama</param><param type="string">51</param><param type="string">8351</param><param type="string">12/13/2014 E</param><param type="string">Premium</param></fetch_display_data></displaydata></request></tem:sXMLInput><tem:TargetSystem>Govinda</tem:TargetSystem><tem:Session>vf103lotgawlfltjjuldtamv|51</tem:Session></tem:Pool_SendXMLRequest></soapenv:Body></soapenv:Envelope><soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"></soapenv:Header><soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><tem:Pool_SendXMLRequest xmlns:tem="http://tempuri.org/"><tem:Name>Rama</tem:Name><tem:SiteID>51</tem:SiteID><tem:sXMLInput><request xmlns="http://ws.apache.org/ns/synapse"><displaydata><fetch_display_data><fn_name>eapi_fetch_mkt_locations_mkt</fn_name><param type="operator">Rama</param><param type="string">51</param><param type="string">8351</param><param type="string">12/13/2014 E</param><param type="string">Premium</param></fetch_display_data></displaydata></request></tem:sXMLInput><tem:TargetSystem>Govinda</tem:TargetSystem><tem:Session>vf103lotgawlfltjjuldtamv|51</tem:Session></tem:Pool_SendXMLRequest></soapenv:Body><tem:Pool_SendXMLRequest xmlns:tem="http://tempuri.org/"><tem:Name>Rama</tem:Name><tem:SiteID>51</tem:SiteID><tem:sXMLInput><request xmlns="http://ws.apache.org/ns/synapse"><displaydata><fetch_display_data><fn_name>eapi_fetch_mkt_locations_mkt</fn_name><param type="operator">Rama</param><param type="string">51</param><param type="string">8351</param><param type="string">12/13/2014 E</param><param type="string">Premium</param></fetch_display_data></displaydata></request></tem:sXMLInput><tem:TargetSystem>Govinda</tem:TargetSystem><tem:Session>vf103lotgawlfltjjuldtamv|51</tem:Session></tem:Pool_SendXMLRequest>Rama51<tem:sXMLInput xmlns:tem="http://tempuri.org/"><request xmlns="http://ws.apache.org/ns/synapse"><displaydata><fetch_display_data><fn_name>eapi_fetch_mkt_locations_mkt</fn_name><param type="operator">Rama</param><param type="string">51</param><param type="string">8351</param><param type="string">12/13/2014 E</param><param type="string">Premium</param></fetch_display_data></displaydata></request></tem:sXMLInput><request xmlns="http://ws.apache.org/ns/synapse"><displaydata><fetch_display_data><fn_name>eapi_fetch_mkt_locations_mkt</fn_name><param type="operator">Rama</param><param type="string">51</param><param type="string">8351</param><param type="string">12/13/2014 E</param><param type="string">Premium</param></fetch_display_data></displaydata></request><displaydata xmlns="http://ws.apache.org/ns/synapse"><fetch_display_data><fn_name>eapi_fetch_mkt_locations_mkt</fn_name><param type="operator">Rama</param><param type="string">51</param><param type="string">8351</param><param type="string">12/13/2014 E</param><param type="string">Premium</param></fetch_display_data></displaydata><fetch_display_data xmlns="http://ws.apache.org/ns/synapse"><fn_name>eapi_fetch_mkt_locations_mkt</fn_name><param type="operator">Rama</param><param type="string">51</param><param type="string">8351</param><param type="string">12/13/2014 E</param><param type="string">Premium</param></fetch_display_data>eapi_fetch_mkt_locations_mktRama51835112/13/2014 EPremiumGovindavf103lotgawlfltjjuldtamv|51
I might be doing something wrong when I construct the request payload for second service call..
Can someone help?
Looks like its a logging issue but the data is going fine.

How to make a dynamic xPath and execute it?

I collect string to xpath
<property xmlns:t="https://services" name="xPathElemet" expression="fn:concat(//t:SNILS/, $func:element)"/>
and I want to run this xpath and write the value of a Property
<property name="KEY" expression="get-property('xPathElemet')"/>
but receive only collected a string
how to xpath of the Property?
example code sequence :
<iterate continueParent="true" expression="//t:Employee">
<target>
<sequence>
<call-template target="save_element">
<with-param name="key_element" value="Name"/>
</call-template>
</sequence>
</target>
</iterate>
example code template :
<template xmlns="http://ws.apache.org/ns/synapse" name="save_element">
<parameter name="key_element"/> <!--example: "Name"-->
<sequence>
<property name="KEY" expression="fn:concat(//t:Employee/t:SNILS, ':' ,$func:key_element)" scope="default"
type="STRING"/> <!--example: "111-111-111-1:Name"-->
<property name="xPathElemet" expression="fn:concat('//t:Employee/t:', $func:element)"/> <!--example: "//t:Employee/t:Name"-->
<property name="VALUE" expression="get-property('xPathElemet')" scope="default" type="STRING"/> <!--example: Den (Now it does not work)-->
<dbreport>
<connection>
<pool>
<seetings/>
</pool>
</connection>
<statement>
<sql>
<![CDATA[insert into cache( key , value ) values (?, ?);]]></sql> <!--insert new line where key = "111-111-111-1:Name" and value = "Den"-->
<parameter expression="get-property('KEY')" type="VARCHAR"/>
<parameter expression="get-property('VALUE')" type="VARCHAR"/>
</statement>
</dbreport>
</sequence>
</template>
example xml:
<Employees xmlns="https://services">
<Employee>
<SNILS>111-111-111-1</SNILS>
<Name>Den</Name>
</Employee>
<Employee>
<SNILS>111-111-111-2</SNILS>
<Name>Elena</Name>
</Employee>
</Employees>
Use evaluate
In your case:
<property xmlns:t="https://services" name="xPathElemet" expression="fn:concat(//t:SNILS/, $func:element)"/>
<property name="KEY" expression="evaluate(get-property('xPathElemet'))"/>
You can find more infomation in this blog.
Please try the following and see if it works
<property xmlns:t="https://services" name="xPathElemet" expression="fn:concat(//t:SNILS/, $func:element)"/>
<property xmlns:t="https://services" name="xPathfull" expression="fn:concat(get-property('xPathElemet'),'/text()')"/>
<property name="KEY" expression="get-property('xPathfull')"/>
What was missing from your code was the /text() which refer to the parameters of the given xpath. Please try this