You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by "Asankha C. Perera (JIRA)" <ji...@apache.org> on 2008/02/07 06:15:07 UTC

[jira] Created: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Allow XPath expressions to be specified relative to envelope or body via an attribute
-------------------------------------------------------------------------------------

                 Key: SYNAPSE-235
                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
             Project: Synapse
          Issue Type: Improvement
            Reporter: Asankha C. Perera


This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc

Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


Re: [jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by Ruwan Linton <ru...@gmail.com>.
Andreas,

On Fri, Mar 14, 2008 at 3:22 AM, Andreas Veithen (JIRA) <ji...@apache.org>
wrote:

>
>    [
> https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578506#action_12578506]
>
> Andreas Veithen commented on SYNAPSE-235:
> -----------------------------------------
>
> Some more comments and suggestions:
>
> 1) SynapseXPath extends AXIOMXPath. I would prefer composition instead of
> inheritance here. Indeed, given the way we extend the functionality of
> AXIOMXPath, there is no longer an "is a" relation between SynapseXPath and
> AXIOMPath. Not having SynapseXPath extending AXIOMXPath directly would give
> us more control over how SynapseXPath objects are used. For example this
> would have prevented the problem I pointed out in my previous comment.
> Another example: for the moment nothing prevents the code from calling
> setVariableContext on a SynapseXPath object, but this would lead to
> unexpected results.
>
> I'm aware that this requires additional changes to SynapseXPathFactory and
> OMElementUtils, but I think that from a design point of view the effort is
> worth it.


Wont this limit the capabilities of the SynapseXPath? I think SynapseXPath
"is a" AXIOMXPath rather than SynapseXPath "contains a" AXIOMXPath.

Any way in my initial code I did this using composition and thought that it
is good to use inheritance here and also if you look at the current code,
there if you provide the MessageContext to evaluate the xpath then the
variables like $trp, $ctx will be available to the xpath. In the case of
SOAPEnvelope being evaluated by the xpath, the above variables does not be
effective (because there is no meaning for them when evaluated with
envelope) and the $body and $header variables are still effective and if you
provide any other object to the evaluate, then non of the variables are
effective because there is no concept of header and body in arbitrary
XMLNode? So I don't see any problem of using inheritance here....


>
>
> 2) We also need a ThreadSafeDelegatingFunctionContext to make SynapseXPath
> thread safe.


+1 I will add that.


>
>
> 3) SynapseVariableContext objects are stored in ThreadLocals and at the
> same time hold references to MessageContext and/or SOAPEnvelope objects. To
> avoid memory leaks, we need to release the reference to
> SynapseVariableContext after the evaluation. There should be a try-finally
> block with a call to ThreadSafeDelegatingFunctionContext #setDelegate(null).
> Idem for the function contexts.


+1, will do this too :)


>
>
> 4) There are hardcoded namespace prefix-URI mappings in
> SynapseXPath#evaluate and SynapseVariableContext#getVariableValue. I really
> don't like this because it is in contradiction with the fact that normally
> namespace prefixes can be chosen arbitrarily. I think we should only specify
> well defined namespace URIs and let the user define the prefix-URI mapping
> in the usual way. The config file would then look like this:
>
> <definitions xmlns="http://ws.apache.org/ns/synapse" xmlns:t="
> http://ws.apache.org/ns/synapse/xpath-vars/transport-headers">
>  ...
>    <... expression="$t:content-type"/>
>  ...
> </definitions>
>
> This is a bit more complicated, but it is the same approach as in XML
> Schema and especially XSLT. Also when reading a config file, somebody not
> familiar with our implicit XPath variables (but otherwise experienced with
> XML) would almost certainly try to find the namespace mapping to get an idea
> about where the variable comes for. If he sees something like "
> http://ws.apache.org/ns/synapse/xpath-vars/transport-headers" as the URI,
> this will become clear to him immediately. He can then get rest of the
> information from Google...


I agree with you, but I did this without a name space for the simplicity of
the configuration, other wise these name spaces are going to hang around in
nodes where there are xpaths (yes we can bring them to the top level
definition element) If all others are OK with going for a name space aware
variables that is you have to define the NS that you use for the variables I
am OK with this modification.

Thanks,
Ruwan

