servicemix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Purcell (JIRA)" <>
Subject [jira] Updated: (SM-1307) DefaultHttpProviderMarshaler: Make it possible to extract the XML content from the NMR.
Date Thu, 10 Apr 2008 15:09:43 GMT


Tom Purcell updated SM-1307:

Extending org.apache.servicemix.expression.Expression

JAXPXPathExpression, JaxenXPathExpression and XMLBeansXPathExpression all extend Expression.
This is nice because the fact that they all implement the same interface allowscan easily
configure SMX to configure any one of the three as the bean class on the locationURIExpression
property of the marshaler. The commom method has the following signature:

Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException;

The code submitted in the attacthed servicemixRestSupport.tar.gz has a svn diff of the JAXPXPathExpression
with the following new method:

public Object evaluate(MessageExchange exchange, NormalizedMessage message, QName returnType)
throws MessagingException 

This adding this method to the Expression interface would not be a problem for either JAXPXPathExpression
or JaxenXPathExpression. The JaxenXPathExpression code is almost identical to the JAXPXPathExpression
code and Jaxen supports the same kind of call with a "QName returnType".

A problem arises, however, with XMLBeansXPathExpression. XMLBeans does not directly support
a similar call but there is a similar method in XMLBeansXPathExpression:

protected Object evaluateXPath(XmlObject object, String xp, XmlOptions opts)

It is currently called by the XMLBeansXPathExpression evaluate method. The evaluate method
pulls the content out of NormalizedMethod and pass it, along with an empty(new) XmlOptions
object, to the evaluateXPath method above. A method like this could be added to the Expression

public Object evaluate(MessageExchange exchange, NormalizedMessage message, Object returnType)
throws MessagingException

This, along with a minor rework of XMLBeansXPathExpression, would have the effect of exposing
the contorl of the content of XmlOptions for XMLBeans implementations and maintian the swapability
of the three in terms of configuration.

It would, of course, leave us with a losely typed returnType parameter.

> DefaultHttpProviderMarshaler: Make it possible to extract the XML content from the NMR.
> ---------------------------------------------------------------------------------------
>                 Key: SM-1307
>                 URL:
>             Project: ServiceMix
>          Issue Type: Improvement
>          Components: servicemix-core, servicemix-http
>    Affects Versions: 3.2.1
>            Reporter: Tom Purcell
>         Attachments: servicemixRestSupport.tar.gz
> The current implementation of DefaultHttpProviderMarshaler the it is possible to construct
the location URI by specifying an XPath expression(locationURIExpression). Make it possible
to extract the XML content as well. In order to do this JAXPXPathExpression must change.
> In the SMX JAXPXPathExpression class the evaluateXPath(Object object) method calls the
javax.xml.xpath.XPathExpression evaluate(object) method. There are four implementations of
that method in XPathExpression. The one being called in the SMX JAXPXPathExpression class
returns a String. This String contains the VALUEs only, not the tags. This is great when you
need a value to build a URL but not when you need the actual XML. You need the NodeSet. Another
version of the XPathExpression evaluate method, evaluate(object, returnType), allows you to
control the return type by specifing one of the javax.xml.xpath.XPathConstants but the SMX
JAXPXPathExpression does not expose a way to call it. 
> The attached file contains the following
> An SVN diff of JAXPXPathExpression in which:
> - Changed:
> 	protected Object evaluateXPath(Object object) throws XPathExpressionException
>   To:
> 	protected Object evaluateXPath(Object object, QName returnType) throws XPathExpressionException
> - Added:
> 	public Object evaluate(MessageExchange exchange, NormalizedMessage message, QName returnType)
throws MessagingException
> - Changed:
> 	public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException
>   To call the new version above. It passes in XPathConstants.STRING as the QName to provide
backward compatibility. 
> The RestProviderMarshaler which:
> - Extends DefaultHttpProviderMarshaler and makes use of the nes functionality
> - Adds HttpStatus.SC_CREATED to the check for valid response codes in handleResponse(MessageExchange
exchange, SmxHttpExchange httpExchange). This is to support valid responses to a RESTful POST
> Below is a sample XBean config for the new http:provder:
>    <http:provider service="wile:wileRestService"
>                    interfaceName="wileCreate"
>                    endpoint="wileRestCreate"
>                    marshaler="#createMarshaler"/>
>     <bean id="createMarshaler" class="com.jbi.marshal.RestProviderMarshaler">
>         <property name="locationURIExpression">
>             <bean class="org.apache.servicemix.expression.JAXPStringXPathExpression">
>                 <constructor-arg
>                         value="concat('http://localhost:8080/wile-www/assetmanagement/assetservice/',/assetRequest/perspective)"/>
>             </bean>
>         </property>
>         <property name="method"
>                   value="POST"/>
>         <property name="contentType"
>                   value="application/x-www-form-urlencoded"/>
>         <property name="contentExpression">
>             <bean class="org.apache.servicemix.expression.JAXPStringXPathExpression">
>                 <constructor-arg value="//asset"/>
>             </bean>
>         </property>
>     </bean>

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

View raw message