[SWS-157] Contribution: XPathProxy Created: 11/Jul/07  Updated: 21/Nov/09  Resolved: 21/Nov/09

Status: Closed
Project: Spring Web Services
Component/s: XML
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Ray Krueger Assignee: Arjen Poutsma
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File xml-tiger-2007-11-20.zip     File xml-tiger.zip     File xpathproxy.zip    
Issue Links:
depends on SWS-159 XPath support needs Function and Vari... Reopened
is related to SWS-291 Annotation-based version of XPathPayl... Open


Previously mentioned here:

I will paraphrase in case the forums ever get changed again

I've built something here that might be a nice addition to an xml-tiger package.

Basically, it allows me to access xml like this (from my unit test):

<?xml version="1.0" encoding="UTF-8"?>
<s:Test xmlns:s="http://www.springframework.org/ws">
  <s:anotherString sneaky='boo'>World</s:anotherString>

With a proxy generated for an interface that looks like this (again from the unit test):

@NamespaceMapping(prefix = "s", uri = "http://www.springframework.org/ws")
public interface Sample {

    String getHello();

    String getWorld(String sneaky);

    Boolean booleanExists();

    Boolean booleanDoesNotExist();

    Boolean booleanTrueValue();

    Boolean booleanFalseValue();

    YesNo yesNo();

    Double doubleValue();

Quick notes...
The "getWorld" method uses an XPathVariableResolver to map the method arguments to xpath variables.

Like the XPathParam stuff in spring-ws, it supports the standard XPath types (String, Boolean, Double, Node, NodeList...). as well as using special Converters.

YesNo in the example above is an enum, a converter is registered with the XPathProxyFactory that allows the conversion of a string to some object.

XPath Booleans are touchy, they are based on existence, not content. This is the default behavior for the XPath proxy as well. Registering a Converter for Booleans though allows s:booleanFalse element above to evaluate to 'false'.

I figured that a spring-xml-tiger package would be a good home for it as it is all JAXP and Annotations. If not, maybe I'll toss it up to sourceforge or googlecode.

I'll attach a zip containing the code. Mind you it's totally "first-draft" quality; the package is "raykrueger.xpathproxy" and has almost no javadoc yet...

Comment by Ray Krueger [ 18/Jul/07 ]

xml-tiger is the new upload.

The package has been changed to org.springframework.xml.xpath.proxy

I cannot cut the XPath stuff over to the Spring XPathExpression abstractions completely until SWS-159 is complete.

The XPathProxy stuff relies on XPathVariableResolvers, and that abstraction doesn't exist yet.

Comment by Ray Krueger [ 16/Aug/07 ]

I have opened a project for this at google code.

I decided to do this as the current model doesn't rely on Spring at all an can be used in any java5 application. I was forcing Spring into it rather needlessly.

I have created a module of the project with spring-ws support for a AbstractXPathProxyPayloadEndpoint.
It extends the AbstractDomPayloadEndpoint so that it can wrap the request elment with the xpath proxy.

This allows for endpoints to be written that look like...

    public class XPathTargetEndpoint extends AbstractXPathProxyPayloadEndpoint<XPathTarget> {

        public XPathTargetEndpoint() {

        protected Element invokeWithProxy(XPathTarget proxy, Document responseDocument) throws Exception {
Comment by Ray Krueger [ 16/Aug/07 ]

No real reason to submit this to Spring now, so I'll close this.

Comment by Ray Krueger [ 16/Aug/07 ]

Sorry, this should be closed as "Won't Fix"

Comment by Arjen Poutsma [ 16/Aug/07 ]

Ok, I still think it's a great idea, and I can totally see why you don't want a Spring dependency. Good luck!

Comment by Ray Krueger [ 30/Sep/07 ]

I am going to re-open this.

Throwing it up on Google code was done just so I could start using it immediately. Really, having it out there permanently doesn't make since give that the project is like one class

I'll repackage it and upload it soon. Again, as a submission to a new spring-xml-tiger module.

Comment by Ray Krueger [ 06/Nov/07 ]

I'm gonna get this ported over for 1.1, I swear it.

Comment by Ray Krueger [ 19/Nov/07 ]

I've attached xml-tiger-2007-11-20.zip as the latest, and possibly final, fileset for xml-tiger.

Comment by Ray Krueger [ 19/Nov/07 ]

Arjen, would you mind reviewing xml-tiger-2007-11-20.zip?
Let me know if there are any code changes to be made. None of the files have headers, and probably aren't formatted to the project style.

I have not included the AbstractXPathProxyPayloadEndpoint in this initial set as it was part of a different module in the original project. I'll work on including that and support for an EndpointAdapter as well.

Comment by Arjen Poutsma [ 07/Feb/08 ]

Sorry, but I have no time to put this in 1.5 M2. Hopefully, I will have time for 1.5 RC.

Comment by Arjen Poutsma [ 05/May/08 ]

Since this feature requires a new module (xml-tiger), I simply cannot introduce this in 1.5.x, as much as I'd like to. Postponing to 1.6.

Comment by Ray Krueger [ 26/Oct/08 ]

I'm retracting this again heh
I'm hoping to take this in a different direction that won't involve WS usage.


Generated at Sat Apr 20 06:21:00 UTC 2019 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.