>
>
>
>
> > Allow XPath expressions to be specified relative to envelope or body via
> an attribute
> >
> -------------------------------------------------------------------------------------
> >
> >                 Key: SYNAPSE-235
> >                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
> >             Project: Synapse
> >          Issue Type: Improvement
> >            Reporter: Asankha C. Perera
> >            Assignee: Ruwan Linton
> >             Fix For: 1.2
> >
> >
> > This would make XPath expressions simpler without consideration for SOAP
> 1.1 or 1.2 or REST etc
> > Default could be envelope (i.e. what we have now - for backward
> compatibility), and an optional attribute could specify if it should be
> relative to the body
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
> For additional commands, e-mail: dev-help@synapse.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

Re: [jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by Ruwan Linton <ru...@gmail.com>.
OK, I will investigate this a little bit and incoperate this modification.
Well I too like to keep the properties of the XPath inside the XPath itself
otherwise we will not be able to define two XPaths in the same element
having two relatives.

Ruwan

On Wed, Mar 12, 2008 at 8:02 AM, Asankha C. Perera (JIRA) <ji...@apache.org>
wrote:

>
>    [
> https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577673#action_12577673]
>
> Asankha C. Perera commented on SYNAPSE-235:
> -------------------------------------------
>
> I like this suggestion very much.. +1
>
> This would be an elegant way to do this going forward, maybe similarly
> one could then write "$headers/.." etc as well to get to transport
> headers..
>
>
>
> > Allow XPath expressions to be specified relative to envelope or body via
> an attribute
> >
> -------------------------------------------------------------------------------------
> >
> >                 Key: SYNAPSE-235
> >                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
> >             Project: Synapse
> >          Issue Type: Improvement
> >            Reporter: Asankha C. Perera
> >            Assignee: Ruwan Linton
> >
> > This would make XPath expressions simpler without consideration for SOAP
> 1.1 or 1.2 or REST etc
> > Default could be envelope (i.e. what we have now - for backward
> compatibility), and an optional attribute could specify if it should be
> relative to the body
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
> For additional commands, e-mail: dev-help@synapse.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Ruwan Linton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577745#action_12577745 ] 

Ruwan Linton commented on SYNAPSE-235:
--------------------------------------

Andreas and Asankha,

I did a few researches on the idea of xpath variables and seems like it is a nice way of addressing the issue, and we can have even more variables defined for the xpaths like $header, $body and so on.

I will make the required improvements to this, and also we need to well document this since we are using the variable names conventionally without declaring them.

Ruwan

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578059#action_12578059 ] 

Andreas Veithen commented on SYNAPSE-235:
-----------------------------------------

I think we also have a concurrency issue in the SynapseXPath implementation. It seems that Jaxen's XPath objects are thread safe, but obviously if we call setFunctionContext or setVariableContext on each invocation of the evaluate method, this is no longer the case! There is an interesting discussion around that topic here:

http://www.nabble.com/Is-Jaxen-thread-safe--to13382743.html

I added a ThreadSafeDelegatingVariableContext in SVN to solve this issue. The idea is to call setVariableContext with an instance of this class in the constructor of SynapseXPath and then to call ThreadSafeDelegatingVariableContext#setDelegate in the evaluate method. We should also use the same pattern with function contexts. This should make SynapseXPath thread safe again. We could then also remove the synchronization from the getStringValue method.

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Asankha C. Perera (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577311#action_12577311 ] 

Asankha C. Perera commented on SYNAPSE-235:
-------------------------------------------

Lets just add an optional attribute [relative="body | envelope"] for now 
  :-) ?

asankha



> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Assigned: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Ruwan Linton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ruwan Linton reassigned SYNAPSE-235:
------------------------------------

    Assignee: Ruwan Linton

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578019#action_12578019 ] 

Andreas Veithen commented on SYNAPSE-235:
-----------------------------------------

Some comments on the "$transport/Content-Type" proposal:

I think Jaxen doesn't support mixing of different object models in the same XPath expression. Therefore to support this syntax we would have to construct an AXIOM tree from the transport headers (and also from the context properties, etc.). Also this kind of information is more naturally exposed via XPath functions, e.g. "get-property('OperationName')".

There is however a third possibility which is easy to implement and that provides a very elegant and compact syntax. It takes advantage of the fact that XPath variables also live in namespaces (i.e. variable names are QNames). If we define a mapping between header names and valid XPath variable names (e.g. Content-Type <-> contentType), then we could expose transport headers as XPath variables in a well defined namespace. Assuming that in the config file, this namespace is bound to the prefix "http", one could then refer to the Content-Type header by writing "$http:contentType".

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578027#action_12578027 ] 

Andreas Veithen commented on SYNAPSE-235:
-----------------------------------------

Ruwan,

I reviewed your modifications and I would like to propose a cleaner VariableContext implementation. I just checked it into SVN as SynapseVariableContext. The idea would be to replace the code in SynapseXPath#evaluate by:

setVariableContext(new SynapseVariableContext(env))
return super.evaluate(env);

My implementation avoids the "this.toString().indexOf("$body") != -1" tests and could also be a starting point for the ideas I suggested in my previous comment.

Note that SynapseVariableContext is not yet tested. Could you give it a try?

BTW: can somebody point me to a code formatter profile for Eclipse appropriate for Apache Synapse?

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Asankha C. Perera (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577673#action_12577673 ] 

Asankha C. Perera commented on SYNAPSE-235:
-------------------------------------------

I like this suggestion very much.. +1

This would be an elegant way to do this going forward, maybe similarly 
one could then write "$headers/.." etc as well to get to transport headers..



> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577641#action_12577641 ] 

Andreas Veithen commented on SYNAPSE-235:
-----------------------------------------

I know that you already started to modify the code, but I was wondering if it would not have been more elegant and perhaps even simpler to use XPath variables to do this. For example:

expression="$body/getQuote/request"

I'm not 100% sure that this is feasible, but I know that in XPath a variable can be a node set (meaning that it in particular it can reference a single node). Also, Jaxen supports this (see http://jaxen.codehaus.org/apidocs/org/jaxen/VariableContext.html). 


> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Ruwan Linton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577660#action_12577660 ] 

Ruwan Linton commented on SYNAPSE-235:
--------------------------------------

Well, even though I have changed the code a lot, changing the configuration is just changing one place (SynapseXPathFactory/SynapseXPathSerializer) and hence still there is room to decide on the correct configuration bits that goes with bodyRelative xpaths.

>From the configuration point, will this be OK, because if you look at the configuration then there is a xpath with xpath variables without declaring that variable inside synapse configuration???

Ruwan

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Ruwan Linton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577306#action_12577306 ] 

Ruwan Linton commented on SYNAPSE-235:
--------------------------------------

In-order to fix this issue we need to add an optional attribute to the elements which has xpath as an attribute to specify the bodyRelative or envelopeRelative nature of the xpath....

Since this is going to be another attribute on the same scope as the xpath attribute I don't quite like the attribute name "relative" having values body and envelope, because it is a property of the xpath that we are trying to configure through another attribute. On the other hand if we go to a attribute name like "xpathBodyRelative" having values true and false, then this is too long :(

One other solution is to add a special character in to the xpath it self and specify the relativity inside xpath itself... For example like;

expression="//getQuote/request, true" (if ',' is not significant in XPath)

Thoughts?

Ruwan

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Ruwan Linton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578344#action_12578344 ] 

Ruwan Linton commented on SYNAPSE-235:
--------------------------------------

Thanks for pointing that, I need to change the usages of the xpath, to use the evaluate(MessageContext) method rather than the evaluate(SOAPEnvelope)

Will do this chnange ASAP :)

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Ruwan Linton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578125#action_12578125 ] 

Ruwan Linton commented on SYNAPSE-235:
--------------------------------------

Andreas,

I think these suggestions are useful for us and will improve the XPath processing. I had a quick look at the two classes and seems OK to me. So I am going to incorporate these to the XPath improvements that we did, and the transport level headers support through XPath variables thing also seems good.

Thanks for the review and the comments.

Ruwan 

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578285#action_12578285 ] 

Andreas Veithen commented on SYNAPSE-235:
-----------------------------------------

I had a look at the modifications you did in revision 636660. You removed the SynapseXPath#evaluate(SOAPEnvelope) method by including the code into SynapseXPath#evaluate(MessageContext). I think this is not a good idea because in revision 636659, there is still code using this method. This code will now execute AXIOMPath#evaluate(Object) instead. Therefore the variable context will not be set up correctly. Can you check this?

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Ruwan Linton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578184#action_12578184 ] 

Ruwan Linton commented on SYNAPSE-235:
--------------------------------------

I did the changes and incorporated the changes with some improvements :) to support the transport headers and the message context properties as xpath variables. You may go through the code again :)

