Uploaded image for project: 'Synapse'
  1. Synapse
  2. SYNAPSE-503

get-property function is not recognized in xquery variable expression attribute

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.0
    • Extension Mediators
    • None

    Description

      I'm transforming response of the remote service in outSequence of a proxy.
      I'm using xquery mediator. I want to change the format of the payload of the response
      and also I want to insert a payload of the request into a first element of the response.

      To do that, I'm storing the request A payload in a variable in inSequence and in outSequence
      I'm want to use it in XQUERY mediator while transforming the response.

      1. proxy: gets request A,
      2. inSequence: stores the payload A in a property named "body" (it will be used in outSeqence),
      2. inSequence: transforms request A to request B,
      3. endpoint: sends request B to remote service,
      4. endpoint: receives response B,
      5. outSequence: transforms response B to response A with request A included.

      Here's a fragments of the synapse.xml:

      Storing the payload contents in the "body" property:
      <property name="body" expression="$body/child::*[position()=1]" />

      Transforming response to other format and passing request payload as a argument:
      <xquery key="response.xq" trace="enable">
      <variable name="payload" type="ELEMENT"/>
      <variable name="request" expression="synapse:get-property('body')" type="ELEMENT"/>
      </xquery>

      On the runtime I've got following exception:

      2009-02-13 20:42:07,359 [192.168.168.6-5MBTB3J] [HttpClientWorker-2] ERROR XQueryMediator Unable to execute the query
      org.apache.synapse.SynapseException: Error evaluating XPath synapse:get-property('body') on message<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:kom="http://www.eurobank.pl/serwisy/paybylink/1.0/komunikaty"><soapenv:Header>
      [...header contents...]</soapenv:Header>[... payload contents...]
      </soapenv:Body></soapenv:Envelope>
      at org.apache.synapse.mediators.xquery.MediatorCustomVariable.handleException(MediatorCustomVariable.java:165)
      at org.apache.synapse.mediators.xquery.MediatorCustomVariable.evaluate(MediatorCustomVariable.java:153)
      at org.apache.synapse.mediators.xquery.MediatorCustomVariable.evaluateValue(MediatorCustomVariable.java:93)
      at org.apache.synapse.mediators.xquery.XQueryMediator.performQuery(XQueryMediator.java:312)
      at org.apache.synapse.mediators.xquery.XQueryMediator.mediate(XQueryMediator.java:160)
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:61)
      at org.apache.synapse.config.xml.AnonymousListMediator.mediate(AnonymousListMediator.java:30)
      at org.apache.synapse.config.xml.SwitchCase.mediate(SwitchCase.java:65)
      at org.apache.synapse.mediators.filters.SwitchMediator.mediate(SwitchMediator.java:111)
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:61)
      at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:111)
      at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:140)
      at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:312)
      at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:133)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
      at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:210)
      at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
      at java.lang.Thread.run(Thread.java:619)
      2009-02-13 20:42:07,359 [192.168.168.6-5MBTB3J] [HttpClientWorker-2] ERROR SynapseCallbackReceiver Synapse encountered an exception, No error handlers found - [Message Dropped]
      Unable to execute the query

      After looking a bit at XQueryMediator code it seems it uses AXIOMXPath class instead of SynapseXPath class.
      This seems to be a reason of the exception.

      I also tried to used XSLT mediator with similar parameters (see below) and the property is set correctly,
      ( XSLTMediator uses SynapseXPath class for evaluating values of properties).

      <xslt key="response.xsl">
      <property name="requestBody" expression="get-property('body')"/>
      </xslt>

      Attachments

        Activity

          People

            indika Indika Kumara
            michal.stochmialek Michal Stochmialek
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: