[ 
https://issues.apache.org/activemq/browse/SM-1307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Freeman Fang updated SM-1307:
-----------------------------

    Fix Version/s:     (was: 3.2.2)

> Rest provide marshaler
> ----------------------
>
>                 Key: SM-1307
>                 URL: https://issues.apache.org/activemq/browse/SM-1307
>             Project: ServiceMix
>          Issue Type: Improvement
>          Components: servicemix-core, servicemix-http
>    Affects Versions: 3.2.1
>            Reporter: Tom Purcell
>            Assignee: Guillaume Nodet
>             Fix For: 3.3
>
>         Attachments: RestProviderMarshaler.java, RestProviderMarshaler.java, 
> RestProviderMarshaler.java, 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 call.
> 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.

Reply via email to