So in effect you can refer to the body content using $body/... and headers using $header/.... and can refer to the transport headers using the $trp:[header-name] where as [header-name] can be any of the header names. For example for the Content-Type http header the xpath is $trp:Content-Type

In the same manner you can access the message context properties using the $ctx:[property-name] or the axis2 message context properties using the $axis2:[property-name]

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Resolved: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Ruwan Linton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ruwan Linton resolved SYNAPSE-235.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2

I have fixed the root issue, I was wondering whether we can support this mechanism to retrieve the transport headers as well. 

(For example expression="$transport/Content-Type") This will add the ability to do routing depending on the transport header information in one step. Same with message context properties.

I will do a little more research on this.

> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


[jira] Commented: (SYNAPSE-235) Allow XPath expressions to be specified relative to envelope or body via an attribute

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SYNAPSE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578506#action_12578506 ] 

Andreas Veithen commented on SYNAPSE-235:
-----------------------------------------

Some more comments and suggestions:

1) SynapseXPath extends AXIOMXPath. I would prefer composition instead of inheritance here. Indeed, given the way we extend the functionality of AXIOMXPath, there is no longer an "is a" relation between SynapseXPath and AXIOMPath. Not having SynapseXPath extending AXIOMXPath directly would give us more control over how SynapseXPath objects are used. For example this would have prevented the problem I pointed out in my previous comment. Another example: for the moment nothing prevents the code from calling setVariableContext on a SynapseXPath object, but this would lead to unexpected results.

I'm aware that this requires additional changes to SynapseXPathFactory and OMElementUtils, but I think that from a design point of view the effort is worth it.

2) We also need a ThreadSafeDelegatingFunctionContext to make SynapseXPath thread safe.

3) SynapseVariableContext objects are stored in ThreadLocals and at the same time hold references to MessageContext and/or SOAPEnvelope objects. To avoid memory leaks, we need to release the reference to SynapseVariableContext after the evaluation. There should be a try-finally block with a call to ThreadSafeDelegatingFunctionContext #setDelegate(null). Idem for the function contexts.

4) There are hardcoded namespace prefix-URI mappings in SynapseXPath#evaluate and SynapseVariableContext#getVariableValue. I really don't like this because it is in contradiction with the fact that normally namespace prefixes can be chosen arbitrarily. I think we should only specify well defined namespace URIs and let the user define the prefix-URI mapping in the usual way. The config file would then look like this:

<definitions xmlns="http://ws.apache.org/ns/synapse" xmlns:t="http://ws.apache.org/ns/synapse/xpath-vars/transport-headers">
  ...
    <... expression="$t:content-type"/>
  ...
</definitions>

This is a bit more complicated, but it is the same approach as in XML Schema and especially XSLT. Also when reading a config file, somebody not familiar with our implicit XPath variables (but otherwise experienced with XML) would almost certainly try to find the namespace mapping to get an idea about where the variable comes for. If he sees something like "http://ws.apache.org/ns/synapse/xpath-vars/transport-headers" as the URI, this will become clear to him immediately. He can then get rest of the information from Google...



> Allow XPath expressions to be specified relative to envelope or body via an attribute
> -------------------------------------------------------------------------------------
>
>                 Key: SYNAPSE-235
>                 URL: https://issues.apache.org/jira/browse/SYNAPSE-235
>             Project: Synapse
>          Issue Type: Improvement
>            Reporter: Asankha C. Perera
>            Assignee: Ruwan Linton
>             Fix For: 1.2
>
>
> This would make XPath expressions simpler without consideration for SOAP 1.1 or 1.2 or REST etc
> Default could be envelope (i.e. what we have now - for backward compatibility), and an optional attribute could specify if it should be relative to the body

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org