You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Tom Purcell <tp...@chariotsolutions.com> on 2008/04/01 15:26:42 UTC
servicemix-http Post support
Hello
I'm trying to use the servicemix-http http:provider to call a RESTful
service. GET works fine but I'm having trouble trying to configure it to do
a post. It appears to me that DefaultHttpProviderMarshaler does not directly
support this and so I must write my own Marshaler to set the content. My
first question is just a request to verify that is correct and that I'm not
missing something.
My next question is about http://issues.apache.org/activemq/browse/SM-580
SM-580 . This appears to address this situation although I'm not certain it
does so in a RESTful way (I'm new to REST). SM-580 appears to be scheduled
for 3.3 so is this what I would use once 3.3 is released and when is 3.3
scheduled for release?
Thanks
Tom
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Okay
I realized that the return type of httpExchange.getResponseFields() was
HttpFields and that from that getFields() would give me an Iterator of
response fields. So I changed my code to do that but still no joy. I still
do not see a way to get a handle on the "Location" field in the response
header. My code is as follows:
public void handleResponse(MessageExchange exchange, SmxHttpExchange
httpExchange) throws Exception {
int response = httpExchange.getResponseStatus();
logger.debug("*** Exchange: " + httpExchange);
logger.debug("*** Response Content: " +
httpExchange.getResponseContent());
logger.debug("*** Response Data: " +
httpExchange.getResponseData());
logger.debug("*** Response Encoding: " +
httpExchange.getResponseEncoding());
logger.debug("*** Response Fields: " +
httpExchange.getResponseFields().getFields());
logger.debug("*** Response Reader: " +
httpExchange.getResponseReader());
logger.debug("*** Response Status: " + response);
logger.debug("*** Response Location Field: " +
httpExchange.getResponseFields().getStringField("Location"));
Iterator responseFields =
httpExchange.getResponseFields().getFields();
while (responseFields.hasNext()) {
Object o = responseFields.next();
logger.debug("*** responseFields o type: " + o.getClass());
}
Enumeration fieldNames =
httpExchange.getResponseFields().getFieldNames();
while (fieldNames.hasMoreElements()) {
Object o = fieldNames.nextElement();
logger.debug("*** fieldNames o type: " + o.getClass());
}
My log looks like this:
13:24:48,978 - DEBUG - RestProviderMarshaler - *** Exchange:
HttpExchange@1181578=POST//localhost:8080/wile-www/assetmanagement/assetservice/asset#7
13:24:48,979 - DEBUG - RestProviderMarshaler - *** Response Status:
201
13:24:48,979 - DEBUG - RestProviderMarshaler - *** Response
Content: null
13:24:48,979 - DEBUG - RestProviderMarshaler - *** Response Data:
null
13:24:48,980 - DEBUG - RestProviderMarshaler - *** Response
Encoding: utf-8
13:24:48,980 - DEBUG - RestProviderMarshaler - *** Response Fields:
org.mortbay.jetty.HttpFields$2@1ad067f
13:24:48,980 - DEBUG - RestProviderMarshaler - *** Response
Location Field: null
13:24:48,982 - DEBUG - RestProviderMarshaler - *** Response Reader:
null
Notice that I do not get into ether of the loops. It appears that all is
null. Am I missing something?
Thanks
Tom
Tom Purcell wrote:
>
> Guillaume
>
> I'm a little lost. I made the change we talked about below (adding
> SC_CREATED to the tested for acceptable response status) but now I'm
> getting an NPE processing the response. I put in a bunch of debugs.
>
> First output from tcpdump shows a what I think is a valid response:
> 11:25:17.388088 IP (tos 0x0, ttl 64, id 24951, offset 0, flags [DF],
> proto: TCP (6), length: 231) localhost.http-alt > localhost.34519: P,
> cksum 0xfedb (incorrect (-> 0x4298), 1:180(179) ack 943 win 277
> <nop,nop,timestamp 1769308 1769258>
> 0x0000: 4500 00e7 6177 4000 4006 da97 7f00 0001 E...aw@.@.......
> 0x0010: 7f00 0001 1f90 86d7 2b43 9e5d 2be5 ce25 ........+C.]+..%
> 0x0020: 8018 0115 fedb 0000 0101 080a 001a ff5c ...............\
> 0x0030: 001a ff2a 4854 5450 2f31 2e31 2032 3031 ...*HTTP/1.1.201
> 0x0040: 2043 7265 6174 6564 0d0a 5365 7276 6572 .Created..Server
> 0x0050: 3a20 4170 6163 6865 2d43 6f79 6f74 652f :.Apache-Coyote/
> 0x0060: 312e 310d 0a4c 6f63 6174 696f 6e3a 2037 1.1..Location:.7
> 0x0070: 4342 3232 4438 362d 3135 4534 2d43 4134 CB22D86-15E4-CA4
> 0x0080: 322d 4546 4137 2d44 3032 4442 4233 3241 2-EFA7-D02DBB32A
> 0x0090: 3830 300d 0a43 6f6e 7465 6e74 2d54 7970 800..Content-Typ
> 0x00a0: 653a 2074 6578 742f 786d 6c0d 0a43 6f6e e:.text/xml..Con
> 0x00b0: 7465 6e74 2d4c 656e 6774 683a 2030 0d0a tent-Length:.0..
> 0x00c0: 4461 7465 3a20 4d6f 6e2c 2030 3720 4170 Date:.Mon,.07.Ap
> 0x00d0: 7220 3230 3038 2031 353a 3235 3a31 3720 r.2008.15:25:17.
> 0x00e0: 474d 540d 0a0d 0a GMT....
>
> Wireshark picks out the field in the response I'm interested in:
> Location: 8C1D3B6A-608B-5840-2F26-4AEB6529DBF7\r\n
>
> The value associated with "Location" is the primary key of the item
> created in the data base by the web app I'm sending the POST to.
>
> My code looks like this:
> public void handleResponse(MessageExchange exchange, SmxHttpExchange
> httpExchange) throws Exception {
> int response = httpExchange.getResponseStatus();
> logger.debug("*** Exchange: " + httpExchange);
> logger.debug("*** Response Status: " + response);
> logger.debug("*** Response Content: " +
> httpExchange.getResponseContent());
> logger.debug("*** Response Data: " +
> httpExchange.getResponseData());
> logger.debug("*** Response Encoding: " +
> httpExchange.getResponseEncoding());
> logger.debug("*** Response Fields: " +
> httpExchange.getResponseFields());
> logger.debug("*** Response Reader: " +
> httpExchange.getResponseReader());
> logger.debug("*** Request Content : " +
> httpExchange.getRequestContent());
> logger.debug("*** Request Source : " +
> httpExchange.getRequestContentSource());
> logger.debug("*** Request Fields: " +
> httpExchange.getRequestFields());
>
> if (response != HttpStatus.SC_OK && response !=
> HttpStatus.SC_ACCEPTED && response != HttpStatus.SC_CREATED)
> if (!(exchange instanceof InOnly)) {
> logger.debug("*** InOnly");
> Fault fault = exchange.createFault();
> fault.setContent(new
> StreamSource(httpExchange.getResponseReader()));
> exchange.setFault(fault);
> } else {
> throw new Exception("Invalid status response: " +
> response);
> }
> } else if (exchange instanceof InOut) {
> logger.debug("*** InOut");
> NormalizedMessage msg = exchange.createMessage();
> msg.setContent(new
> StreamSource(httpExchange.getResponseReader()));
> logger.debug("*** msg Content: " + msg.getContent());
> exchange.setMessage(msg, "out");
> logger.debug("*** exchange message: " +
> exchange.getMessage("out"));...
>
> My log looks like this:
> 13:39:26,454 - DEBUG - RestProviderMarshaler - *** Exchange:
> HttpExchange@25741223=POST//localhost:8080/wile-www/assetmanagement/assetservice/asset#7
> 13:39:26,455 - DEBUG - RestProviderMarshaler - *** Response
> Status: 201
> 13:39:26,456 - DEBUG - RestProviderMarshaler - *** Response
> Content: null
> 13:39:26,457 - DEBUG - RestProviderMarshaler - *** Response Data:
> null
> 13:39:26,458 - DEBUG - RestProviderMarshaler - *** Response
> Encoding: utf-8
> 13:39:26,459 - DEBUG - RestProviderMarshaler - *** Response
> Fields:
>
> 13:39:26,460 - DEBUG - RestProviderMarshaler - *** Response
> Reader: null
> 13:39:26,461 - DEBUG - RestProviderMarshaler - *** Request
> Content :
> 13:39:26,462 - DEBUG - RestProviderMarshaler - *** Request Source
> : null
> 13:39:26,463 - DEBUG - RestProviderMarshaler - *** Request
> Fields: Host: localhost
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 793
>
>
> 13:39:26,464 - DEBUG - RestProviderMarshaler - *** InOut
> 13:39:26,465 - DEBUG - RestProviderMarshaler - *** msg Content:
> javax.xml.transform.stream.StreamSource@ebbf5f
> 13:39:26,466 - DEBUG - RestProviderMarshaler - *** exchange
> message:
> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1612394{properties:
> {}}
> 13:39:26,467 - DEBUG - DeliveryChannelImpl - Send
> ID:127.0.0.2-119295a616b-3:6 in DeliveryChannel{servicemix-http}
> 13:39:26,476 - TRACE - DeliveryChannelImpl - Sent: InOut[
> id: ID:127.0.0.2-119295a616b-3:6
> status: Active
> role: provider
> service: {http://www.sungard.com/wile}wileRestService
> endpoint: wileRestCreate
> in: <?xml version="1.0"
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> name="TestServerAsset1207593562444"> <class_type>ServerAsset</class_type>
> <description>This is a Test ServerAsset, created from
> TestAssetPersistenceTwo.</description>
> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
> <managed>true</managed> <category
> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
> <os>REDHAT LINUX</os>
> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
> <memory>2048</memory> <cpus>2</cpus> </asset> </assetRequest>
> out: Unable to display: java.io.IOException: No input stream or reader
> available
> ]
>
> Notice that all of the response fields are null or blank. I've been trying
> to figure out how to get a handle to that "Location" field but I got lost
> in mortbay code and thought you might be able to give me a shortcut.
>
> Thanks
> Tom
>
>
>
>
>
> gnodet wrote:
>>
>> On Fri, Apr 4, 2008 at 2:12 PM, Tom Purcell
>> <tp...@chariotsolutions.com>
>> wrote:
>>
>>>
>>>
>>> What does the 201 means in your case?
>>>
>>> Good question, 201 maps to SC_CREATED which seems an appropriate
>>> response
>>> to
>>> a post. Should:
>>> if (response != HttpStatus.SC_OK && response !=
>>> HttpStatus.SC_ACCEPTED)
>>>
>>> Be changed to:
>>> if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED
>>> &&
>>> response != HttpStatus.SC_CREATED)
>>>
>>>
>>>
>> Yes, i suppose it makes sense. Not sure in which case SC_ACCEPTED or
>> SC_CREATED is used.
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>>
>>
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16570253.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
Thanks for the response. We'll continue along this course than.
Thanks
Tom
gnodet wrote:
>
> On 4/22/08, Tom Purcell <tp...@chariotsolutions.com> wrote:
>>
>> Bruce
>>
>> Thanks for asking. The short answer is yes. I'm trying to use a
>> marshaller
>> to extract data from the message and use that data to construct the REST
>> URI. I have it all working but there are still two concerns. The first is
>> that in order to accomplish this I had to change SMX code in
>> JAXPXPathExpression. All the details on that can be found on
>> https://issues.apache.org/activemq/browse/SM-1307 SM-1307 . The concern
>> is
>> whether those changes will find their way into SMX or will we have to
>> find
>> another approach.
>>
>
> I had planned to commit it but did not found much time last week.
>
>
>> The other concern is detailed in
>> http://cwiki.apache.org/SM/discussion-forums.html#nabble-p16609525
>> another
>> thread . I started the separate thread because that issue seemed more
>> NMR
>> than REST related. I got distracted last week by other issues and have
>> not
>> been able to rule out a problem with the web app we need to talk or a
>> problem with my marshaller. I expect to resume work on this today. Any
>> thoughts or suggestions would be appreciated.
>>
>> Thanks
>> Tom
>>
>> bsnyder wrote:
>> >
>> > On Wed, Apr 9, 2008 at 6:55 AM, Tom Purcell
>> > <tp...@chariotsolutions.com> wrote:
>> >>
>> >> Done: https://issues.apache.org/activemq/browse/SM-1309 SM-1309
>> >>
>> >>
>> >> Good catch ! Could you raise a JIRA and I'll fix it asap.
>> >
>> > Tom, I'm just curious, what's the status of your work on this now? Did
>> > you get it working correctly?
>> >
>> > Bruce
>> > --
>> > perl -e 'print
>> > unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
>> > );'
>> >
>> > Apache ActiveMQ - http://activemq.org/
>> > Apache Camel - http://activemq.org/camel/
>> > Apache ServiceMix - http://servicemix.org/
>> > Apache Geronimo - http://geronimo.apache.org/
>> >
>> > Blog: http://bruceblog.org/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16824284.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16851016.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by gn...@gmail.com.
On 4/22/08, Tom Purcell <tp...@chariotsolutions.com> wrote:
>
> Bruce
>
> Thanks for asking. The short answer is yes. I'm trying to use a marshaller
> to extract data from the message and use that data to construct the REST
> URI. I have it all working but there are still two concerns. The first is
> that in order to accomplish this I had to change SMX code in
> JAXPXPathExpression. All the details on that can be found on
> https://issues.apache.org/activemq/browse/SM-1307 SM-1307 . The concern is
> whether those changes will find their way into SMX or will we have to find
> another approach.
>
I had planned to commit it but did not found much time last week.
> The other concern is detailed in
> http://cwiki.apache.org/SM/discussion-forums.html#nabble-p16609525 another
> thread . I started the separate thread because that issue seemed more NMR
> than REST related. I got distracted last week by other issues and have not
> been able to rule out a problem with the web app we need to talk or a
> problem with my marshaller. I expect to resume work on this today. Any
> thoughts or suggestions would be appreciated.
>
> Thanks
> Tom
>
> bsnyder wrote:
> >
> > On Wed, Apr 9, 2008 at 6:55 AM, Tom Purcell
> > <tp...@chariotsolutions.com> wrote:
> >>
> >> Done: https://issues.apache.org/activemq/browse/SM-1309 SM-1309
> >>
> >>
> >> Good catch ! Could you raise a JIRA and I'll fix it asap.
> >
> > Tom, I'm just curious, what's the status of your work on this now? Did
> > you get it working correctly?
> >
> > Bruce
> > --
> > perl -e 'print
> > unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> > );'
> >
> > Apache ActiveMQ - http://activemq.org/
> > Apache Camel - http://activemq.org/camel/
> > Apache ServiceMix - http://servicemix.org/
> > Apache Geronimo - http://geronimo.apache.org/
> >
> > Blog: http://bruceblog.org/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16824284.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Bruce
Thanks for asking. The short answer is yes. I'm trying to use a marshaller
to extract data from the message and use that data to construct the REST
URI. I have it all working but there are still two concerns. The first is
that in order to accomplish this I had to change SMX code in
JAXPXPathExpression. All the details on that can be found on
https://issues.apache.org/activemq/browse/SM-1307 SM-1307 . The concern is
whether those changes will find their way into SMX or will we have to find
another approach.
The other concern is detailed in
http://cwiki.apache.org/SM/discussion-forums.html#nabble-p16609525 another
thread . I started the separate thread because that issue seemed more NMR
than REST related. I got distracted last week by other issues and have not
been able to rule out a problem with the web app we need to talk or a
problem with my marshaller. I expect to resume work on this today. Any
thoughts or suggestions would be appreciated.
Thanks
Tom
bsnyder wrote:
>
> On Wed, Apr 9, 2008 at 6:55 AM, Tom Purcell
> <tp...@chariotsolutions.com> wrote:
>>
>> Done: https://issues.apache.org/activemq/browse/SM-1309 SM-1309
>>
>>
>> Good catch ! Could you raise a JIRA and I'll fix it asap.
>
> Tom, I'm just curious, what's the status of your work on this now? Did
> you get it working correctly?
>
> Bruce
> --
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
>
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> Apache Geronimo - http://geronimo.apache.org/
>
> Blog: http://bruceblog.org/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16824284.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Okay
I think I'm in pretty good shape. First, on the "problem with the web app we
need to talk to or a problem with my marshaller" issue the answer was really
both. The web app is returning an HTTP status code of 406 and an ugly NPE
message if an invocation of its REST interface fails for any reason. The NPE
is not helpful but that's a separate issue from what we need to deal with
here.
The real SMX side problem was that I was not handling the 406 status return
properly in the marshaller. I was just putting the incoming message text in
the MessageExchange. Down the line when SMX attempted to access the message
content it was apparently looking for a Reader and finding the text hence
the problem.
So I've reworked my RestProviderMarshaler. Its a bit more sophisticated in
handling the response. I'm not certain I'm handling the SourceStream and
Reader in the most efficient way and it would not deal with attachments
properly but it meets our needs and may serve as an example of plain vanilla
REST support. The code is below and attached to
https://issues.apache.org/activemq/browse/SM-1307. SM-1307
Thanks
Tom
package com.jbi.marshal;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.servicemix.expression.JAXPStringXPathExpression;
import org.apache.servicemix.http.endpoints.DefaultHttpProviderMarshaler;
import org.apache.servicemix.http.jetty.SmxHttpExchange;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.mortbay.io.ByteArrayBuffer;
import org.mortbay.jetty.HttpFields;
import org.mortbay.jetty.HttpHeaders;
import org.w3c.dom.Node;
import javax.jbi.messaging.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.xpath.XPathConstants;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.Iterator;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
* User: tpurcell
* Date: Mar 12, 2008
* Time: 3:37:47 PM
*
* Provides basic support for calling RESTful services using the
servicemix-http JBI component
*/
public class RestProviderMarshaler extends DefaultHttpProviderMarshaler {
private SourceTransformer transformer = new SourceTransformer();
private JAXPStringXPathExpression contentExpression;
/**
* Returns the XPath expression that decribes the content to send.
*
* @return JAXPStringXPathExpression XPath expression that decribes the
content to send
*/
public JAXPStringXPathExpression getContentExpression() {
return contentExpression;
}
/**
* Accepts the XPath expression that decribes the content to send.
*
* @param contentExpression JAXPStringXPathExpression that decribes the
content to send
*/
public void setContentExpression(JAXPStringXPathExpression
contentExpression) {
this.contentExpression = contentExpression;
}
public void createRequest(MessageExchange exchange, NormalizedMessage
inMsg, SmxHttpExchange httpExchange) throws Exception {
httpExchange.setURL(getLocationUri(exchange, inMsg));
// Temporary fix for bug in jetty-client 6.1.5
//
http://fisheye.codehaus.org/browse/jetty-contrib/jetty/trunk/contrib/client/src/main/java/org/mortbay/jetty/client/HttpConnection.java?r1=374&r2=378
httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
httpExchange.setMethod(getMethod(exchange, inMsg));
httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
getContentType(exchange, inMsg));
if (getHeaders() != null) {
for (Map.Entry<String, String> e : getHeaders().entrySet()) {
httpExchange.setRequestHeader(e.getKey(), e.getValue());
}
}
if (contentExpression != null) {
String contentToSend = applyContentExpression(exchange, inMsg);
if (contentToSend != null) {
httpExchange.setRequestContent(new
ByteArrayBuffer(contentToSend.getBytes()));
}
} else if (inMsg.getContent() != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
transformer.toResult(inMsg.getContent(), new
StreamResult(baos));
httpExchange.setRequestContent(new
ByteArrayBuffer(baos.toByteArray()));
}
}
/**
* Calls evaluate on the XPath expression requesting a
XPathConstants.NODE as the return type. This will make it
* possible for a SourceTransformer to construct a full XML
representation of the selected nodes.
*
* @param exchange MessageExchange to use on MessageVariableResolver
* @param inMsg NormalizedMessage to use on MessageVariableResolver
* @return String Contains the XML items described by the provided
XPath expression.
*/
protected String applyContentExpression(MessageExchange exchange,
NormalizedMessage inMsg) throws Exception {
String content = null;
if (contentExpression != null) {
Node node = (Node) contentExpression.evaluate(exchange, inMsg,
XPathConstants.NODE);
content = transformer.toString(new DOMSource(node));
}
if (content == null) {
throw new IllegalStateException("XPath expression failed. Unable
to find Content for exchange");
}
return content;
}
/**
* Accept the response from the RESTful service and pass it on to the
NMR
* @param exchange MessageExchange to use on
MessageVariableResolver
* @param httpExchange SmxHttpExchange which holds the response from
the RESTful service
* @throws Exception
*/
public void handleResponse(MessageExchange exchange, SmxHttpExchange
httpExchange) throws Exception {
int response = httpExchange.getResponseStatus();
if (exchange instanceof InOnly) {
processInOnly(exchange, response);
} else if (isSuccessful(response)) {
NormalizedMessage msg = exchange.createMessage();
msg.setContent(packageHttpResponse(httpExchange, response));
exchange.setMessage(msg, "out");
} else {
Fault fault = exchange.createFault();
fault.setContent(packageHttpResponse(httpExchange, response));
exchange.setFault(fault);
}
}
/**
* Handles InOnly MEP. If the call was not successful there's noone to
tell so throw an exception
*
* @param exchange MessageExchange to use on
MessageVariableResolver
* @param response HTTP Status Code returned by the RESTful service
*/
private void processInOnly(MessageExchange exchange, int response)
throws Exception {
if (isSuccessful(response)) {
exchange.setStatus(ExchangeStatus.DONE);
} else
throw new Exception("Invalid status response: " + response);
}
/**
* Returns true for the following HTTP staus codes as successful:
* OK 200 OK
* CREATED 201 Created
* ACCEPTED 202 Accepted
* NO_CONTENT 204 No Content
*
* False for all others.
*
* @param httpStatusCode Code to evaluate.
* @return True for the above codes. False for all others.
*/
public boolean isSuccessful(int httpStatusCode) {
if (httpStatusCode == HttpStatus.SC_OK ||
httpStatusCode == HttpStatus.SC_CREATED ||
httpStatusCode == HttpStatus.SC_ACCEPTED ||
httpStatusCode == HttpStatus.SC_NO_CONTENT) {
return true;
}
return false;
}
/**
* Provides basic packaging for the response from the RESTful service.
The XML returned has the following structure:
*
* <response>
* <http-status>
* <code>nnn</code>
* </http-status>
* <http-headers>
* <"header field name 1">header field value 1"</"header field
name 1">
* <"header field name 2">header field value 2"</"header field
name 2">
* ...
* <"header field name n">header field value n"</"header field
name n">
* </http-headers>
* <content>
* "Actual HTTP content(if any)"
* </content>
* </response>
*
* @param httpExchange SmxHttpExchange which holds the response from
the RESTful service
* @param response HTTP Status Code returned by the RESTful service
* @return StreamSource
*/
public StreamSource packageHttpResponse(SmxHttpExchange httpExchange,
int response) throws UnsupportedEncodingException {
StringBuffer responseBuffer = new StringBuffer();
responseBuffer.append("<response>");
responseBuffer.append("<http-status>");
responseBuffer.append("<code>" + response + "</code>");
responseBuffer.append("</http-status>");
responseBuffer.append("<http-headers>");
Iterator responseFields =
httpExchange.getResponseFields().getFields();
while (responseFields.hasNext()) {
HttpFields.Field httpField = (HttpFields.Field)
responseFields.next();
responseBuffer.append("<");
responseBuffer.append(httpField.getName());
responseBuffer.append(">");
responseBuffer.append(httpField.getValue());
responseBuffer.append("</");
responseBuffer.append(httpField.getName());
responseBuffer.append(">");
}
responseBuffer.append("</http-headers>");
if (httpExchange.getResponseData() != null) {
responseBuffer.append("<content>");
responseBuffer.append(httpExchange.getResponseContent());
responseBuffer.append("</content>");
} else {
responseBuffer.append("<content/>");
}
responseBuffer.append("</response>");
return new StreamSource(new InputStreamReader(new
ByteArrayInputStream(responseBuffer.toString().getBytes()), "utf-8"));
}
}
bsnyder wrote:
>
> On Wed, Apr 9, 2008 at 6:55 AM, Tom Purcell
> <tp...@chariotsolutions.com> wrote:
>>
>> Done: https://issues.apache.org/activemq/browse/SM-1309 SM-1309
>>
>>
>> Good catch ! Could you raise a JIRA and I'll fix it asap.
>
> Tom, I'm just curious, what's the status of your work on this now? Did
> you get it working correctly?
>
> Bruce
> --
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
>
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> Apache Geronimo - http://geronimo.apache.org/
>
> Blog: http://bruceblog.org/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16939009.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Bruce Snyder <br...@gmail.com>.
On Wed, Apr 9, 2008 at 6:55 AM, Tom Purcell
<tp...@chariotsolutions.com> wrote:
>
> Done: https://issues.apache.org/activemq/browse/SM-1309 SM-1309
>
>
> Good catch ! Could you raise a JIRA and I'll fix it asap.
Tom, I'm just curious, what's the status of your work on this now? Did
you get it working correctly?
Bruce
--
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'
Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/
Blog: http://bruceblog.org/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Done: https://issues.apache.org/activemq/browse/SM-1309 SM-1309
Good catch ! Could you raise a JIRA and I'll fix it asap.
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16585348.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
Good catch ! Could you raise a JIRA and I'll fix it asap.
On Wed, Apr 9, 2008 at 12:54 AM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
>
> I've been going through the SMX code and I just came across this.
> SmxHttpExchange overrides some of the onResponse... methods of
> org.mortbay.jetty.client.HttpExchange. The one that I think we are
> interested in is the one that handles the header.
>
> In HttpExchange the method is:
> onResponseHeader(Buffer name, Buffer value)
> But in SmxHttpExchange the method is:
> onResponsetHeader(Buffer name, Buffer value)
>
> Note the "t" in onResponsetHeader. As a result the empty HttpExchnage
> implementation gets called and we do not get the header.
>
> I put debugs in the method to see if it got called. It did not. I changed
> the name and it did. Here's the log:
> 17:40:05,758 - DEBUG - SmxHttpExchange - onResponseHeader
> 17:40:05,759 - DEBUG - SmxHttpExchange - Buffer name:
> [31577415,24727094,m=-1,g=0,p=6,c=6]={Server}
> 17:40:05,759 - DEBUG - SmxHttpExchange - Buffer value:
> [16629781,21881288,m=-1,g=30,p=47,c=4096]={Apache-Coyote/1.1}
> 17:40:05,760 - DEBUG - SmxHttpExchange - onResponseHeader
> 17:40:05,760 - DEBUG - SmxHttpExchange - Buffer name:
> [2238119,1555131,m=-1,g=0,p=8,c=8]={Location}
> 17:40:05,760 - DEBUG - SmxHttpExchange - Buffer value:
>
> [16629781,21881288,m=-1,g=59,p=95,c=4096]={9689BB46-1FEE-1842-1A03-FA222838B620}
> 17:40:05,761 - DEBUG - SmxHttpExchange - onResponseHeader
> 17:40:05,761 - DEBUG - SmxHttpExchange - Buffer name:
> [31748349,11936044,m=-1,g=0,p=12,c=12]={Content-Type}
> 17:40:05,761 - DEBUG - SmxHttpExchange - Buffer value:
> [16629781,21881288,m=-1,g=111,p=119,c=4096]={text/xml}
> 17:40:05,762 - DEBUG - SmxHttpExchange - onResponseHeader
> 17:40:05,762 - DEBUG - SmxHttpExchange - Buffer name:
> [20712074,14152675,m=-1,g=0,p=14,c=14]={Content-Length}
> 17:40:05,762 - DEBUG - SmxHttpExchange - Buffer value:
> [16629781,21881288,m=-1,g=137,p=138,c=4096]={0}
> 17:40:05,763 - DEBUG - SmxHttpExchange - onResponseHeader
> 17:40:05,763 - DEBUG - SmxHttpExchange - Buffer name:
> [30204536,2640049,m=-1,g=0,p=4,c=4]={Date}
> 17:40:05,763 - DEBUG - SmxHttpExchange - Buffer value:
> [16629781,21881288,m=-1,g=146,p=175,c=4096]={Tue, 08 Apr 2008 22:40:05
> GMT}
> 17:40:05,764 - DEBUG - SmxHttpExchange -
> onResponseHeaderComplete
>
> As you can see the second buffer has the name "{Location}" which is what
> I'm
> looking for.
>
> I would add that the web app responding to the call constructs the
> response
> as follows:
> return Response.created(new java.net.URI(guid)).build();
>
> This is calling the builder in javax.ws.rs.core.Response as defined in
> jsr311 so I'm pretty sure its responding appropriately.
>
> Thanks
> Tom
>
>
>
> gnodet wrote:
> >
> > Are you sure you should receive something in return from your POST
> request
> > ? It sounds like the server sends back a 201 / SC_CREATED and that's
> all.
> > I'm not sure if this is related to servicemix or the marshaler you are
> > creating.... Have you tried to send a request using a web form or any
> > other
> > mean and check what the output is ?
> >
> > On Mon, Apr 7, 2008 at 9:32 PM, Tom Purcell
> > <tp...@chariotsolutions.com>
> > wrote:
> >
> >>
> >> Guillaume
> >>
> >> I'm a little lost. I made the change we talked about below (adding
> >> SC_CREATED to the tested for acceptable response status) but now I'm
> >> getting
> >> an NPE processing the response. I put in a bunch of debugs.
> >>
> >> First output from tcpdump shows a what I think is a valid response:
> >> 11:25:17.388088 IP (tos 0x0, ttl 64, id 24951, offset 0, flags [DF],
> >> proto:
> >> TCP (6), length: 231) localhost.http-alt > localhost.34519: P, cksum
> >> 0xfedb
> >> (incorrect (-> 0x4298), 1:180(179) ack 943 win 277 <nop,nop,timestamp
> >> 1769308 1769258>
> >> 0x0000: 4500 00e7 6177 4000 4006 da97 7f00 0001 E...aw@
> .@.......
> >> 0x0010: 7f00 0001 1f90 86d7 2b43 9e5d 2be5 ce25
> ........+C.]+..%
> >> 0x0020: 8018 0115 fedb 0000 0101 080a 001a ff5c
> ...............\
> >> 0x0030: 001a ff2a 4854 5450 2f31 2e31 2032 3031
> ...*HTTP/1.1.201
> >> 0x0040: 2043 7265 6174 6564 0d0a 5365 7276 6572
> .Created..Server
> >> 0x0050: 3a20 4170 6163 6865 2d43 6f79 6f74 652f
> :.Apache-Coyote/
> >> 0x0060: 312e 310d 0a4c 6f63 6174 696f 6e3a 2037
> 1.1..Location:.7
> >> 0x0070: 4342 3232 4438 362d 3135 4534 2d43 4134
> CB22D86-15E4-CA4
> >> 0x0080: 322d 4546 4137 2d44 3032 4442 4233 3241
> 2-EFA7-D02DBB32A
> >> 0x0090: 3830 300d 0a43 6f6e 7465 6e74 2d54 7970
> 800..Content-Typ
> >> 0x00a0: 653a 2074 6578 742f 786d 6c0d 0a43 6f6e
> e:.text/xml..Con
> >> 0x00b0: 7465 6e74 2d4c 656e 6774 683a 2030 0d0a
> tent-Length:.0..
> >> 0x00c0: 4461 7465 3a20 4d6f 6e2c 2030 3720 4170
> Date:.Mon,.07.Ap
> >> 0x00d0: 7220 3230 3038 2031 353a 3235 3a31 3720
> r.2008.15:25:17.
> >> 0x00e0: 474d 540d 0a0d 0a GMT....
> >>
> >> Wireshark picks out the field in the response I'm interested in:
> >> Location: 8C1D3B6A-608B-5840-2F26-4AEB6529DBF7\r\n
> >>
> >> The value associated with "Location" is the primary key of the item
> >> created
> >> in the data base by the web app I'm sending the POST to.
> >>
> >> My code looks like this:
> >> public void handleResponse(MessageExchange exchange, SmxHttpExchange
> >> httpExchange) throws Exception {
> >> int response = httpExchange.getResponseStatus();
> >> logger.debug("*** Exchange: " + httpExchange);
> >> logger.debug("*** Response Status: " + response);
> >> logger.debug("*** Response Content: " +
> >> httpExchange.getResponseContent());
> >> logger.debug("*** Response Data: " +
> >> httpExchange.getResponseData());
> >> logger.debug("*** Response Encoding: " +
> >> httpExchange.getResponseEncoding());
> >> logger.debug("*** Response Fields: " +
> >> httpExchange.getResponseFields());
> >> logger.debug("*** Response Reader: " +
> >> httpExchange.getResponseReader());
> >> logger.debug("*** Request Content : " +
> >> httpExchange.getRequestContent());
> >> logger.debug("*** Request Source : " +
> >> httpExchange.getRequestContentSource());
> >> logger.debug("*** Request Fields: " +
> >> httpExchange.getRequestFields());
> >>
> >> if (response != HttpStatus.SC_OK && response !=
> >> HttpStatus.SC_ACCEPTED && response != HttpStatus.SC_CREATED)
> >> if (!(exchange instanceof InOnly)) {
> >> logger.debug("*** InOnly");
> >> Fault fault = exchange.createFault();
> >> fault.setContent(new
> >> StreamSource(httpExchange.getResponseReader()));
> >> exchange.setFault(fault);
> >> } else {
> >> throw new Exception("Invalid status response: " +
> >> response);
> >> }
> >> } else if (exchange instanceof InOut) {
> >> logger.debug("*** InOut");
> >> NormalizedMessage msg = exchange.createMessage();
> >> msg.setContent(new
> >> StreamSource(httpExchange.getResponseReader()));
> >> logger.debug("*** msg Content: " + msg.getContent());
> >> exchange.setMessage(msg, "out");
> >> logger.debug("*** exchange message: " +
> >> exchange.getMessage("out"));...
> >>
> >> My log looks like this:
> >> 13:39:26,454 - DEBUG - RestProviderMarshaler - *** Exchange:
> >> HttpExchange@25741223
> >> =POST//localhost:8080/wile-www/assetmanagement/assetservice/asset#7
> >> 13:39:26,455 - DEBUG - RestProviderMarshaler - *** Response
> >> Status:
> >> 201
> >> 13:39:26,456 - DEBUG - RestProviderMarshaler - *** Response
> >> Content: null
> >> 13:39:26,457 - DEBUG - RestProviderMarshaler - *** Response
> >> Data:
> >> null
> >> 13:39:26,458 - DEBUG - RestProviderMarshaler - *** Response
> >> Encoding: utf-8
> >> 13:39:26,459 - DEBUG - RestProviderMarshaler - *** Response
> >> Fields:
> >>
> >> 13:39:26,460 - DEBUG - RestProviderMarshaler - *** Response
> >> Reader:
> >> null
> >> 13:39:26,461 - DEBUG - RestProviderMarshaler - *** Request
> >> Content
> >> :
> >> 13:39:26,462 - DEBUG - RestProviderMarshaler - *** Request
> >> Source
> >> :
> >> null
> >> 13:39:26,463 - DEBUG - RestProviderMarshaler - *** Request
> >> Fields:
> >> Host: localhost
> >> Content-Type: application/x-www-form-urlencoded
> >> Content-Length: 793
> >>
> >>
> >> 13:39:26,464 - DEBUG - RestProviderMarshaler - *** InOut
> >> 13:39:26,465 - DEBUG - RestProviderMarshaler - *** msg
> Content:
> >> javax.xml.transform.stream.StreamSource@ebbf5f
> >> 13:39:26,466 - DEBUG - RestProviderMarshaler - *** exchange
> >> message:
> >> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1612394
> >> {properties:
> >> {}}
> >> 13:39:26,467 - DEBUG - DeliveryChannelImpl - Send
> >> ID:127.0.0.2-119295a616b-3:6 in DeliveryChannel{servicemix-http}
> >> 13:39:26,476 - TRACE - DeliveryChannelImpl - Sent: InOut[
> >> id: ID:127.0.0.2-119295a616b-3:6
> >> status: Active
> >> role: provider
> >> service:
> >> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> <http://www.sungard.com/wile%7DwileRestService>
> >> endpoint: wileRestCreate
> >> in: <?xml version="1.0"
> >> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >> name="TestServerAsset1207593562444">
> <class_type>ServerAsset</class_type>
> >> <description>This is a Test ServerAsset, created from
> >> TestAssetPersistenceTwo.</description>
> >> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
> >> <managed>true</managed> <category
> >> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
> >> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
> >> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/>
> <mfgName/>
> >> <os>REDHAT LINUX</os>
> >>
> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
> >> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
> >> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
> >> <memory>2048</memory> <cpus>2</cpus> </asset> </assetRequest>
> >> out: Unable to display: java.io.IOException: No input stream or reader
> >> available
> >> ]
> >>
> >> Notice that all of the response fields are null or blank. I've been
> >> trying
> >> to figure out how to get a handle to that "Location" field but I got
> lost
> >> in
> >> mortbay code and thought you might be able to give me a shortcut.
> >>
> >> Thanks
> >> Tom
> >>
> >>
> >>
> >>
> >>
> >> gnodet wrote:
> >> >
> >> > On Fri, Apr 4, 2008 at 2:12 PM, Tom Purcell
> >> > <tp...@chariotsolutions.com>
> >> > wrote:
> >> >
> >> >>
> >> >>
> >> >> What does the 201 means in your case?
> >> >>
> >> >> Good question, 201 maps to SC_CREATED which seems an appropriate
> >> response
> >> >> to
> >> >> a post. Should:
> >> >> if (response != HttpStatus.SC_OK && response !=
> >> >> HttpStatus.SC_ACCEPTED)
> >> >>
> >> >> Be changed to:
> >> >> if (response != HttpStatus.SC_OK && response !=
> >> HttpStatus.SC_ACCEPTED
> >> >> &&
> >> >> response != HttpStatus.SC_CREATED)
> >> >>
> >> >>
> >> >>
> >> > Yes, i suppose it makes sense. Not sure in which case SC_ACCEPTED or
> >> > SC_CREATED is used.
> >> >
> >> > --
> >> > Cheers,
> >> > Guillaume Nodet
> >> > ------------------------
> >> > Blog: http://gnodet.blogspot.com/
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16539106.html
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16575810.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
I've been going through the SMX code and I just came across this.
SmxHttpExchange overrides some of the onResponse... methods of
org.mortbay.jetty.client.HttpExchange. The one that I think we are
interested in is the one that handles the header.
In HttpExchange the method is:
onResponseHeader(Buffer name, Buffer value)
But in SmxHttpExchange the method is:
onResponsetHeader(Buffer name, Buffer value)
Note the "t" in onResponsetHeader. As a result the empty HttpExchnage
implementation gets called and we do not get the header.
I put debugs in the method to see if it got called. It did not. I changed
the name and it did. Here's the log:
17:40:05,758 - DEBUG - SmxHttpExchange - onResponseHeader
17:40:05,759 - DEBUG - SmxHttpExchange - Buffer name:
[31577415,24727094,m=-1,g=0,p=6,c=6]={Server}
17:40:05,759 - DEBUG - SmxHttpExchange - Buffer value:
[16629781,21881288,m=-1,g=30,p=47,c=4096]={Apache-Coyote/1.1}
17:40:05,760 - DEBUG - SmxHttpExchange - onResponseHeader
17:40:05,760 - DEBUG - SmxHttpExchange - Buffer name:
[2238119,1555131,m=-1,g=0,p=8,c=8]={Location}
17:40:05,760 - DEBUG - SmxHttpExchange - Buffer value:
[16629781,21881288,m=-1,g=59,p=95,c=4096]={9689BB46-1FEE-1842-1A03-FA222838B620}
17:40:05,761 - DEBUG - SmxHttpExchange - onResponseHeader
17:40:05,761 - DEBUG - SmxHttpExchange - Buffer name:
[31748349,11936044,m=-1,g=0,p=12,c=12]={Content-Type}
17:40:05,761 - DEBUG - SmxHttpExchange - Buffer value:
[16629781,21881288,m=-1,g=111,p=119,c=4096]={text/xml}
17:40:05,762 - DEBUG - SmxHttpExchange - onResponseHeader
17:40:05,762 - DEBUG - SmxHttpExchange - Buffer name:
[20712074,14152675,m=-1,g=0,p=14,c=14]={Content-Length}
17:40:05,762 - DEBUG - SmxHttpExchange - Buffer value:
[16629781,21881288,m=-1,g=137,p=138,c=4096]={0}
17:40:05,763 - DEBUG - SmxHttpExchange - onResponseHeader
17:40:05,763 - DEBUG - SmxHttpExchange - Buffer name:
[30204536,2640049,m=-1,g=0,p=4,c=4]={Date}
17:40:05,763 - DEBUG - SmxHttpExchange - Buffer value:
[16629781,21881288,m=-1,g=146,p=175,c=4096]={Tue, 08 Apr 2008 22:40:05 GMT}
17:40:05,764 - DEBUG - SmxHttpExchange -
onResponseHeaderComplete
As you can see the second buffer has the name "{Location}" which is what I'm
looking for.
I would add that the web app responding to the call constructs the response
as follows:
return Response.created(new java.net.URI(guid)).build();
This is calling the builder in javax.ws.rs.core.Response as defined in
jsr311 so I'm pretty sure its responding appropriately.
Thanks
Tom
gnodet wrote:
>
> Are you sure you should receive something in return from your POST request
> ? It sounds like the server sends back a 201 / SC_CREATED and that's all.
> I'm not sure if this is related to servicemix or the marshaler you are
> creating.... Have you tried to send a request using a web form or any
> other
> mean and check what the output is ?
>
> On Mon, Apr 7, 2008 at 9:32 PM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>> Guillaume
>>
>> I'm a little lost. I made the change we talked about below (adding
>> SC_CREATED to the tested for acceptable response status) but now I'm
>> getting
>> an NPE processing the response. I put in a bunch of debugs.
>>
>> First output from tcpdump shows a what I think is a valid response:
>> 11:25:17.388088 IP (tos 0x0, ttl 64, id 24951, offset 0, flags [DF],
>> proto:
>> TCP (6), length: 231) localhost.http-alt > localhost.34519: P, cksum
>> 0xfedb
>> (incorrect (-> 0x4298), 1:180(179) ack 943 win 277 <nop,nop,timestamp
>> 1769308 1769258>
>> 0x0000: 4500 00e7 6177 4000 4006 da97 7f00 0001 E...aw@.@.......
>> 0x0010: 7f00 0001 1f90 86d7 2b43 9e5d 2be5 ce25 ........+C.]+..%
>> 0x0020: 8018 0115 fedb 0000 0101 080a 001a ff5c ...............\
>> 0x0030: 001a ff2a 4854 5450 2f31 2e31 2032 3031 ...*HTTP/1.1.201
>> 0x0040: 2043 7265 6174 6564 0d0a 5365 7276 6572 .Created..Server
>> 0x0050: 3a20 4170 6163 6865 2d43 6f79 6f74 652f :.Apache-Coyote/
>> 0x0060: 312e 310d 0a4c 6f63 6174 696f 6e3a 2037 1.1..Location:.7
>> 0x0070: 4342 3232 4438 362d 3135 4534 2d43 4134 CB22D86-15E4-CA4
>> 0x0080: 322d 4546 4137 2d44 3032 4442 4233 3241 2-EFA7-D02DBB32A
>> 0x0090: 3830 300d 0a43 6f6e 7465 6e74 2d54 7970 800..Content-Typ
>> 0x00a0: 653a 2074 6578 742f 786d 6c0d 0a43 6f6e e:.text/xml..Con
>> 0x00b0: 7465 6e74 2d4c 656e 6774 683a 2030 0d0a tent-Length:.0..
>> 0x00c0: 4461 7465 3a20 4d6f 6e2c 2030 3720 4170 Date:.Mon,.07.Ap
>> 0x00d0: 7220 3230 3038 2031 353a 3235 3a31 3720 r.2008.15:25:17.
>> 0x00e0: 474d 540d 0a0d 0a GMT....
>>
>> Wireshark picks out the field in the response I'm interested in:
>> Location: 8C1D3B6A-608B-5840-2F26-4AEB6529DBF7\r\n
>>
>> The value associated with "Location" is the primary key of the item
>> created
>> in the data base by the web app I'm sending the POST to.
>>
>> My code looks like this:
>> public void handleResponse(MessageExchange exchange, SmxHttpExchange
>> httpExchange) throws Exception {
>> int response = httpExchange.getResponseStatus();
>> logger.debug("*** Exchange: " + httpExchange);
>> logger.debug("*** Response Status: " + response);
>> logger.debug("*** Response Content: " +
>> httpExchange.getResponseContent());
>> logger.debug("*** Response Data: " +
>> httpExchange.getResponseData());
>> logger.debug("*** Response Encoding: " +
>> httpExchange.getResponseEncoding());
>> logger.debug("*** Response Fields: " +
>> httpExchange.getResponseFields());
>> logger.debug("*** Response Reader: " +
>> httpExchange.getResponseReader());
>> logger.debug("*** Request Content : " +
>> httpExchange.getRequestContent());
>> logger.debug("*** Request Source : " +
>> httpExchange.getRequestContentSource());
>> logger.debug("*** Request Fields: " +
>> httpExchange.getRequestFields());
>>
>> if (response != HttpStatus.SC_OK && response !=
>> HttpStatus.SC_ACCEPTED && response != HttpStatus.SC_CREATED)
>> if (!(exchange instanceof InOnly)) {
>> logger.debug("*** InOnly");
>> Fault fault = exchange.createFault();
>> fault.setContent(new
>> StreamSource(httpExchange.getResponseReader()));
>> exchange.setFault(fault);
>> } else {
>> throw new Exception("Invalid status response: " +
>> response);
>> }
>> } else if (exchange instanceof InOut) {
>> logger.debug("*** InOut");
>> NormalizedMessage msg = exchange.createMessage();
>> msg.setContent(new
>> StreamSource(httpExchange.getResponseReader()));
>> logger.debug("*** msg Content: " + msg.getContent());
>> exchange.setMessage(msg, "out");
>> logger.debug("*** exchange message: " +
>> exchange.getMessage("out"));...
>>
>> My log looks like this:
>> 13:39:26,454 - DEBUG - RestProviderMarshaler - *** Exchange:
>> HttpExchange@25741223
>> =POST//localhost:8080/wile-www/assetmanagement/assetservice/asset#7
>> 13:39:26,455 - DEBUG - RestProviderMarshaler - *** Response
>> Status:
>> 201
>> 13:39:26,456 - DEBUG - RestProviderMarshaler - *** Response
>> Content: null
>> 13:39:26,457 - DEBUG - RestProviderMarshaler - *** Response
>> Data:
>> null
>> 13:39:26,458 - DEBUG - RestProviderMarshaler - *** Response
>> Encoding: utf-8
>> 13:39:26,459 - DEBUG - RestProviderMarshaler - *** Response
>> Fields:
>>
>> 13:39:26,460 - DEBUG - RestProviderMarshaler - *** Response
>> Reader:
>> null
>> 13:39:26,461 - DEBUG - RestProviderMarshaler - *** Request
>> Content
>> :
>> 13:39:26,462 - DEBUG - RestProviderMarshaler - *** Request
>> Source
>> :
>> null
>> 13:39:26,463 - DEBUG - RestProviderMarshaler - *** Request
>> Fields:
>> Host: localhost
>> Content-Type: application/x-www-form-urlencoded
>> Content-Length: 793
>>
>>
>> 13:39:26,464 - DEBUG - RestProviderMarshaler - *** InOut
>> 13:39:26,465 - DEBUG - RestProviderMarshaler - *** msg Content:
>> javax.xml.transform.stream.StreamSource@ebbf5f
>> 13:39:26,466 - DEBUG - RestProviderMarshaler - *** exchange
>> message:
>> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1612394
>> {properties:
>> {}}
>> 13:39:26,467 - DEBUG - DeliveryChannelImpl - Send
>> ID:127.0.0.2-119295a616b-3:6 in DeliveryChannel{servicemix-http}
>> 13:39:26,476 - TRACE - DeliveryChannelImpl - Sent: InOut[
>> id: ID:127.0.0.2-119295a616b-3:6
>> status: Active
>> role: provider
>> service:
>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>> endpoint: wileRestCreate
>> in: <?xml version="1.0"
>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> name="TestServerAsset1207593562444"> <class_type>ServerAsset</class_type>
>> <description>This is a Test ServerAsset, created from
>> TestAssetPersistenceTwo.</description>
>> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
>> <managed>true</managed> <category
>> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
>> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
>> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
>> <os>REDHAT LINUX</os>
>> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
>> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
>> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
>> <memory>2048</memory> <cpus>2</cpus> </asset> </assetRequest>
>> out: Unable to display: java.io.IOException: No input stream or reader
>> available
>> ]
>>
>> Notice that all of the response fields are null or blank. I've been
>> trying
>> to figure out how to get a handle to that "Location" field but I got lost
>> in
>> mortbay code and thought you might be able to give me a shortcut.
>>
>> Thanks
>> Tom
>>
>>
>>
>>
>>
>> gnodet wrote:
>> >
>> > On Fri, Apr 4, 2008 at 2:12 PM, Tom Purcell
>> > <tp...@chariotsolutions.com>
>> > wrote:
>> >
>> >>
>> >>
>> >> What does the 201 means in your case?
>> >>
>> >> Good question, 201 maps to SC_CREATED which seems an appropriate
>> response
>> >> to
>> >> a post. Should:
>> >> if (response != HttpStatus.SC_OK && response !=
>> >> HttpStatus.SC_ACCEPTED)
>> >>
>> >> Be changed to:
>> >> if (response != HttpStatus.SC_OK && response !=
>> HttpStatus.SC_ACCEPTED
>> >> &&
>> >> response != HttpStatus.SC_CREATED)
>> >>
>> >>
>> >>
>> > Yes, i suppose it makes sense. Not sure in which case SC_ACCEPTED or
>> > SC_CREATED is used.
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16539106.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16575810.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
Are you sure you should receive something in return from your POST request
? It sounds like the server sends back a 201 / SC_CREATED and that's all.
I'm not sure if this is related to servicemix or the marshaler you are
creating.... Have you tried to send a request using a web form or any other
mean and check what the output is ?
On Mon, Apr 7, 2008 at 9:32 PM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
>
> I'm a little lost. I made the change we talked about below (adding
> SC_CREATED to the tested for acceptable response status) but now I'm
> getting
> an NPE processing the response. I put in a bunch of debugs.
>
> First output from tcpdump shows a what I think is a valid response:
> 11:25:17.388088 IP (tos 0x0, ttl 64, id 24951, offset 0, flags [DF],
> proto:
> TCP (6), length: 231) localhost.http-alt > localhost.34519: P, cksum
> 0xfedb
> (incorrect (-> 0x4298), 1:180(179) ack 943 win 277 <nop,nop,timestamp
> 1769308 1769258>
> 0x0000: 4500 00e7 6177 4000 4006 da97 7f00 0001 E...aw@.@.......
> 0x0010: 7f00 0001 1f90 86d7 2b43 9e5d 2be5 ce25 ........+C.]+..%
> 0x0020: 8018 0115 fedb 0000 0101 080a 001a ff5c ...............\
> 0x0030: 001a ff2a 4854 5450 2f31 2e31 2032 3031 ...*HTTP/1.1.201
> 0x0040: 2043 7265 6174 6564 0d0a 5365 7276 6572 .Created..Server
> 0x0050: 3a20 4170 6163 6865 2d43 6f79 6f74 652f :.Apache-Coyote/
> 0x0060: 312e 310d 0a4c 6f63 6174 696f 6e3a 2037 1.1..Location:.7
> 0x0070: 4342 3232 4438 362d 3135 4534 2d43 4134 CB22D86-15E4-CA4
> 0x0080: 322d 4546 4137 2d44 3032 4442 4233 3241 2-EFA7-D02DBB32A
> 0x0090: 3830 300d 0a43 6f6e 7465 6e74 2d54 7970 800..Content-Typ
> 0x00a0: 653a 2074 6578 742f 786d 6c0d 0a43 6f6e e:.text/xml..Con
> 0x00b0: 7465 6e74 2d4c 656e 6774 683a 2030 0d0a tent-Length:.0..
> 0x00c0: 4461 7465 3a20 4d6f 6e2c 2030 3720 4170 Date:.Mon,.07.Ap
> 0x00d0: 7220 3230 3038 2031 353a 3235 3a31 3720 r.2008.15:25:17.
> 0x00e0: 474d 540d 0a0d 0a GMT....
>
> Wireshark picks out the field in the response I'm interested in:
> Location: 8C1D3B6A-608B-5840-2F26-4AEB6529DBF7\r\n
>
> The value associated with "Location" is the primary key of the item
> created
> in the data base by the web app I'm sending the POST to.
>
> My code looks like this:
> public void handleResponse(MessageExchange exchange, SmxHttpExchange
> httpExchange) throws Exception {
> int response = httpExchange.getResponseStatus();
> logger.debug("*** Exchange: " + httpExchange);
> logger.debug("*** Response Status: " + response);
> logger.debug("*** Response Content: " +
> httpExchange.getResponseContent());
> logger.debug("*** Response Data: " +
> httpExchange.getResponseData());
> logger.debug("*** Response Encoding: " +
> httpExchange.getResponseEncoding());
> logger.debug("*** Response Fields: " +
> httpExchange.getResponseFields());
> logger.debug("*** Response Reader: " +
> httpExchange.getResponseReader());
> logger.debug("*** Request Content : " +
> httpExchange.getRequestContent());
> logger.debug("*** Request Source : " +
> httpExchange.getRequestContentSource());
> logger.debug("*** Request Fields: " +
> httpExchange.getRequestFields());
>
> if (response != HttpStatus.SC_OK && response !=
> HttpStatus.SC_ACCEPTED && response != HttpStatus.SC_CREATED)
> if (!(exchange instanceof InOnly)) {
> logger.debug("*** InOnly");
> Fault fault = exchange.createFault();
> fault.setContent(new
> StreamSource(httpExchange.getResponseReader()));
> exchange.setFault(fault);
> } else {
> throw new Exception("Invalid status response: " +
> response);
> }
> } else if (exchange instanceof InOut) {
> logger.debug("*** InOut");
> NormalizedMessage msg = exchange.createMessage();
> msg.setContent(new
> StreamSource(httpExchange.getResponseReader()));
> logger.debug("*** msg Content: " + msg.getContent());
> exchange.setMessage(msg, "out");
> logger.debug("*** exchange message: " +
> exchange.getMessage("out"));...
>
> My log looks like this:
> 13:39:26,454 - DEBUG - RestProviderMarshaler - *** Exchange:
> HttpExchange@25741223
> =POST//localhost:8080/wile-www/assetmanagement/assetservice/asset#7
> 13:39:26,455 - DEBUG - RestProviderMarshaler - *** Response
> Status:
> 201
> 13:39:26,456 - DEBUG - RestProviderMarshaler - *** Response
> Content: null
> 13:39:26,457 - DEBUG - RestProviderMarshaler - *** Response Data:
> null
> 13:39:26,458 - DEBUG - RestProviderMarshaler - *** Response
> Encoding: utf-8
> 13:39:26,459 - DEBUG - RestProviderMarshaler - *** Response
> Fields:
>
> 13:39:26,460 - DEBUG - RestProviderMarshaler - *** Response
> Reader:
> null
> 13:39:26,461 - DEBUG - RestProviderMarshaler - *** Request
> Content
> :
> 13:39:26,462 - DEBUG - RestProviderMarshaler - *** Request Source
> :
> null
> 13:39:26,463 - DEBUG - RestProviderMarshaler - *** Request
> Fields:
> Host: localhost
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 793
>
>
> 13:39:26,464 - DEBUG - RestProviderMarshaler - *** InOut
> 13:39:26,465 - DEBUG - RestProviderMarshaler - *** msg Content:
> javax.xml.transform.stream.StreamSource@ebbf5f
> 13:39:26,466 - DEBUG - RestProviderMarshaler - *** exchange
> message:
> org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1612394
> {properties:
> {}}
> 13:39:26,467 - DEBUG - DeliveryChannelImpl - Send
> ID:127.0.0.2-119295a616b-3:6 in DeliveryChannel{servicemix-http}
> 13:39:26,476 - TRACE - DeliveryChannelImpl - Sent: InOut[
> id: ID:127.0.0.2-119295a616b-3:6
> status: Active
> role: provider
> service: {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> endpoint: wileRestCreate
> in: <?xml version="1.0"
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> name="TestServerAsset1207593562444"> <class_type>ServerAsset</class_type>
> <description>This is a Test ServerAsset, created from
> TestAssetPersistenceTwo.</description>
> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
> <managed>true</managed> <category
> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
> <os>REDHAT LINUX</os>
> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
> <memory>2048</memory> <cpus>2</cpus> </asset> </assetRequest>
> out: Unable to display: java.io.IOException: No input stream or reader
> available
> ]
>
> Notice that all of the response fields are null or blank. I've been trying
> to figure out how to get a handle to that "Location" field but I got lost
> in
> mortbay code and thought you might be able to give me a shortcut.
>
> Thanks
> Tom
>
>
>
>
>
> gnodet wrote:
> >
> > On Fri, Apr 4, 2008 at 2:12 PM, Tom Purcell
> > <tp...@chariotsolutions.com>
> > wrote:
> >
> >>
> >>
> >> What does the 201 means in your case?
> >>
> >> Good question, 201 maps to SC_CREATED which seems an appropriate
> response
> >> to
> >> a post. Should:
> >> if (response != HttpStatus.SC_OK && response !=
> >> HttpStatus.SC_ACCEPTED)
> >>
> >> Be changed to:
> >> if (response != HttpStatus.SC_OK && response !=
> HttpStatus.SC_ACCEPTED
> >> &&
> >> response != HttpStatus.SC_CREATED)
> >>
> >>
> >>
> > Yes, i suppose it makes sense. Not sure in which case SC_ACCEPTED or
> > SC_CREATED is used.
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16539106.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
I'm a little lost. I made the change we talked about below (adding
SC_CREATED to the tested for acceptable response status) but now I'm getting
an NPE processing the response. I put in a bunch of debugs.
First output from tcpdump shows a what I think is a valid response:
11:25:17.388088 IP (tos 0x0, ttl 64, id 24951, offset 0, flags [DF], proto:
TCP (6), length: 231) localhost.http-alt > localhost.34519: P, cksum 0xfedb
(incorrect (-> 0x4298), 1:180(179) ack 943 win 277 <nop,nop,timestamp
1769308 1769258>
0x0000: 4500 00e7 6177 4000 4006 da97 7f00 0001 E...aw@.@.......
0x0010: 7f00 0001 1f90 86d7 2b43 9e5d 2be5 ce25 ........+C.]+..%
0x0020: 8018 0115 fedb 0000 0101 080a 001a ff5c ...............\
0x0030: 001a ff2a 4854 5450 2f31 2e31 2032 3031 ...*HTTP/1.1.201
0x0040: 2043 7265 6174 6564 0d0a 5365 7276 6572 .Created..Server
0x0050: 3a20 4170 6163 6865 2d43 6f79 6f74 652f :.Apache-Coyote/
0x0060: 312e 310d 0a4c 6f63 6174 696f 6e3a 2037 1.1..Location:.7
0x0070: 4342 3232 4438 362d 3135 4534 2d43 4134 CB22D86-15E4-CA4
0x0080: 322d 4546 4137 2d44 3032 4442 4233 3241 2-EFA7-D02DBB32A
0x0090: 3830 300d 0a43 6f6e 7465 6e74 2d54 7970 800..Content-Typ
0x00a0: 653a 2074 6578 742f 786d 6c0d 0a43 6f6e e:.text/xml..Con
0x00b0: 7465 6e74 2d4c 656e 6774 683a 2030 0d0a tent-Length:.0..
0x00c0: 4461 7465 3a20 4d6f 6e2c 2030 3720 4170 Date:.Mon,.07.Ap
0x00d0: 7220 3230 3038 2031 353a 3235 3a31 3720 r.2008.15:25:17.
0x00e0: 474d 540d 0a0d 0a GMT....
Wireshark picks out the field in the response I'm interested in:
Location: 8C1D3B6A-608B-5840-2F26-4AEB6529DBF7\r\n
The value associated with "Location" is the primary key of the item created
in the data base by the web app I'm sending the POST to.
My code looks like this:
public void handleResponse(MessageExchange exchange, SmxHttpExchange
httpExchange) throws Exception {
int response = httpExchange.getResponseStatus();
logger.debug("*** Exchange: " + httpExchange);
logger.debug("*** Response Status: " + response);
logger.debug("*** Response Content: " +
httpExchange.getResponseContent());
logger.debug("*** Response Data: " +
httpExchange.getResponseData());
logger.debug("*** Response Encoding: " +
httpExchange.getResponseEncoding());
logger.debug("*** Response Fields: " +
httpExchange.getResponseFields());
logger.debug("*** Response Reader: " +
httpExchange.getResponseReader());
logger.debug("*** Request Content : " +
httpExchange.getRequestContent());
logger.debug("*** Request Source : " +
httpExchange.getRequestContentSource());
logger.debug("*** Request Fields: " +
httpExchange.getRequestFields());
if (response != HttpStatus.SC_OK && response !=
HttpStatus.SC_ACCEPTED && response != HttpStatus.SC_CREATED)
if (!(exchange instanceof InOnly)) {
logger.debug("*** InOnly");
Fault fault = exchange.createFault();
fault.setContent(new
StreamSource(httpExchange.getResponseReader()));
exchange.setFault(fault);
} else {
throw new Exception("Invalid status response: " + response);
}
} else if (exchange instanceof InOut) {
logger.debug("*** InOut");
NormalizedMessage msg = exchange.createMessage();
msg.setContent(new
StreamSource(httpExchange.getResponseReader()));
logger.debug("*** msg Content: " + msg.getContent());
exchange.setMessage(msg, "out");
logger.debug("*** exchange message: " +
exchange.getMessage("out"));...
My log looks like this:
13:39:26,454 - DEBUG - RestProviderMarshaler - *** Exchange:
HttpExchange@25741223=POST//localhost:8080/wile-www/assetmanagement/assetservice/asset#7
13:39:26,455 - DEBUG - RestProviderMarshaler - *** Response Status:
201
13:39:26,456 - DEBUG - RestProviderMarshaler - *** Response
Content: null
13:39:26,457 - DEBUG - RestProviderMarshaler - *** Response Data:
null
13:39:26,458 - DEBUG - RestProviderMarshaler - *** Response
Encoding: utf-8
13:39:26,459 - DEBUG - RestProviderMarshaler - *** Response Fields:
13:39:26,460 - DEBUG - RestProviderMarshaler - *** Response Reader:
null
13:39:26,461 - DEBUG - RestProviderMarshaler - *** Request Content
:
13:39:26,462 - DEBUG - RestProviderMarshaler - *** Request Source :
null
13:39:26,463 - DEBUG - RestProviderMarshaler - *** Request Fields:
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 793
13:39:26,464 - DEBUG - RestProviderMarshaler - *** InOut
13:39:26,465 - DEBUG - RestProviderMarshaler - *** msg Content:
javax.xml.transform.stream.StreamSource@ebbf5f
13:39:26,466 - DEBUG - RestProviderMarshaler - *** exchange
message:
org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@1612394{properties:
{}}
13:39:26,467 - DEBUG - DeliveryChannelImpl - Send
ID:127.0.0.2-119295a616b-3:6 in DeliveryChannel{servicemix-http}
13:39:26,476 - TRACE - DeliveryChannelImpl - Sent: InOut[
id: ID:127.0.0.2-119295a616b-3:6
status: Active
role: provider
service: {http://www.sungard.com/wile}wileRestService
endpoint: wileRestCreate
in: <?xml version="1.0"
encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
name="TestServerAsset1207593562444"> <class_type>ServerAsset</class_type>
<description>This is a Test ServerAsset, created from
TestAssetPersistenceTwo.</description>
<serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
<managed>true</managed> <category
guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
<os>REDHAT LINUX</os>
<host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
<domain_name>sgns.net</domain_name> <platform>OS64</platform>
<os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
<memory>2048</memory> <cpus>2</cpus> </asset> </assetRequest>
out: Unable to display: java.io.IOException: No input stream or reader
available
]
Notice that all of the response fields are null or blank. I've been trying
to figure out how to get a handle to that "Location" field but I got lost in
mortbay code and thought you might be able to give me a shortcut.
Thanks
Tom
gnodet wrote:
>
> On Fri, Apr 4, 2008 at 2:12 PM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>>
>> What does the 201 means in your case?
>>
>> Good question, 201 maps to SC_CREATED which seems an appropriate response
>> to
>> a post. Should:
>> if (response != HttpStatus.SC_OK && response !=
>> HttpStatus.SC_ACCEPTED)
>>
>> Be changed to:
>> if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED
>> &&
>> response != HttpStatus.SC_CREATED)
>>
>>
>>
> Yes, i suppose it makes sense. Not sure in which case SC_ACCEPTED or
> SC_CREATED is used.
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16539106.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
On Fri, Apr 4, 2008 at 2:12 PM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
>
> What does the 201 means in your case?
>
> Good question, 201 maps to SC_CREATED which seems an appropriate response
> to
> a post. Should:
> if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED)
>
> Be changed to:
> if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED
> &&
> response != HttpStatus.SC_CREATED)
>
>
>
Yes, i suppose it makes sense. Not sure in which case SC_ACCEPTED or
SC_CREATED is used.
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
"If you look at the test, it says:
if (!(exchange instanceof InOnly))
Note the negation of the test."
Sorry, end of long day, I missed the !.
What does the 201 means in your case?
Good question, 201 maps to SC_CREATED which seems an appropriate response to
a post. Should:
if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED)
Be changed to:
if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED &&
response != HttpStatus.SC_CREATED)
gnodet wrote:
>
> If you look at the test, it says:
> if (!(exchange instanceof InOnly))
> Note the negation of the test.
>
> Are you expecting a response later ?
> No.
>
> Thanks
> Tom
>
> The exception that happens when logging the message certainly is because
> ServiceMix expects either a 200 or 202 status code or a response. What
> does
> the 201 means in your case ? Are you expecting a response later ?
>
> On Thu, Apr 3, 2008 at 10:26 PM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>> Guillaume
>>
>> I've done some looking into the response issue. I added debugs to the
>> handleResponse method of my RestProviderMarshaler to figure out what was
>> happening. This is what the beginning of that method looks like. I only
>> included up to where things appear to go wrong. The only difference is
>> the
>> debugs:
>>
>> public void handleResponse(MessageExchange exchange, SmxHttpExchange
>> httpExchange) throws Exception {
>> int response = httpExchange.getResponseStatus();
>> logger.debug("*** Response Status: " + response);
>>
>> if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED)
>> {
>> if (!(exchange instanceof InOnly)) {
>> logger.debug("*** InOnly");
>>
>> Now in the log I get the following:
>> 15:12:52,646 - DEBUG - RestProviderMarshaler - *** Response
>> Status:
>> 201
>> 15:12:52,647 - DEBUG - RestProviderMarshaler - *** InOnly
>> 15:12:52,647 - DEBUG - DeliveryChannelImpl - Send
>> ID:127.0.0.2-1191563e603-3:10 in DeliveryChannel{servicemix-http}
>> 15:12:52,652 - TRACE - DeliveryChannelImpl - Sent: InOut[
>> id: ID:127.0.0.2-1191563e603-3:10
>> status: Active
>> role: provider
>> service:
>> {http://www.abc.com/wile}wileRestService<http://www.abc.com/wile%7DwileRestService>
>> endpoint: wileRestCreate
>> in: <?xml version="1.0"
>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset...
>> NOTE: DOTS BY ME TO SHORTEN EMAIL
>> ...</assetRequest>
>> fault: Unable to display: java.io.IOException: No input stream or reader
>> available
>> ]
>>
>> It starts out good. We get a 201. But why are we in the InOnly code? The
>> subsequent TRACE - DeliveryChannelImpl message says we are InOut. I'm not
>> sure what to do here.
>>
>> Thanks
>> Tom
>>
>>
>>
>> Tom Purcell wrote:
>> >
>> > Guillaume
>> >
>> > I've made some progress. This is what I did.
>> >
>> > First, I switched to JAXP instead of Jaxen. The ONLY reason for this is
>> > I'm on a corporate network and they will not allow access to any URL
>> with
>> > the "jaxen" in it thus making research difficult. (not your problem,
>> just
>> > venting).
>> >
>> > I understood what you were saying about using a SourceTransformer
>> instead
>> > of toString() but the problem is that by the time my getContentToSend()
>> > gets the result of the XPath evaluation it is already a String with the
>> > XML tags stripped out.
>> >
>> > 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.
>> >
>> > I need the NodeSet. Another version of the XPathExpression evaluate
>> > method, evaluate(object, returnType), allows you to control the return
>> > type but the SMX JAXPXPathExpression does not expose a way to call it.
>> I
>> > went into the SMX JAXPXPathExpression class and did the following:
>> >
>> > 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.
>> >
>> > In my new RestProviderMarshaler:
>> > protected String getContentToSend(MessageExchange exchange,
>> > NormalizedMessage inMsg) throws Exception {
>> > String content = null;
>> >
>> > if (contentExpression != null) {
>> > logger.debug("*** Evaluate toString: " +
>> > contentExpression.evaluate(exchange, inMsg));
>> > Node node = (Node)contentExpression.evaluate(exchange, inMsg,
>> > XPathConstants.NODE);
>> > content = transformer.toString(new DOMSource(node));
>> > logger.debug("*** Content toString: " + content);
>> > }
>> >
>> > if (content == null) {
>> > throw new IllegalStateException("Unable to find Content for
>> > exchange");
>> > }
>> > return content;
>> > }
>> >
>> > NOTE:
>> > I have two calls to contentExpression.evaluate() method in
>> > JAXPXPathExpression. The first is just in the debug and is there to
>> > demonstrate the backward compatibility call. This is what it produces
>> in
>> > the log (No XML Tags):
>> >
>> > 14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
>> > toString: ServerAsset This is a Test ServerAsset, created from
>> > TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
>> > testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64 5.0.1
>> > 001 2048 2
>> >
>> > With the call to the new version (contentExpression.evaluate(exchange,
>> > inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of
>> XML):
>> >
>> > 14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
>> > toString: <?xml version="1.0" encoding="UTF-8"?><asset
>> > name="TestServerAsset1207250490590">
>> <class_type>ServerAsset</class_type>
>> > <description>This is a Test ServerAsset, created from
>> > TestAssetPersistenceTwo.</description>
>> > <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
>> > <managed>true</managed> <category
>> > guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
>> > guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
>> > guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/>
>> <mfgName/>
>> > <os>REDHAT LINUX</os>
>> >
>> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
>> > <domain_name>sgns.net</domain_name> <platform>OS64</platform>
>> > <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
>> > <memory>2048</memory> <cpus>2</cpus> </asset>
>> >
>> > I'm not out of the woods yet. My POST is getting to the webapp and the
>> > webapp is updating the database but things fall apart on the response.
>> I'm
>> > not certain at this point whether its an issue with the wepapp's
>> response
>> > or SMX's handling it or a little of both. I'll let you know what I find
>> > out.
>> >
>> > On the JAXPXPathExpression code, if there is another approach you think
>> I
>> > should take or you'd like to get the code let me know.
>> >
>> > Thanks
>> > Tom
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > Tom Purcell wrote:
>> >>
>> >> Guillaume
>> >>
>> >> Thabnks for the input. Responses inline
>> >>
>> >> gnodet wrote:
>> >>>
>> >>> Have you tried using the JaxenXPathExpression instead of the
>> >>> JaxenStringXPathExpression ?
>> >>>
>> >>> Yes, I got the same result.
>> >>>
>> >>> Also, I think you need to change the getContentToSend() method
>> because
>> >>> using
>> >>> toString() on the result won't work. Try using the
>> >>> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the DOM
>> >>> node
>> >>> to a String instead.
>> >>>
>> >>> Okay, I'll play with this but the call to
>> contentExpression.evaluate()
>> >>> in getContentToSend() returns a String object. At any rate I'll give
>> it
>> >>> a shot and let you know how it goes.
>> >>>
>> >>> Thanks
>> >>> Tom
>> >>>
>> >>> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
>> >>> <tp...@chariotsolutions.com>
>> >>> wrote:
>> >>>
>> >>>>
>> >>>> Guillaume
>> >>>>
>> >>>> Below is all of what I'm doing. Notice in the logs at the bottom
>> that
>> >>>> what
>> >>>> comes in on the NM is of type DOMSource but the object returned by
>> the
>> >>>> contentExpression.evaluate() method is of type String. I think it
>> want
>> >>>> I
>> >>>> want is for that to be a DOMSource too. I also see the "Content is
>> not
>> >>>> allowed in prolog" meesage but I think that is caused by the fact
>> that
>> >>>> my
>> >>>> content is just the values and not the XML.
>> >>>>
>> >>>> Here's the xbean config:
>> >>>>
>> >>>> <http:provider service="wile:wileRestService"
>> >>>> interfaceName="wileCreate"
>> >>>> endpoint="wileRestCreate"
>> >>>> marshaler="#createMarshaler"/>
>> >>>>
>> >>>> <bean id="createMarshaler"
>> >>>> class="jbi.marshal.RestProviderMarshaler">
>> >>>> <property name="locationURIExpression">
>> >>>> <bean
>> >>>> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
>> >>>> <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.JaxenStringXPathExpression">
>> >>>> <constructor-arg value="//asset"/>
>> >>>> </bean>
>> >>>> </property>
>> >>>> </bean>
>> >>>> </pre>
>> >>>>
>> >>>> In my RestProviderMarshaler class I added a property for
>> >>>> contentExpression
>> >>>> and replaced the createRequest method. Here are the relevant
>> methods:
>> >>>>
>> >>>> public void createRequest(MessageExchange exchange,
>> >>>> NormalizedMessage
>> >>>> inMsg, SmxHttpExchange httpExchange) throws Exception {
>> >>>> logger.debug("*** Before CREATE MessageExchange: " +
>> exchange);
>> >>>> logger.debug("*** NM In Content: " + inMsg.getContent());
>> >>>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
>> >>>> inMsg));
>> >>>>
>> >>>> httpExchange.setURL(getLocationUri(exchange, inMsg));
>> >>>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
>> >>>> ByteArrayBuffer(new URI(getLocationUri(exchange,
>> inMsg)).getHost()));
>> >>>> httpExchange.setMethod(getMethod(exchange, inMsg));
>> >>>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
>> >>>> getContentType(exchange, inMsg));
>> >>>>
>> >>>> if (getHeaders() != null) {
>> >>>> for (Map.Entry<String, String> e :
>> getHeaders().entrySet())
>> >>>> {
>> >>>> httpExchange.setRequestHeader(e.getKey(),
>> e.getValue());
>> >>>> }
>> >>>> }
>> >>>>
>> >>>> String contentToSend = getContentToSend(exchange, inMsg);
>> >>>> logger.debug("*** Content: " + contentToSend);
>> >>>>
>> >>>> if (contentToSend != null) {
>> >>>> httpExchange.setRequestContent(new
>> >>>> ByteArrayBuffer(contentToSend.getBytes()));
>> >>>> }
>> >>>> }
>> >>>>
>> >>>> protected String getContentToSend(MessageExchange exchange,
>> >>>> NormalizedMessage inMsg) throws Exception {
>> >>>> String content = null;
>> >>>> if (contentExpression != null) {
>> >>>> Object o = contentExpression.evaluate(exchange, inMsg);
>> >>>> logger.debug("*** Content Object Type: " + o.getClass());
>> >>>> content = (o != null) ? o.toString() : null;
>> >>>> }
>> >>>> if (content == null) {
>> >>>> throw new IllegalStateException("Unable to find Content
>> for
>> >>>> exchange");
>> >>>> }
>> >>>> return content;
>> >>>> }
>> >>>>
>> >>>> Here is what I see from the debugs:
>> >>>>
>> >>>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before
>> >>>> CREATE
>> >>>> MessageExchange: InOut[
>> >>>> id: ID:127.0.0.2-11910ec49ca-3:4
>> >>>> status: Active
>> >>>> role: provider
>> >>>> service:
>> >>>>
>> {http://www.abc.com/wile}wileRestService<http://www.abc.com/wile%7DwileRestService>
>> <http://www.abc.com/wile%7DwileRestService>
>> >>>> endpoint: wileRestCreate
>> >>>> in: <?xml version="1.0"
>> >>>>
>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> >>>> name="TestAsset"> <class_type>BigAsset</class_type>
>> <description>This
>> >>>> is a
>> >>>> Test Asset</description> <serial_number>12345</serial_number>
>> >>>> <enabled>true</enabled> <category guid="67890" value="Default"/>
>> <type
>> >>>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>> >>>> </asset> </assetRequest>
>> >>>> ]
>> >>>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
>> >>>> Content:
>> >>>> javax.xml.transform.dom.DOMSource@23cae6
>> >>>> 16:18:59,408 - DEBUG - RestProviderMarshaler - ***
>> >>>> LocationURI:
>> >>>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
>> >>>> 16:18:59,409<
>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409
>> >-
>> >>>> DEBUG - RestProviderMarshaler - *** Content Object
>> >>>> Type: class java.lang.String
>> >>>> 16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
>> >>>> BigAsset This is a Test Asset 12345 true
>> >>>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
>> >>>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
>> >>>> [Fatal Error] :1:1: Content is not allowed in prolog.
>> >>>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
>> >>>> id: ID:127.0.0.2-11910ec49ca-3:4
>> >>>> status: Active
>> >>>> role: provider
>> >>>> service:
>> >>>>
>> {http://www.abc.com/wile}wileRestService<http://www.abc.com/wile%7DwileRestService>
>> <http://www.abc.com/wile%7DwileRestService>
>> >>>> endpoint: wileRestCreate
>> >>>> in: <?xml version="1.0"
>> >>>>
>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> >>>> name="TestAsset"> <class_type>BigAsset</class_type>
>> <description>This
>> >>>> is a
>> >>>> Test Asset</description> <serial_number>12345</serial_number>
>> >>>> <enabled>true</enabled> <category guid="67890" value="Default"/>
>> <type
>> >>>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>> >>>> </asset> </assetRequest>
>> >>>> fault: Unable to display: org.xml.sax.SAXParseException: Content is
>> >>>> not
>> >>>> allowed in prolog.
>> >>>> ]
>> >>>> 16:18:59,454 - DEBUG - SedaFlow - Called Flow
>> >>>> send
>> >>>>
>> >>>> Thanks
>> >>>> Tom
>> >>>>
>> >>>>
>> >>>> gnodet wrote:
>> >>>> >
>> >>>> > I suppose the creation of the content does not support writing an
>> xml
>> >>>> > element and maybe use toString() or something like that to create
>> the
>> >>>> > content of the request. Could you paste the endpoint definition
>> and
>> >>>> > snippet
>> >>>> > of code, I'm not sure to fully understand your configuration.
>> >>>> > I think if you use a marshaler, you can really do anything you
>> need.
>> >>>> I'm
>> >>>> > sure we could come with something reusable using an expression for
>> >>>> the
>> >>>> > URL,
>> >>>> > the method and the content.
>> >>>> >
>> >>>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
>> >>>> > <tp...@chariotsolutions.com>
>> >>>> > wrote:
>> >>>> >
>> >>>> >>
>> >>>> >> Guillaume
>> >>>> >>
>> >>>> >> The message gets sent to the correct URI but the issue is the
>> >>>> content
>> >>>> of
>> >>>> >> the
>> >>>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
>> >>>> returned
>> >>>> >> by
>> >>>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent to
>> >>>> the
>> >>>> >> RESTful service, is just the values (bar).
>> >>>> >>
>> >>>> >> At this point I guess its really a Jaxen question. Can you get it
>> to
>> >>>> >> return
>> >>>> >> the XML instead of just the values? Otherwise some other parsing
>> >>>> strategy
>> >>>> >> is
>> >>>> >> needed. However, I really liked the idea of just defining an
>> XPath
>> >>>> >> expression on the endpoint. It seems it would make the marshaler
>> >>>> pretty
>> >>>> >> flexible.
>> >>>> >>
>> >>>> >> Thanks
>> >>>> >> Tom
>> >>>> >>
>> >>>> >>
>> >>>> >>
>> >>>> >> gnodet wrote:
>> >>>> >> >
>> >>>> >> > Well, it sounds realy good.
>> >>>> >> > What exactly does not work when using POST with your marshaler
>> ?
>> >>>> >> >
>> >>>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
>> >>>> >> > <tp...@chariotsolutions.com>
>> >>>> >> > wrote:
>> >>>> >> >
>> >>>> >> >>
>> >>>> >> >> Guillaume
>> >>>> >> >>
>> >>>> >> >> Okay, I'm new to REST so I may be missing something there too
>> but
>> >>>> this
>> >>>> >> is
>> >>>> >> >> where I'm at. SMX will receive a JMS message with an XML
>> payload.
>> >>>> The
>> >>>> >> XML
>> >>>> >> >> will have two high level nodes. One node's value will be the
>> >>>> service
>> >>>> >> to
>> >>>> >> >> call
>> >>>> >> >> (will become part of the REST URL). The other node will be a
>> big
>> >>>> chunk
>> >>>> >> of
>> >>>> >> >> XML to be POSTed to the service. The content-type is
>> >>>> >> >> x-www-form-urlencoded.
>> >>>> >> >>
>> >>>> >> >> I extended DefaultHttpProviderMarshaler and I call
>> >>>> >> >>
>> >>>> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>> >>>> >> >>
>> >>>> >> >> This almost works. I use JaxenStringXPathExpression to get the
>> >>>> value
>> >>>> >> of
>> >>>> >> >> the
>> >>>> >> >> first node and set the REST URL. Then my class has a new
>> >>>> property,
>> >>>> >> >> contentExpression, also a JaxenStringXPathExpression. I use
>> this
>> >>>> to
>> >>>> >> >> define
>> >>>> >> >> the XPath to the second node, the one with the big chunk of
>> XML,
>> >>>> but
>> >>>> >> it
>> >>>> >> >> adds
>> >>>> >> >> the values of the second node. What I need is the chunk of
>> XML,
>> >>>> >> elements,
>> >>>> >> >> attributes and all.
>> >>>> >> >>
>> >>>> >> >> I guess I could introduce a Saxon endpoint to do a
>> transformation
>> >>>> and
>> >>>> >> a
>> >>>> >> >> router to send the message to different HTTP endpoints based
>> on
>> >>>> the
>> >>>> >> first
>> >>>> >> >> node but that seems a lot less elegant than just dynamically
>> >>>> >> determining
>> >>>> >> >> the
>> >>>> >> >> REST URL in the marshaler. It works fine for GETs but then
>> POST,
>> >>>> I'm
>> >>>> >> >> learning, is a different story.
>> >>>> >> >>
>> >>>> >> >> Any thoughts?
>> >>>> >> >>
>> >>>> >> >> Thanks
>> >>>> >> >> Tom
>> >>>> >> >>
>> >>>> >> >>
>> >>>> >> >> gnodet wrote:
>> >>>> >> >> >
>> >>>> >> >> > I really think the best way would be to create your own
>> >>>> marshaler
>> >>>> if
>> >>>> >> >> the
>> >>>> >> >> > default one does not work for you. If you come up with
>> >>>> something
>> >>>> >> >> generic
>> >>>> >> >> > enough feel free to contribute it back. However, the
>> >>>> >> >> > DefaultHttpProviderMarshaler should send a POST request if
>> the
>> >>>> input
>> >>>> >> >> > message
>> >>>> >> >> > is not null, but this is more like a soap POST rather than a
>> >>>> form
>> >>>> >> post
>> >>>> >> >> > with
>> >>>> >> >> > key/value pairs. Is that what you'd need ? How do you
>> extract
>> >>>> the
>> >>>> >> >> > key/value pairs from the exchange ?
>> >>>> >> >> >
>> >>>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
>> >>>> >> >> > <tp...@chariotsolutions.com>
>> >>>> >> >> > wrote:
>> >>>> >> >> >
>> >>>> >> >> >>
>> >>>> >> >> >> Hello
>> >>>> >> >> >>
>> >>>> >> >> >> I'm trying to use the servicemix-http http:provider to call
>> a
>> >>>> >> RESTful
>> >>>> >> >> >> service. GET works fine but I'm having trouble trying to
>> >>>> configure
>> >>>> >> it
>> >>>> >> >> to
>> >>>> >> >> >> do
>> >>>> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler
>> >>>> does
>> >>>> not
>> >>>> >> >> >> directly
>> >>>> >> >> >> support this and so I must write my own Marshaler to set
>> the
>> >>>> >> content.
>> >>>> >> >> My
>> >>>> >> >> >> first question is just a request to verify that is correct
>> and
>> >>>> that
>> >>>> >> >> I'm
>> >>>> >> >> >> not
>> >>>> >> >> >> missing something.
>> >>>> >> >> >>
>> >>>> >> >> >> My next question is about
>> >>>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
>> >>>> >> >> >> SM-580 <
>> http://issues.apache.org/activemq/browse/SM-580SM-580>
>> >>>> .
>> >>>> >> This
>> >>>> >> >> >> appears to address this situation although I'm not certain
>> it
>> >>>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears
>> to
>> >>>> be
>> >>>> >> >> >> scheduled
>> >>>> >> >> >> for 3.3 so is this what I would use once 3.3 is released
>> and
>> >>>> when
>> >>>> >> is
>> >>>> >> >> 3.3
>> >>>> >> >> >> scheduled for release?
>> >>>> >> >> >>
>> >>>> >> >> >> Thanks
>> >>>> >> >> >> Tom
>> >>>> >> >> >> --
>> >>>> >> >> >> View this message in context:
>> >>>> >> >> >>
>> >>>> >> >>
>> >>>> >>
>> >>>>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>> >>>> >> >> >> Sent from the ServiceMix - User mailing list archive at
>> >>>> Nabble.com.
>> >>>> >> >> >>
>> >>>> >> >> >>
>> >>>> >> >> >
>> >>>> >> >> >
>> >>>> >> >> > --
>> >>>> >> >> > Cheers,
>> >>>> >> >> > Guillaume Nodet
>> >>>> >> >> > ------------------------
>> >>>> >> >> > Blog: http://gnodet.blogspot.com/
>> >>>> >> >> >
>> >>>> >> >> >
>> >>>> >> >>
>> >>>> >> >> --
>> >>>> >> >> View this message in context:
>> >>>> >> >>
>> >>>> >>
>> >>>>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
>> >>>> >> >> Sent from the ServiceMix - User mailing list archive at
>> >>>> Nabble.com.
>> >>>> >> >>
>> >>>> >> >>
>> >>>> >> >
>> >>>> >> >
>> >>>> >> > --
>> >>>> >> > Cheers,
>> >>>> >> > Guillaume Nodet
>> >>>> >> > ------------------------
>> >>>> >> > Blog: http://gnodet.blogspot.com/
>> >>>> >> >
>> >>>> >> >
>> >>>> >>
>> >>>> >> --
>> >>>> >> View this message in context:
>> >>>> >>
>> >>>>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
>> >>>> >> Sent from the ServiceMix - User mailing list archive at
>> Nabble.com.
>> >>>> >>
>> >>>> >>
>> >>>> >
>> >>>> >
>> >>>> > --
>> >>>> > Cheers,
>> >>>> > Guillaume Nodet
>> >>>> > ------------------------
>> >>>> > Blog: http://gnodet.blogspot.com/
>> >>>> >
>> >>>> >
>> >>>>
>> >>>> --
>> >>>> View this message in context:
>> >>>>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
>> >>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>> --
>> >>> Cheers,
>> >>> Guillaume Nodet
>> >>> ------------------------
>> >>> Blog: http://gnodet.blogspot.com/
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16471350.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16491213.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
If you look at the test, it says:
if (!(exchange instanceof InOnly))
Note the negation of the test.
The exception that happens when logging the message certainly is because
ServiceMix expects either a 200 or 202 status code or a response. What does
the 201 means in your case ? Are you expecting a response later ?
On Thu, Apr 3, 2008 at 10:26 PM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
>
> I've done some looking into the response issue. I added debugs to the
> handleResponse method of my RestProviderMarshaler to figure out what was
> happening. This is what the beginning of that method looks like. I only
> included up to where things appear to go wrong. The only difference is the
> debugs:
>
> public void handleResponse(MessageExchange exchange, SmxHttpExchange
> httpExchange) throws Exception {
> int response = httpExchange.getResponseStatus();
> logger.debug("*** Response Status: " + response);
>
> if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED)
> {
> if (!(exchange instanceof InOnly)) {
> logger.debug("*** InOnly");
>
> Now in the log I get the following:
> 15:12:52,646 - DEBUG - RestProviderMarshaler - *** Response
> Status:
> 201
> 15:12:52,647 - DEBUG - RestProviderMarshaler - *** InOnly
> 15:12:52,647 - DEBUG - DeliveryChannelImpl - Send
> ID:127.0.0.2-1191563e603-3:10 in DeliveryChannel{servicemix-http}
> 15:12:52,652 - TRACE - DeliveryChannelImpl - Sent: InOut[
> id: ID:127.0.0.2-1191563e603-3:10
> status: Active
> role: provider
> service: {http://www.abc.com/wile}wileRestService<http://www.abc.com/wile%7DwileRestService>
> endpoint: wileRestCreate
> in: <?xml version="1.0"
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset...
> NOTE: DOTS BY ME TO SHORTEN EMAIL
> ...</assetRequest>
> fault: Unable to display: java.io.IOException: No input stream or reader
> available
> ]
>
> It starts out good. We get a 201. But why are we in the InOnly code? The
> subsequent TRACE - DeliveryChannelImpl message says we are InOut. I'm not
> sure what to do here.
>
> Thanks
> Tom
>
>
>
> Tom Purcell wrote:
> >
> > Guillaume
> >
> > I've made some progress. This is what I did.
> >
> > First, I switched to JAXP instead of Jaxen. The ONLY reason for this is
> > I'm on a corporate network and they will not allow access to any URL
> with
> > the "jaxen" in it thus making research difficult. (not your problem,
> just
> > venting).
> >
> > I understood what you were saying about using a SourceTransformer
> instead
> > of toString() but the problem is that by the time my getContentToSend()
> > gets the result of the XPath evaluation it is already a String with the
> > XML tags stripped out.
> >
> > 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.
> >
> > I need the NodeSet. Another version of the XPathExpression evaluate
> > method, evaluate(object, returnType), allows you to control the return
> > type but the SMX JAXPXPathExpression does not expose a way to call it. I
> > went into the SMX JAXPXPathExpression class and did the following:
> >
> > 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.
> >
> > In my new RestProviderMarshaler:
> > protected String getContentToSend(MessageExchange exchange,
> > NormalizedMessage inMsg) throws Exception {
> > String content = null;
> >
> > if (contentExpression != null) {
> > logger.debug("*** Evaluate toString: " +
> > contentExpression.evaluate(exchange, inMsg));
> > Node node = (Node)contentExpression.evaluate(exchange, inMsg,
> > XPathConstants.NODE);
> > content = transformer.toString(new DOMSource(node));
> > logger.debug("*** Content toString: " + content);
> > }
> >
> > if (content == null) {
> > throw new IllegalStateException("Unable to find Content for
> > exchange");
> > }
> > return content;
> > }
> >
> > NOTE:
> > I have two calls to contentExpression.evaluate() method in
> > JAXPXPathExpression. The first is just in the debug and is there to
> > demonstrate the backward compatibility call. This is what it produces in
> > the log (No XML Tags):
> >
> > 14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
> > toString: ServerAsset This is a Test ServerAsset, created from
> > TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
> > testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64 5.0.1
> > 001 2048 2
> >
> > With the call to the new version (contentExpression.evaluate(exchange,
> > inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of
> XML):
> >
> > 14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
> > toString: <?xml version="1.0" encoding="UTF-8"?><asset
> > name="TestServerAsset1207250490590">
> <class_type>ServerAsset</class_type>
> > <description>This is a Test ServerAsset, created from
> > TestAssetPersistenceTwo.</description>
> > <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
> > <managed>true</managed> <category
> > guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
> > guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
> > guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
> > <os>REDHAT LINUX</os>
> >
> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
> > <domain_name>sgns.net</domain_name> <platform>OS64</platform>
> > <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
> > <memory>2048</memory> <cpus>2</cpus> </asset>
> >
> > I'm not out of the woods yet. My POST is getting to the webapp and the
> > webapp is updating the database but things fall apart on the response.
> I'm
> > not certain at this point whether its an issue with the wepapp's
> response
> > or SMX's handling it or a little of both. I'll let you know what I find
> > out.
> >
> > On the JAXPXPathExpression code, if there is another approach you think
> I
> > should take or you'd like to get the code let me know.
> >
> > Thanks
> > Tom
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Tom Purcell wrote:
> >>
> >> Guillaume
> >>
> >> Thabnks for the input. Responses inline
> >>
> >> gnodet wrote:
> >>>
> >>> Have you tried using the JaxenXPathExpression instead of the
> >>> JaxenStringXPathExpression ?
> >>>
> >>> Yes, I got the same result.
> >>>
> >>> Also, I think you need to change the getContentToSend() method because
> >>> using
> >>> toString() on the result won't work. Try using the
> >>> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the DOM
> >>> node
> >>> to a String instead.
> >>>
> >>> Okay, I'll play with this but the call to contentExpression.evaluate()
> >>> in getContentToSend() returns a String object. At any rate I'll give
> it
> >>> a shot and let you know how it goes.
> >>>
> >>> Thanks
> >>> Tom
> >>>
> >>> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
> >>> <tp...@chariotsolutions.com>
> >>> wrote:
> >>>
> >>>>
> >>>> Guillaume
> >>>>
> >>>> Below is all of what I'm doing. Notice in the logs at the bottom that
> >>>> what
> >>>> comes in on the NM is of type DOMSource but the object returned by
> the
> >>>> contentExpression.evaluate() method is of type String. I think it
> want
> >>>> I
> >>>> want is for that to be a DOMSource too. I also see the "Content is
> not
> >>>> allowed in prolog" meesage but I think that is caused by the fact
> that
> >>>> my
> >>>> content is just the values and not the XML.
> >>>>
> >>>> Here's the xbean config:
> >>>>
> >>>> <http:provider service="wile:wileRestService"
> >>>> interfaceName="wileCreate"
> >>>> endpoint="wileRestCreate"
> >>>> marshaler="#createMarshaler"/>
> >>>>
> >>>> <bean id="createMarshaler"
> >>>> class="jbi.marshal.RestProviderMarshaler">
> >>>> <property name="locationURIExpression">
> >>>> <bean
> >>>> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
> >>>> <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.JaxenStringXPathExpression">
> >>>> <constructor-arg value="//asset"/>
> >>>> </bean>
> >>>> </property>
> >>>> </bean>
> >>>> </pre>
> >>>>
> >>>> In my RestProviderMarshaler class I added a property for
> >>>> contentExpression
> >>>> and replaced the createRequest method. Here are the relevant methods:
> >>>>
> >>>> public void createRequest(MessageExchange exchange,
> >>>> NormalizedMessage
> >>>> inMsg, SmxHttpExchange httpExchange) throws Exception {
> >>>> logger.debug("*** Before CREATE MessageExchange: " +
> exchange);
> >>>> logger.debug("*** NM In Content: " + inMsg.getContent());
> >>>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
> >>>> inMsg));
> >>>>
> >>>> httpExchange.setURL(getLocationUri(exchange, inMsg));
> >>>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
> >>>> ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
> >>>> httpExchange.setMethod(getMethod(exchange, inMsg));
> >>>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
> >>>> getContentType(exchange, inMsg));
> >>>>
> >>>> if (getHeaders() != null) {
> >>>> for (Map.Entry<String, String> e :
> getHeaders().entrySet())
> >>>> {
> >>>> httpExchange.setRequestHeader(e.getKey(),
> e.getValue());
> >>>> }
> >>>> }
> >>>>
> >>>> String contentToSend = getContentToSend(exchange, inMsg);
> >>>> logger.debug("*** Content: " + contentToSend);
> >>>>
> >>>> if (contentToSend != null) {
> >>>> httpExchange.setRequestContent(new
> >>>> ByteArrayBuffer(contentToSend.getBytes()));
> >>>> }
> >>>> }
> >>>>
> >>>> protected String getContentToSend(MessageExchange exchange,
> >>>> NormalizedMessage inMsg) throws Exception {
> >>>> String content = null;
> >>>> if (contentExpression != null) {
> >>>> Object o = contentExpression.evaluate(exchange, inMsg);
> >>>> logger.debug("*** Content Object Type: " + o.getClass());
> >>>> content = (o != null) ? o.toString() : null;
> >>>> }
> >>>> if (content == null) {
> >>>> throw new IllegalStateException("Unable to find Content
> for
> >>>> exchange");
> >>>> }
> >>>> return content;
> >>>> }
> >>>>
> >>>> Here is what I see from the debugs:
> >>>>
> >>>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before
> >>>> CREATE
> >>>> MessageExchange: InOut[
> >>>> id: ID:127.0.0.2-11910ec49ca-3:4
> >>>> status: Active
> >>>> role: provider
> >>>> service:
> >>>> {http://www.abc.com/wile}wileRestService<http://www.abc.com/wile%7DwileRestService>
> <http://www.abc.com/wile%7DwileRestService>
> >>>> endpoint: wileRestCreate
> >>>> in: <?xml version="1.0"
> >>>>
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >>>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This
> >>>> is a
> >>>> Test Asset</description> <serial_number>12345</serial_number>
> >>>> <enabled>true</enabled> <category guid="67890" value="Default"/>
> <type
> >>>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
> >>>> </asset> </assetRequest>
> >>>> ]
> >>>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
> >>>> Content:
> >>>> javax.xml.transform.dom.DOMSource@23cae6
> >>>> 16:18:59,408 - DEBUG - RestProviderMarshaler - ***
> >>>> LocationURI:
> >>>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
> >>>> 16:18:59,409<
> http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409
> >-
> >>>> DEBUG - RestProviderMarshaler - *** Content Object
> >>>> Type: class java.lang.String
> >>>> 16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
> >>>> BigAsset This is a Test Asset 12345 true
> >>>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
> >>>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
> >>>> [Fatal Error] :1:1: Content is not allowed in prolog.
> >>>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
> >>>> id: ID:127.0.0.2-11910ec49ca-3:4
> >>>> status: Active
> >>>> role: provider
> >>>> service:
> >>>> {http://www.abc.com/wile}wileRestService<http://www.abc.com/wile%7DwileRestService>
> <http://www.abc.com/wile%7DwileRestService>
> >>>> endpoint: wileRestCreate
> >>>> in: <?xml version="1.0"
> >>>>
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >>>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This
> >>>> is a
> >>>> Test Asset</description> <serial_number>12345</serial_number>
> >>>> <enabled>true</enabled> <category guid="67890" value="Default"/>
> <type
> >>>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
> >>>> </asset> </assetRequest>
> >>>> fault: Unable to display: org.xml.sax.SAXParseException: Content is
> >>>> not
> >>>> allowed in prolog.
> >>>> ]
> >>>> 16:18:59,454 - DEBUG - SedaFlow - Called Flow
> >>>> send
> >>>>
> >>>> Thanks
> >>>> Tom
> >>>>
> >>>>
> >>>> gnodet wrote:
> >>>> >
> >>>> > I suppose the creation of the content does not support writing an
> xml
> >>>> > element and maybe use toString() or something like that to create
> the
> >>>> > content of the request. Could you paste the endpoint definition
> and
> >>>> > snippet
> >>>> > of code, I'm not sure to fully understand your configuration.
> >>>> > I think if you use a marshaler, you can really do anything you
> need.
> >>>> I'm
> >>>> > sure we could come with something reusable using an expression for
> >>>> the
> >>>> > URL,
> >>>> > the method and the content.
> >>>> >
> >>>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
> >>>> > <tp...@chariotsolutions.com>
> >>>> > wrote:
> >>>> >
> >>>> >>
> >>>> >> Guillaume
> >>>> >>
> >>>> >> The message gets sent to the correct URI but the issue is the
> >>>> content
> >>>> of
> >>>> >> the
> >>>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
> >>>> returned
> >>>> >> by
> >>>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent to
> >>>> the
> >>>> >> RESTful service, is just the values (bar).
> >>>> >>
> >>>> >> At this point I guess its really a Jaxen question. Can you get it
> to
> >>>> >> return
> >>>> >> the XML instead of just the values? Otherwise some other parsing
> >>>> strategy
> >>>> >> is
> >>>> >> needed. However, I really liked the idea of just defining an XPath
> >>>> >> expression on the endpoint. It seems it would make the marshaler
> >>>> pretty
> >>>> >> flexible.
> >>>> >>
> >>>> >> Thanks
> >>>> >> Tom
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> gnodet wrote:
> >>>> >> >
> >>>> >> > Well, it sounds realy good.
> >>>> >> > What exactly does not work when using POST with your marshaler ?
> >>>> >> >
> >>>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
> >>>> >> > <tp...@chariotsolutions.com>
> >>>> >> > wrote:
> >>>> >> >
> >>>> >> >>
> >>>> >> >> Guillaume
> >>>> >> >>
> >>>> >> >> Okay, I'm new to REST so I may be missing something there too
> but
> >>>> this
> >>>> >> is
> >>>> >> >> where I'm at. SMX will receive a JMS message with an XML
> payload.
> >>>> The
> >>>> >> XML
> >>>> >> >> will have two high level nodes. One node's value will be the
> >>>> service
> >>>> >> to
> >>>> >> >> call
> >>>> >> >> (will become part of the REST URL). The other node will be a
> big
> >>>> chunk
> >>>> >> of
> >>>> >> >> XML to be POSTed to the service. The content-type is
> >>>> >> >> x-www-form-urlencoded.
> >>>> >> >>
> >>>> >> >> I extended DefaultHttpProviderMarshaler and I call
> >>>> >> >>
> >>>> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
> >>>> >> >>
> >>>> >> >> This almost works. I use JaxenStringXPathExpression to get the
> >>>> value
> >>>> >> of
> >>>> >> >> the
> >>>> >> >> first node and set the REST URL. Then my class has a new
> >>>> property,
> >>>> >> >> contentExpression, also a JaxenStringXPathExpression. I use
> this
> >>>> to
> >>>> >> >> define
> >>>> >> >> the XPath to the second node, the one with the big chunk of
> XML,
> >>>> but
> >>>> >> it
> >>>> >> >> adds
> >>>> >> >> the values of the second node. What I need is the chunk of XML,
> >>>> >> elements,
> >>>> >> >> attributes and all.
> >>>> >> >>
> >>>> >> >> I guess I could introduce a Saxon endpoint to do a
> transformation
> >>>> and
> >>>> >> a
> >>>> >> >> router to send the message to different HTTP endpoints based on
> >>>> the
> >>>> >> first
> >>>> >> >> node but that seems a lot less elegant than just dynamically
> >>>> >> determining
> >>>> >> >> the
> >>>> >> >> REST URL in the marshaler. It works fine for GETs but then
> POST,
> >>>> I'm
> >>>> >> >> learning, is a different story.
> >>>> >> >>
> >>>> >> >> Any thoughts?
> >>>> >> >>
> >>>> >> >> Thanks
> >>>> >> >> Tom
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> gnodet wrote:
> >>>> >> >> >
> >>>> >> >> > I really think the best way would be to create your own
> >>>> marshaler
> >>>> if
> >>>> >> >> the
> >>>> >> >> > default one does not work for you. If you come up with
> >>>> something
> >>>> >> >> generic
> >>>> >> >> > enough feel free to contribute it back. However, the
> >>>> >> >> > DefaultHttpProviderMarshaler should send a POST request if
> the
> >>>> input
> >>>> >> >> > message
> >>>> >> >> > is not null, but this is more like a soap POST rather than a
> >>>> form
> >>>> >> post
> >>>> >> >> > with
> >>>> >> >> > key/value pairs. Is that what you'd need ? How do you
> extract
> >>>> the
> >>>> >> >> > key/value pairs from the exchange ?
> >>>> >> >> >
> >>>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
> >>>> >> >> > <tp...@chariotsolutions.com>
> >>>> >> >> > wrote:
> >>>> >> >> >
> >>>> >> >> >>
> >>>> >> >> >> Hello
> >>>> >> >> >>
> >>>> >> >> >> I'm trying to use the servicemix-http http:provider to call
> a
> >>>> >> RESTful
> >>>> >> >> >> service. GET works fine but I'm having trouble trying to
> >>>> configure
> >>>> >> it
> >>>> >> >> to
> >>>> >> >> >> do
> >>>> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler
> >>>> does
> >>>> not
> >>>> >> >> >> directly
> >>>> >> >> >> support this and so I must write my own Marshaler to set the
> >>>> >> content.
> >>>> >> >> My
> >>>> >> >> >> first question is just a request to verify that is correct
> and
> >>>> that
> >>>> >> >> I'm
> >>>> >> >> >> not
> >>>> >> >> >> missing something.
> >>>> >> >> >>
> >>>> >> >> >> My next question is about
> >>>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
> >>>> >> >> >> SM-580 <
> http://issues.apache.org/activemq/browse/SM-580SM-580>
> >>>> .
> >>>> >> This
> >>>> >> >> >> appears to address this situation although I'm not certain
> it
> >>>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears
> to
> >>>> be
> >>>> >> >> >> scheduled
> >>>> >> >> >> for 3.3 so is this what I would use once 3.3 is released and
> >>>> when
> >>>> >> is
> >>>> >> >> 3.3
> >>>> >> >> >> scheduled for release?
> >>>> >> >> >>
> >>>> >> >> >> Thanks
> >>>> >> >> >> Tom
> >>>> >> >> >> --
> >>>> >> >> >> View this message in context:
> >>>> >> >> >>
> >>>> >> >>
> >>>> >>
> >>>>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
> >>>> >> >> >> Sent from the ServiceMix - User mailing list archive at
> >>>> Nabble.com.
> >>>> >> >> >>
> >>>> >> >> >>
> >>>> >> >> >
> >>>> >> >> >
> >>>> >> >> > --
> >>>> >> >> > Cheers,
> >>>> >> >> > Guillaume Nodet
> >>>> >> >> > ------------------------
> >>>> >> >> > Blog: http://gnodet.blogspot.com/
> >>>> >> >> >
> >>>> >> >> >
> >>>> >> >>
> >>>> >> >> --
> >>>> >> >> View this message in context:
> >>>> >> >>
> >>>> >>
> >>>>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
> >>>> >> >> Sent from the ServiceMix - User mailing list archive at
> >>>> Nabble.com.
> >>>> >> >>
> >>>> >> >>
> >>>> >> >
> >>>> >> >
> >>>> >> > --
> >>>> >> > Cheers,
> >>>> >> > Guillaume Nodet
> >>>> >> > ------------------------
> >>>> >> > Blog: http://gnodet.blogspot.com/
> >>>> >> >
> >>>> >> >
> >>>> >>
> >>>> >> --
> >>>> >> View this message in context:
> >>>> >>
> >>>>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
> >>>> >> Sent from the ServiceMix - User mailing list archive at
> Nabble.com.
> >>>> >>
> >>>> >>
> >>>> >
> >>>> >
> >>>> > --
> >>>> > Cheers,
> >>>> > Guillaume Nodet
> >>>> > ------------------------
> >>>> > Blog: http://gnodet.blogspot.com/
> >>>> >
> >>>> >
> >>>>
> >>>> --
> >>>> View this message in context:
> >>>>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
> >>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> Cheers,
> >>> Guillaume Nodet
> >>> ------------------------
> >>> Blog: http://gnodet.blogspot.com/
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16471350.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
I've done some looking into the response issue. I added debugs to the
handleResponse method of my RestProviderMarshaler to figure out what was
happening. This is what the beginning of that method looks like. I only
included up to where things appear to go wrong. The only difference is the
debugs:
public void handleResponse(MessageExchange exchange, SmxHttpExchange
httpExchange) throws Exception {
int response = httpExchange.getResponseStatus();
logger.debug("*** Response Status: " + response);
if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED) {
if (!(exchange instanceof InOnly)) {
logger.debug("*** InOnly");
Now in the log I get the following:
15:12:52,646 - DEBUG - RestProviderMarshaler - *** Response Status:
201
15:12:52,647 - DEBUG - RestProviderMarshaler - *** InOnly
15:12:52,647 - DEBUG - DeliveryChannelImpl - Send
ID:127.0.0.2-1191563e603-3:10 in DeliveryChannel{servicemix-http}
15:12:52,652 - TRACE - DeliveryChannelImpl - Sent: InOut[
id: ID:127.0.0.2-1191563e603-3:10
status: Active
role: provider
service: {http://www.abc.com/wile}wileRestService
endpoint: wileRestCreate
in: <?xml version="1.0"
encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset...
NOTE: DOTS BY ME TO SHORTEN EMAIL
...</assetRequest>
fault: Unable to display: java.io.IOException: No input stream or reader
available
]
It starts out good. We get a 201. But why are we in the InOnly code? The
subsequent TRACE - DeliveryChannelImpl message says we are InOut. I'm not
sure what to do here.
Thanks
Tom
Tom Purcell wrote:
>
> Guillaume
>
> I've made some progress. This is what I did.
>
> First, I switched to JAXP instead of Jaxen. The ONLY reason for this is
> I'm on a corporate network and they will not allow access to any URL with
> the "jaxen" in it thus making research difficult. (not your problem, just
> venting).
>
> I understood what you were saying about using a SourceTransformer instead
> of toString() but the problem is that by the time my getContentToSend()
> gets the result of the XPath evaluation it is already a String with the
> XML tags stripped out.
>
> 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.
>
> I need the NodeSet. Another version of the XPathExpression evaluate
> method, evaluate(object, returnType), allows you to control the return
> type but the SMX JAXPXPathExpression does not expose a way to call it. I
> went into the SMX JAXPXPathExpression class and did the following:
>
> 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.
>
> In my new RestProviderMarshaler:
> protected String getContentToSend(MessageExchange exchange,
> NormalizedMessage inMsg) throws Exception {
> String content = null;
>
> if (contentExpression != null) {
> logger.debug("*** Evaluate toString: " +
> contentExpression.evaluate(exchange, inMsg));
> Node node = (Node)contentExpression.evaluate(exchange, inMsg,
> XPathConstants.NODE);
> content = transformer.toString(new DOMSource(node));
> logger.debug("*** Content toString: " + content);
> }
>
> if (content == null) {
> throw new IllegalStateException("Unable to find Content for
> exchange");
> }
> return content;
> }
>
> NOTE:
> I have two calls to contentExpression.evaluate() method in
> JAXPXPathExpression. The first is just in the debug and is there to
> demonstrate the backward compatibility call. This is what it produces in
> the log (No XML Tags):
>
> 14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
> toString: ServerAsset This is a Test ServerAsset, created from
> TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
> testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64 5.0.1
> 001 2048 2
>
> With the call to the new version (contentExpression.evaluate(exchange,
> inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of XML):
>
> 14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
> toString: <?xml version="1.0" encoding="UTF-8"?><asset
> name="TestServerAsset1207250490590"> <class_type>ServerAsset</class_type>
> <description>This is a Test ServerAsset, created from
> TestAssetPersistenceTwo.</description>
> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
> <managed>true</managed> <category
> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
> <os>REDHAT LINUX</os>
> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
> <memory>2048</memory> <cpus>2</cpus> </asset>
>
> I'm not out of the woods yet. My POST is getting to the webapp and the
> webapp is updating the database but things fall apart on the response. I'm
> not certain at this point whether its an issue with the wepapp's response
> or SMX's handling it or a little of both. I'll let you know what I find
> out.
>
> On the JAXPXPathExpression code, if there is another approach you think I
> should take or you'd like to get the code let me know.
>
> Thanks
> Tom
>
>
>
>
>
>
>
>
>
> Tom Purcell wrote:
>>
>> Guillaume
>>
>> Thabnks for the input. Responses inline
>>
>> gnodet wrote:
>>>
>>> Have you tried using the JaxenXPathExpression instead of the
>>> JaxenStringXPathExpression ?
>>>
>>> Yes, I got the same result.
>>>
>>> Also, I think you need to change the getContentToSend() method because
>>> using
>>> toString() on the result won't work. Try using the
>>> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the DOM
>>> node
>>> to a String instead.
>>>
>>> Okay, I'll play with this but the call to contentExpression.evaluate()
>>> in getContentToSend() returns a String object. At any rate I'll give it
>>> a shot and let you know how it goes.
>>>
>>> Thanks
>>> Tom
>>>
>>> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
>>> <tp...@chariotsolutions.com>
>>> wrote:
>>>
>>>>
>>>> Guillaume
>>>>
>>>> Below is all of what I'm doing. Notice in the logs at the bottom that
>>>> what
>>>> comes in on the NM is of type DOMSource but the object returned by the
>>>> contentExpression.evaluate() method is of type String. I think it want
>>>> I
>>>> want is for that to be a DOMSource too. I also see the "Content is not
>>>> allowed in prolog" meesage but I think that is caused by the fact that
>>>> my
>>>> content is just the values and not the XML.
>>>>
>>>> Here's the xbean config:
>>>>
>>>> <http:provider service="wile:wileRestService"
>>>> interfaceName="wileCreate"
>>>> endpoint="wileRestCreate"
>>>> marshaler="#createMarshaler"/>
>>>>
>>>> <bean id="createMarshaler"
>>>> class="jbi.marshal.RestProviderMarshaler">
>>>> <property name="locationURIExpression">
>>>> <bean
>>>> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
>>>> <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.JaxenStringXPathExpression">
>>>> <constructor-arg value="//asset"/>
>>>> </bean>
>>>> </property>
>>>> </bean>
>>>> </pre>
>>>>
>>>> In my RestProviderMarshaler class I added a property for
>>>> contentExpression
>>>> and replaced the createRequest method. Here are the relevant methods:
>>>>
>>>> public void createRequest(MessageExchange exchange,
>>>> NormalizedMessage
>>>> inMsg, SmxHttpExchange httpExchange) throws Exception {
>>>> logger.debug("*** Before CREATE MessageExchange: " + exchange);
>>>> logger.debug("*** NM In Content: " + inMsg.getContent());
>>>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
>>>> inMsg));
>>>>
>>>> httpExchange.setURL(getLocationUri(exchange, inMsg));
>>>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
>>>> ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
>>>> httpExchange.setMethod(getMethod(exchange, inMsg));
>>>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
>>>> getContentType(exchange, inMsg));
>>>>
>>>> if (getHeaders() != null) {
>>>> for (Map.Entry<String, String> e : getHeaders().entrySet())
>>>> {
>>>> httpExchange.setRequestHeader(e.getKey(), e.getValue());
>>>> }
>>>> }
>>>>
>>>> String contentToSend = getContentToSend(exchange, inMsg);
>>>> logger.debug("*** Content: " + contentToSend);
>>>>
>>>> if (contentToSend != null) {
>>>> httpExchange.setRequestContent(new
>>>> ByteArrayBuffer(contentToSend.getBytes()));
>>>> }
>>>> }
>>>>
>>>> protected String getContentToSend(MessageExchange exchange,
>>>> NormalizedMessage inMsg) throws Exception {
>>>> String content = null;
>>>> if (contentExpression != null) {
>>>> Object o = contentExpression.evaluate(exchange, inMsg);
>>>> logger.debug("*** Content Object Type: " + o.getClass());
>>>> content = (o != null) ? o.toString() : null;
>>>> }
>>>> if (content == null) {
>>>> throw new IllegalStateException("Unable to find Content for
>>>> exchange");
>>>> }
>>>> return content;
>>>> }
>>>>
>>>> Here is what I see from the debugs:
>>>>
>>>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before
>>>> CREATE
>>>> MessageExchange: InOut[
>>>> id: ID:127.0.0.2-11910ec49ca-3:4
>>>> status: Active
>>>> role: provider
>>>> service:
>>>> {http://www.abc.com/wile}wileRestService<http://www.abc.com/wile%7DwileRestService>
>>>> endpoint: wileRestCreate
>>>> in: <?xml version="1.0"
>>>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>>>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This
>>>> is a
>>>> Test Asset</description> <serial_number>12345</serial_number>
>>>> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
>>>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>>>> </asset> </assetRequest>
>>>> ]
>>>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
>>>> Content:
>>>> javax.xml.transform.dom.DOMSource@23cae6
>>>> 16:18:59,408 - DEBUG - RestProviderMarshaler - ***
>>>> LocationURI:
>>>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
>>>> 16:18:59,409<http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409>-
>>>> DEBUG - RestProviderMarshaler - *** Content Object
>>>> Type: class java.lang.String
>>>> 16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
>>>> BigAsset This is a Test Asset 12345 true
>>>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
>>>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
>>>> [Fatal Error] :1:1: Content is not allowed in prolog.
>>>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
>>>> id: ID:127.0.0.2-11910ec49ca-3:4
>>>> status: Active
>>>> role: provider
>>>> service:
>>>> {http://www.abc.com/wile}wileRestService<http://www.abc.com/wile%7DwileRestService>
>>>> endpoint: wileRestCreate
>>>> in: <?xml version="1.0"
>>>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>>>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This
>>>> is a
>>>> Test Asset</description> <serial_number>12345</serial_number>
>>>> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
>>>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>>>> </asset> </assetRequest>
>>>> fault: Unable to display: org.xml.sax.SAXParseException: Content is
>>>> not
>>>> allowed in prolog.
>>>> ]
>>>> 16:18:59,454 - DEBUG - SedaFlow - Called Flow
>>>> send
>>>>
>>>> Thanks
>>>> Tom
>>>>
>>>>
>>>> gnodet wrote:
>>>> >
>>>> > I suppose the creation of the content does not support writing an xml
>>>> > element and maybe use toString() or something like that to create the
>>>> > content of the request. Could you paste the endpoint definition and
>>>> > snippet
>>>> > of code, I'm not sure to fully understand your configuration.
>>>> > I think if you use a marshaler, you can really do anything you need.
>>>> I'm
>>>> > sure we could come with something reusable using an expression for
>>>> the
>>>> > URL,
>>>> > the method and the content.
>>>> >
>>>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
>>>> > <tp...@chariotsolutions.com>
>>>> > wrote:
>>>> >
>>>> >>
>>>> >> Guillaume
>>>> >>
>>>> >> The message gets sent to the correct URI but the issue is the
>>>> content
>>>> of
>>>> >> the
>>>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
>>>> returned
>>>> >> by
>>>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent to
>>>> the
>>>> >> RESTful service, is just the values (bar).
>>>> >>
>>>> >> At this point I guess its really a Jaxen question. Can you get it to
>>>> >> return
>>>> >> the XML instead of just the values? Otherwise some other parsing
>>>> strategy
>>>> >> is
>>>> >> needed. However, I really liked the idea of just defining an XPath
>>>> >> expression on the endpoint. It seems it would make the marshaler
>>>> pretty
>>>> >> flexible.
>>>> >>
>>>> >> Thanks
>>>> >> Tom
>>>> >>
>>>> >>
>>>> >>
>>>> >> gnodet wrote:
>>>> >> >
>>>> >> > Well, it sounds realy good.
>>>> >> > What exactly does not work when using POST with your marshaler ?
>>>> >> >
>>>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
>>>> >> > <tp...@chariotsolutions.com>
>>>> >> > wrote:
>>>> >> >
>>>> >> >>
>>>> >> >> Guillaume
>>>> >> >>
>>>> >> >> Okay, I'm new to REST so I may be missing something there too but
>>>> this
>>>> >> is
>>>> >> >> where I'm at. SMX will receive a JMS message with an XML payload.
>>>> The
>>>> >> XML
>>>> >> >> will have two high level nodes. One node's value will be the
>>>> service
>>>> >> to
>>>> >> >> call
>>>> >> >> (will become part of the REST URL). The other node will be a big
>>>> chunk
>>>> >> of
>>>> >> >> XML to be POSTed to the service. The content-type is
>>>> >> >> x-www-form-urlencoded.
>>>> >> >>
>>>> >> >> I extended DefaultHttpProviderMarshaler and I call
>>>> >> >>
>>>> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>>>> >> >>
>>>> >> >> This almost works. I use JaxenStringXPathExpression to get the
>>>> value
>>>> >> of
>>>> >> >> the
>>>> >> >> first node and set the REST URL. Then my class has a new
>>>> property,
>>>> >> >> contentExpression, also a JaxenStringXPathExpression. I use this
>>>> to
>>>> >> >> define
>>>> >> >> the XPath to the second node, the one with the big chunk of XML,
>>>> but
>>>> >> it
>>>> >> >> adds
>>>> >> >> the values of the second node. What I need is the chunk of XML,
>>>> >> elements,
>>>> >> >> attributes and all.
>>>> >> >>
>>>> >> >> I guess I could introduce a Saxon endpoint to do a transformation
>>>> and
>>>> >> a
>>>> >> >> router to send the message to different HTTP endpoints based on
>>>> the
>>>> >> first
>>>> >> >> node but that seems a lot less elegant than just dynamically
>>>> >> determining
>>>> >> >> the
>>>> >> >> REST URL in the marshaler. It works fine for GETs but then POST,
>>>> I'm
>>>> >> >> learning, is a different story.
>>>> >> >>
>>>> >> >> Any thoughts?
>>>> >> >>
>>>> >> >> Thanks
>>>> >> >> Tom
>>>> >> >>
>>>> >> >>
>>>> >> >> gnodet wrote:
>>>> >> >> >
>>>> >> >> > I really think the best way would be to create your own
>>>> marshaler
>>>> if
>>>> >> >> the
>>>> >> >> > default one does not work for you. If you come up with
>>>> something
>>>> >> >> generic
>>>> >> >> > enough feel free to contribute it back. However, the
>>>> >> >> > DefaultHttpProviderMarshaler should send a POST request if the
>>>> input
>>>> >> >> > message
>>>> >> >> > is not null, but this is more like a soap POST rather than a
>>>> form
>>>> >> post
>>>> >> >> > with
>>>> >> >> > key/value pairs. Is that what you'd need ? How do you extract
>>>> the
>>>> >> >> > key/value pairs from the exchange ?
>>>> >> >> >
>>>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
>>>> >> >> > <tp...@chariotsolutions.com>
>>>> >> >> > wrote:
>>>> >> >> >
>>>> >> >> >>
>>>> >> >> >> Hello
>>>> >> >> >>
>>>> >> >> >> I'm trying to use the servicemix-http http:provider to call a
>>>> >> RESTful
>>>> >> >> >> service. GET works fine but I'm having trouble trying to
>>>> configure
>>>> >> it
>>>> >> >> to
>>>> >> >> >> do
>>>> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler
>>>> does
>>>> not
>>>> >> >> >> directly
>>>> >> >> >> support this and so I must write my own Marshaler to set the
>>>> >> content.
>>>> >> >> My
>>>> >> >> >> first question is just a request to verify that is correct and
>>>> that
>>>> >> >> I'm
>>>> >> >> >> not
>>>> >> >> >> missing something.
>>>> >> >> >>
>>>> >> >> >> My next question is about
>>>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
>>>> >> >> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580>
>>>> .
>>>> >> This
>>>> >> >> >> appears to address this situation although I'm not certain it
>>>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears to
>>>> be
>>>> >> >> >> scheduled
>>>> >> >> >> for 3.3 so is this what I would use once 3.3 is released and
>>>> when
>>>> >> is
>>>> >> >> 3.3
>>>> >> >> >> scheduled for release?
>>>> >> >> >>
>>>> >> >> >> Thanks
>>>> >> >> >> Tom
>>>> >> >> >> --
>>>> >> >> >> View this message in context:
>>>> >> >> >>
>>>> >> >>
>>>> >>
>>>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>>>> >> >> >> Sent from the ServiceMix - User mailing list archive at
>>>> Nabble.com.
>>>> >> >> >>
>>>> >> >> >>
>>>> >> >> >
>>>> >> >> >
>>>> >> >> > --
>>>> >> >> > Cheers,
>>>> >> >> > Guillaume Nodet
>>>> >> >> > ------------------------
>>>> >> >> > Blog: http://gnodet.blogspot.com/
>>>> >> >> >
>>>> >> >> >
>>>> >> >>
>>>> >> >> --
>>>> >> >> View this message in context:
>>>> >> >>
>>>> >>
>>>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
>>>> >> >> Sent from the ServiceMix - User mailing list archive at
>>>> Nabble.com.
>>>> >> >>
>>>> >> >>
>>>> >> >
>>>> >> >
>>>> >> > --
>>>> >> > Cheers,
>>>> >> > Guillaume Nodet
>>>> >> > ------------------------
>>>> >> > Blog: http://gnodet.blogspot.com/
>>>> >> >
>>>> >> >
>>>> >>
>>>> >> --
>>>> >> View this message in context:
>>>> >>
>>>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
>>>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> > --
>>>> > Cheers,
>>>> > Guillaume Nodet
>>>> > ------------------------
>>>> > Blog: http://gnodet.blogspot.com/
>>>> >
>>>> >
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Guillaume Nodet
>>> ------------------------
>>> Blog: http://gnodet.blogspot.com/
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16471350.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Getting started on ServiceMix - Is there any open source VM that can host linux VM on Vista
Posted by Bruce Snyder <br...@gmail.com>.
On Fri, Apr 4, 2008 at 8:37 PM, Confidential Contact <ed...@yahoo.com> wrote:
> I will appreciate if someone can point me in the right direction.
There are plenty of commercial VMs that can do this, but the only open
source VM that I'm aware of is VirtualBox Open Source Edition:
http://www.virtualbox.org/
And VirtualBox was just recently acquired by Sun.
Bruce
--
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'
Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/
Blog: http://bruceblog.org/
Re: Getting started on ServiceMix - Is there any open source VM that
can host linux VM on Vista
Posted by Lars Heinemann <la...@compart.net>.
Just try VirtualBox from InnoTek (http://www.virtualbox.org/)
Regards
Lars
Confidential Contact schrieb:
> I will appreciate if someone can point me in the right direction.
>
> Eda
>
>
> ---------------------------------
> You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
>
Getting started on ServiceMix - Is there any open source VM that can host linux VM on Vista
Posted by Confidential Contact <ed...@yahoo.com>.
I will appreciate if someone can point me in the right direction.
Eda
---------------------------------
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Done: https://issues.apache.org/activemq/browse/SM-1307 SM-1307
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16573781.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
I single patch would work too, it does not really matter.
On Sat, Apr 5, 2008 at 2:28 AM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
> "i suppose the 201 support should go in the DefaultHttpProviderMarshaler.
> Does RestProviderMarshaler inherit the DefaultHttpProviderMarshaler ?"
>
> Yes it does. So, just to be clear, put the 201 in
> DefaultHttpProviderMarshaler and add a new RestProviderMarshaler, that
> extends DefaultHttpProviderMarshaler, that has the contentExpression
> stuff.
>
> "Well, I suppose we should modify both at the same time if you have the
> patch
> for both."
>
> I'll attach a diff for each ???XPathExpression and
> DefaultHttpProviderMarshaler and a copy of RestProviderMarshaler and and a
> config example to the Jira.
>
> Thanks
> Tom
>
>
> gnodet wrote:
> >
> > On Fri, Apr 4, 2008 at 3:31 PM, Tom Purcell
> > <tp...@chariotsolutions.com>
> > wrote:
> >
> >>
> >> Guillaume
> >>
> >> I'll do that but I have a couple of questions. First the use of the new
> >> JAXPXPathExpression would be be reliant on the ability to configure the
> >> contentExpression provided by the RestProviderMarshaler. In light of
> our
> >> other discussion about the handling of HttpStatus.SC_Created (201)
> should
> >> that configuration be rolled into DefaultHttpProviderMarshaler or
> should
> >> there be a separate RestProviderMarshaler?
> >
> >
> > i suppose the 201 support should go in the DefaultHttpProviderMarshaler.
> > Does the
> > RestProviderMarshaler inherit the DefaultHttpProviderMarshaler ? If not,
> > it
> > may be worth
> > trying to refactor it a bit so that we can override the needed methods.
> >
> >
> >>
> >>
> >> Second, there is similar code in the JaxenXPathExpression class would
> you
> >> like the diff for that as well?
> >
> >
> > Well, I suppose we should modify both at the same time if you have the
> > patch
> > for both.
> >
> >>
> >>
> >> Thanks
> >> Tom
> >>
> >>
> >> gnodet wrote:
> >> >
> >> > If you have a svn diff, please attach it to a JIRA whenever you have
> >> some
> >> > time and i'll take a close look, but it sounds like a reasonable
> >> > enhancement
> >> > to the JAXPXPathExpression.
> >> >
> >> > On Thu, Apr 3, 2008 at 9:33 PM, Tom Purcell
> >> > <tp...@chariotsolutions.com>
> >> > wrote:
> >> >
> >> >>
> >> >> Guillaume
> >> >>
> >> >> I've made some progress. This is what I did.
> >> >>
> >> >> First, I switched to JAXP instead of Jaxen. The ONLY reason for this
> >> is
> >> >> I'm
> >> >> on a corporate network and they will not allow access to any URL
> with
> >> the
> >> >> "jaxen" in it thus making research difficult. (not your problem,
> just
> >> >> venting).
> >> >>
> >> >> I understood what you were saying about using a SourceTransformer
> >> instead
> >> >> of
> >> >> toString() but the problem is that by the time my getContentToSend()
> >> gets
> >> >> the result of the XPath evaluation it is already a String with the
> XML
> >> >> tags
> >> >> stripped out.
> >> >>
> >> >> 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.
> >> >>
> >> >> I need the NodeSet. Another version of the XPathExpression evaluate
> >> >> method,
> >> >> evaluate(object, returnType), allows you to control the return type
> >> but
> >> >> the
> >> >> SMX JAXPXPathExpression does not expose a way to call it. I went
> into
> >> the
> >> >> SMX JAXPXPathExpression class and did the following:
> >> >>
> >> >> 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
> >> XPathConRestProviderMarshaler
> >> >> stants.STRING as the
> >> >> QName to provide backward compatibility.
> >> >>
> >> >> In my new RestProviderMarshaler:
> >> >> protected String getContentToSend(MessageExchange exchange,
> >> >> NormalizedMessage inMsg) throws Exception {
> >> >> String content = null;
> >> >>
> >> >> if (contentExpression != null) {
> >> >> logger.debug("*** Evaluate toString: " +
> >> >> contentExpression.evaluate(exchange, inMsg));
> >> >> Node node = (Node)contentExpression.evaluate(exchange, inMsg,
> >> >> XPathConstants.NODE);
> >> >> content = transformer.toString(new DOMSource(node));
> >> >> logger.debug("*** Content toString: " + content);
> >> >> }
> >> >>
> >> >> if (content == null) {
> >> >> throw new IllegalStateException("Unable to find Content
> for
> >> >> exchange");
> >> >> }
> >> >> return content;
> >> >> }
> >> >>
> >> >> NOTE:
> >> >> I have two calls to contentExpression.evaluate() method in
> >> >> JAXPXPathExpression. The first is just in the debug and is there to
> >> >> demonstrate the backward compatibility call. This is what it
> produces
> >> in
> >> >> the
> >> >> log (No XML Tags):
> >> >>
> >> >> 14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
> >> >> toString: ServerAsset This is a Test ServerAsset, created from
> >> >> TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
> >> >> testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64
> >> 5.0.1
> >> >> 001
> >> >> 2048 2
> >> >>
> >> >> With the call to the new version
> (contentExpression.evaluate(exchange,
> >> >> inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of
> >> XML):
> >> >>
> >> >> 14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
> >> >> toString: <?xml version="1.0" encoding="UTF-8"?><asset
> >> >> name="TestServerAsset1207250490590">
> >> <class_type>ServerAsset</class_type>
> >> >> <description>This is a Test ServerAsset, created from
> >> >> TestAssetPersistenceTwo.</description>
> >> >> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
> >> >> <managed>true</managed> <category
> >> >> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
> >> >> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
> >> >> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/>
> >> <mfgName/>
> >> >> <os>REDHAT LINUX</os>
> >> >>
> >>
> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
> >> >> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
> >> >> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
> >> >> <memory>2048</memory> <cpus>2</cpus> </asset>
> >> >>
> >> >> I'm not out of the woods yet. My POST is getting to the webapp and
> the
> >> >> webapp is updating the database but things fall apart on the
> response.
> >> >> I'm
> >> >> not certain at this point whether its an issue with the wepapp's
> >> response
> >> >> or
> >> >> SMX's handling it or a little of both. I'll let you know what I find
> >> out.
> >> >>
> >> >> On the JAXPXPathExpression code, if there is another approach you
> >> think
> >> I
> >> >> should take or you'd like to get the code let me know.
> >> >>
> >> >> Thanks
> >> >> Tom
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Tom Purcell wrote:
> >> >> >
> >> >> > Guillaume
> >> >> >
> >> >> > Thabnks for the input. Responses inline
> >> >> >
> >> >> > gnodet wrote:
> >> >> >>
> >> >> >> Have you tried using the JaxenXPathExpression instead of the
> >> >> >> JaxenStringXPathExpression ?
> >> >> >>
> >> >> >> Yes, I got the same result.
> >> >> >>
> >> >> >> Also, I think you need to change the getContentToSend() method
> >> because
> >> >> >> using
> >> >> >> toString() on the result won't work. Try using the
> >> >> >> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the
> >> DOM
> >> >> >> node
> >> >> >> to a String instead.
> >> >> >>
> >> >> >> Okay, I'll play with this but the call to
> >> contentExpression.evaluate()
> >> >> in
> >> >> >> getContentToSend() returns a String object. At any rate I'll give
> >> it
> >> a
> >> >> >> shot and let you know how it goes.
> >> >> >>
> >> >> >> Thanks
> >> >> >> Tom
> >> >> >>
> >> >> >> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
> >> >> >> <tp...@chariotsolutions.com>
> >> >> >> wrote:
> >> >> >>
> >> >> >>>
> >> >> >>> Guillaume
> >> >> >>>
> >> >> >>> Below is all of what I'm doing. Notice in the logs at the bottom
> >> that
> >> >> >>> what
> >> >> >>> comes in on the NM is of type DOMSource but the object returned
> by
> >> >> the
> >> >> >>> contentExpression.evaluate() method is of type String. I think
> it
> >> >> want
> >> >> I
> >> >> >>> want is for that to be a DOMSource too. I also see the "Content
> is
> >> >> not
> >> >> >>> allowed in prolog" meesage but I think that is caused by the
> fact
> >> >> that
> >> >> >>> my
> >> >> >>> content is just the values and not the XML.
> >> >> >>>
> >> >> >>> Here's the xbean config:
> >> >> >>>
> >> >> >>> <http:provider service="wile:wileRestService"
> >> >> >>> interfaceName="wileCreate"
> >> >> >>> endpoint="wileRestCreate"
> >> >> >>> marshaler="#createMarshaler"/>
> >> >> >>>
> >> >> >>> <bean id="createMarshaler"
> >> >> class="jbi.marshal.RestProviderMarshaler">
> >> >> >>> <property name="locationURIExpression">
> >> >> >>> <bean
> >> >> >>>
> >> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
> >> >> >>> <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.JaxenStringXPathExpression">
> >> >> >>> <constructor-arg value="//asset"/>
> >> >> >>> </bean>
> >> >> >>> </property>
> >> >> >>> </bean>
> >> >> >>> </pre>
> >> >> >>>
> >> >> >>> In my RestProviderMarshaler class I added a property for
> >> >> >>> contentExpression
> >> >> >>> and replaced the createRequest method. Here are the relevant
> >> methods:
> >> >> >>>
> >> >> >>> public void createRequest(MessageExchange exchange,
> >> >> NormalizedMessage
> >> >> >>> inMsg, SmxHttpExchange httpExchange) throws Exception {
> >> >> >>> logger.debug("*** Before CREATE MessageExchange: " +
> >> >> exchange);
> >> >> >>> logger.debug("*** NM In Content: " + inMsg.getContent());
> >> >> >>> logger.debug("*** LocationURI: " +
> getLocationUri(exchange,
> >> >> >>> inMsg));
> >> >> >>>
> >> >> >>> httpExchange.setURL(getLocationUri(exchange, inMsg));
> >> >> >>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER,
> new
> >> >> >>> ByteArrayBuffer(new URI(getLocationUri(exchange,
> >> inMsg)).getHost()));
> >> >> >>> httpExchange.setMethod(getMethod(exchange, inMsg));
> >> >> >>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
> >> >> >>> getContentType(exchange, inMsg));
> >> >> >>>
> >> >> >>> if (getHeaders() != null) {
> >> >> >>> for (Map.Entry<String, String> e :
> >> >> getHeaders().entrySet())
> >> >> {
> >> >> >>> httpExchange.setRequestHeader(e.getKey(),
> >> >> e.getValue());
> >> >> >>> }
> >> >> >>> }
> >> >> >>>
> >> >> >>> String contentToSend = getContentToSend(exchange, inMsg);
> >> >> >>> logger.debug("*** Content: " + contentToSend);
> >> >> >>>
> >> >> >>> if (contentToSend != null) {
> >> >> >>> httpExchange.setRequestContent(new
> >> >> >>> ByteArrayBuffer(contentToSend.getBytes()));
> >> >> >>> }
> >> >> >>> }
> >> >> >>>
> >> >> >>> protected String getContentToSend(MessageExchange exchange,
> >> >> >>> NormalizedMessage inMsg) throws Exception {
> >> >> >>> String content = null;
> >> >> >>> if (contentExpression != null) {
> >> >> >>> Object o = contentExpression.evaluate(exchange,
> inMsg);
> >> >> >>> logger.debug("*** Content Object Type: " +
> >> o.getClass());
> >> >> >>> content = (o != null) ? o.toString() : null;
> >> >> >>> }
> >> >> >>> if (content == null) {
> >> >> >>> throw new IllegalStateException("Unable to find
> Content
> >> >> for
> >> >> >>> exchange");
> >> >> >>> }
> >> >> >>> return content;
> >> >> >>> }
> >> >> >>>
> >> >> >>> Here is what I see from the debugs:
> >> >> >>>
> >> >> >>> 16:18:59,407 - DEBUG - RestProviderMarshaler - ***
> Before
> >> >> >>> CREATE
> >> >> >>> MessageExchange: InOut[
> >> >> >>> id: ID:127.0.0.2-11910ec49ca-3:4
> >> >> >>> status: Active
> >> >> >>> role: provider
> >> >> >>> service:
> >> >> >>>
> >> >>
> >> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> <http://www.sungard.com/wile%7DwileRestService>
> >> <http://www.sungard.com/wile%7DwileRestService>
> >> >> <http://www.sungard.com/wile%7DwileRestService>
> >> >> >>> endpoint: wileRestCreate
> >> >> >>> in: <?xml version="1.0"
> >> >> >>>
> >> >>
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >> >> >>> name="TestAsset"> <class_type>BigAsset</class_type>
> >> <description>This
> >> >> is
> >> >> >>> a
> >> >> >>> Test Asset</description> <serial_number>12345</serial_number>
> >> >> >>> <enabled>true</enabled> <category guid="67890" value="Default"/>
> >> >> <type
> >> >> >>> guid="09876" value="Default"/> <state guid="54321"
> >> value="Default"/>
> >> >> >>> </asset> </assetRequest>
> >> >> >>> ]
> >> >> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM
> In
> >> >> >>> Content:
> >> >> >>> javax.xml.transform.dom.DOMSource@23cae6
> >> >> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - ***
> >> >> LocationURI:
> >> >> >>>
> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
> >> >> >>> 16:18:59,409<
> >> >>
> >>
> http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409
> >> >> >-
> >> >> >>> DEBUG - RestProviderMarshaler - *** Content Object
> >> >> >>> Type: class java.lang.String
> >> >> >>> 16:18:59,409 - DEBUG - RestProviderMarshaler - ***
> >> Content:
> >> >> >>> BigAsset This is a Test Asset 12345 true
> >> >> >>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
> >> >> >>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
> >> >> >>> [Fatal Error] :1:1: Content is not allowed in prolog.
> >> >> >>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent:
> >> InOut[
> >> >> >>> id: ID:127.0.0.2-11910ec49ca-3:4
> >> >> >>> status: Active
> >> >> >>> role: provider
> >> >> >>> service:
> >> >> >>>
> >> >>
> >> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> <http://www.sungard.com/wile%7DwileRestService>
> >> <http://www.sungard.com/wile%7DwileRestService>
> >> >> <http://www.sungard.com/wile%7DwileRestService>
> >> >> >>> endpoint: wileRestCreate
> >> >> >>> in: <?xml version="1.0"
> >> >> >>>
> >> >>
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >> >> >>> name="TestAsset"> <class_type>BigAsset</class_type>
> >> <description>This
> >> >> is
> >> >> >>> a
> >> >> >>> Test Asset</description> <serial_number>12345</serial_number>
> >> >> >>> <enabled>true</enabled> <category guid="67890" value="Default"/>
> >> >> <type
> >> >> >>> guid="09876" value="Default"/> <state guid="54321"
> >> value="Default"/>
> >> >> >>> </asset> </assetRequest>
> >> >> >>> fault: Unable to display: org.xml.sax.SAXParseException:
> Content
> >> is
> >> >> not
> >> >> >>> allowed in prolog.
> >> >> >>> ]
> >> >> >>> 16:18:59,454 - DEBUG - SedaFlow - Called
> >> Flow
> >> >> send
> >> >> >>>
> >> >> >>> Thanks
> >> >> >>> Tom
> >> >> >>>
> >> >> >>>
> >> >> >>> gnodet wrote:
> >> >> >>> >
> >> >> >>> > I suppose the creation of the content does not support writing
> >> an
> >> >> xml
> >> >> >>> > element and maybe use toString() or something like that to
> >> create
> >> >> the
> >> >> >>> > content of the request. Could you paste the endpoint
> definition
> >> >> and
> >> >> >>> > snippet
> >> >> >>> > of code, I'm not sure to fully understand your configuration.
> >> >> >>> > I think if you use a marshaler, you can really do anything you
> >> >> need.
> >> >> >>> I'm
> >> >> >>> > sure we could come with something reusable using an expression
> >> for
> >> >> the
> >> >> >>> > URL,
> >> >> >>> > the method and the content.
> >> >> >>> >
> >> >> >>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
> >> >> >>> > <tp...@chariotsolutions.com>
> >> >> >>> > wrote:
> >> >> >>> >
> >> >> >>> >>
> >> >> >>> >> Guillaume
> >> >> >>> >>
> >> >> >>> >> The message gets sent to the correct URI but the issue is the
> >> >> content
> >> >> >>> of
> >> >> >>> >> the
> >> >> >>> >> message. I need to send the XML (<foo>bar</foo>) but what
> gets
> >> >> >>> returned
> >> >> >>> >> by
> >> >> >>> >> contentExpression.evaluate(exchange, inMsg), subsequently
> sent
> >> to
> >> >> the
> >> >> >>> >> RESTful service, is just the values (bar).
> >> >> >>> >>
> >> >> >>> >> At this point I guess its really a Jaxen question. Can you
> get
> >> it
> >> >> to
> >> >> >>> >> return
> >> >> >>> >> the XML instead of just the values? Otherwise some other
> >> parsing
> >> >> >>> strategy
> >> >> >>> >> is
> >> >> >>> >> needed. However, I really liked the idea of just defining an
> >> XPath
> >> >> >>> >> expression on the endpoint. It seems it would make the
> >> marshaler
> >> >> >>> pretty
> >> >> >>> >> flexible.
> >> >> >>> >>
> >> >> >>> >> Thanks
> >> >> >>> >> Tom
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >> gnodet wrote:
> >> >> >>> >> >
> >> >> >>> >> > Well, it sounds realy good.
> >> >> >>> >> > What exactly does not work when using POST with your
> >> marshaler
> >> ?
> >> >> >>> >> >
> >> >> >>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
> >> >> >>> >> > <tp...@chariotsolutions.com>
> >> >> >>> >> > wrote:
> >> >> >>> >> >
> >> >> >>> >> >>
> >> >> >>> >> >> Guillaume
> >> >> >>> >> >>
> >> >> >>> >> >> Okay, I'm new to REST so I may be missing something there
> >> too
> >> >> but
> >> >> >>> this
> >> >> >>> >> is
> >> >> >>> >> >> where I'm at. SMX will receive a JMS message with an XML
> >> >> payload.
> >> >> >>> The
> >> >> >>> >> XML
> >> >> >>> >> >> will have two high level nodes. One node's value will be
> the
> >> >> >>> service
> >> >> >>> >> to
> >> >> >>> >> >> call
> >> >> >>> >> >> (will become part of the REST URL). The other node will be
> a
> >> >> big
> >> >> >>> chunk
> >> >> >>> >> of
> >> >> >>> >> >> XML to be POSTed to the service. The content-type is
> >> >> >>> >> >> x-www-form-urlencoded.
> >> >> >>> >> >>
> >> >> >>> >> >> I extended DefaultHttpProviderMarshaler and I call
> >> >> >>> >> >>
> >> >> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
> >> >> >>> >> >>
> >> >> >>> >> >> This almost works. I use JaxenStringXPathExpression to get
> >> the
> >> >> >>> value
> >> >> >>> >> of
> >> >> >>> >> >> the
> >> >> >>> >> >> first node and set the REST URL. Then my class has a new
> >> >> property,
> >> >> >>> >> >> contentExpression, also a JaxenStringXPathExpression. I
> use
> >> >> this
> >> >> >>> to
> >> >> >>> >> >> define
> >> >> >>> >> >> the XPath to the second node, the one with the big chunk
> of
> >> >> XML,
> >> >> >>> but
> >> >> >>> >> it
> >> >> >>> >> >> adds
> >> >> >>> >> >> the values of the second node. What I need is the chunk of
> >> XML,
> >> >> >>> >> elements,
> >> >> >>> >> >> attributes and all.
> >> >> >>> >> >>
> >> >> >>> >> >> I guess I could introduce a Saxon endpoint to do a
> >> >> transformation
> >> >> >>> and
> >> >> >>> >> a
> >> >> >>> >> >> router to send the message to different HTTP endpoints
> based
> >> on
> >> >> >>> the
> >> >> >>> >> first
> >> >> >>> >> >> node but that seems a lot less elegant than just
> dynamically
> >> >> >>> >> determining
> >> >> >>> >> >> the
> >> >> >>> >> >> REST URL in the marshaler. It works fine for GETs but then
> >> >> POST,
> >> >> >>> I'm
> >> >> >>> >> >> learning, is a different story.
> >> >> >>> >> >>
> >> >> >>> >> >> Any thoughts?
> >> >> >>> >> >>
> >> >> >>> >> >> Thanks
> >> >> >>> >> >> Tom
> >> >> >>> >> >>
> >> >> >>> >> >>
> >> >> >>> >> >> gnodet wrote:
> >> >> >>> >> >> >
> >> >> >>> >> >> > I really think the best way would be to create your own
> >> >> >>> marshaler
> >> >> >>> if
> >> >> >>> >> >> the
> >> >> >>> >> >> > default one does not work for you. If you come up with
> >> >> >>> something
> >> >> >>> >> >> generic
> >> >> >>> >> >> > enough feel free to contribute it back. However, the
> >> >> >>> >> >> > DefaultHttpProviderMarshaler should send a POST request
> if
> >> >> the
> >> >> >>> input
> >> >> >>> >> >> > message
> >> >> >>> >> >> > is not null, but this is more like a soap POST rather
> than
> >> a
> >> >> >>> form
> >> >> >>> >> post
> >> >> >>> >> >> > with
> >> >> >>> >> >> > key/value pairs. Is that what you'd need ? How do you
> >> >> extract
> >> >> >>> the
> >> >> >>> >> >> > key/value pairs from the exchange ?
> >> >> >>> >> >> >
> >> >> >>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
> >> >> >>> >> >> > <tp...@chariotsolutions.com>
> >> >> >>> >> >> > wrote:
> >> >> >>> >> >> >
> >> >> >>> >> >> >>
> >> >> >>> >> >> >> Hello
> >> >> >>> >> >> >>
> >> >> >>> >> >> >> I'm trying to use the servicemix-http http:provider to
> >> call
> >> >> a
> >> >> >>> >> RESTful
> >> >> >>> >> >> >> service. GET works fine but I'm having trouble trying
> to
> >> >> >>> configure
> >> >> >>> >> it
> >> >> >>> >> >> to
> >> >> >>> >> >> >> do
> >> >> >>> >> >> >> a post. It appears to me that
> >> DefaultHttpProviderMarshaler
> >> >> does
> >> >> >>> not
> >> >> >>> >> >> >> directly
> >> >> >>> >> >> >> support this and so I must write my own Marshaler to
> set
> >> the
> >> >> >>> >> content.
> >> >> >>> >> >> My
> >> >> >>> >> >> >> first question is just a request to verify that is
> >> correct
> >> >> and
> >> >> >>> that
> >> >> >>> >> >> I'm
> >> >> >>> >> >> >> not
> >> >> >>> >> >> >> missing something.
> >> >> >>> >> >> >>
> >> >> >>> >> >> >> My next question is about
> >> >> >>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
> >> >> >>> >> >> >> SM-580
> >> >> <http://issues.apache.org/activemq/browse/SM-580SM-580
> >> >> >
> >> >> >>> .
> >> >> >>> >> This
> >> >> >>> >> >> >> appears to address this situation although I'm not
> >> certain
> >> >> it
> >> >> >>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580
> >> appears
> >> >> to
> >> >> >>> be
> >> >> >>> >> >> >> scheduled
> >> >> >>> >> >> >> for 3.3 so is this what I would use once 3.3 is
> released
> >> and
> >> >> >>> when
> >> >> >>> >> is
> >> >> >>> >> >> 3.3
> >> >> >>> >> >> >> scheduled for release?
> >> >> >>> >> >> >>
> >> >> >>> >> >> >> Thanks
> >> >> >>> >> >> >> Tom
> >> >> >>> >> >> >> --
> >> >> >>> >> >> >> View this message in context:
> >> >> >>> >> >> >>
> >> >> >>> >> >>
> >> >> >>> >>
> >> >> >>>
> >> >>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
> >> >> >>> >> >> >> Sent from the ServiceMix - User mailing list archive at
> >> >> >>> Nabble.com.
> >> >> >>> >> >> >>
> >> >> >>> >> >> >>
> >> >> >>> >> >> >
> >> >> >>> >> >> >
> >> >> >>> >> >> > --
> >> >> >>> >> >> > Cheers,
> >> >> >>> >> >> > Guillaume Nodet
> >> >> >>> >> >> > ------------------------
> >> >> >>> >> >> > Blog: http://gnodet.blogspot.com/
> >> >> >>> >> >> >
> >> >> >>> >> >> >
> >> >> >>> >> >>
> >> >> >>> >> >> --
> >> >> >>> >> >> View this message in context:
> >> >> >>> >> >>
> >> >> >>> >>
> >> >> >>>
> >> >>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
> >> >> >>> >> >> Sent from the ServiceMix - User mailing list archive at
> >> >> >>> Nabble.com.
> >> >> >>> >> >>
> >> >> >>> >> >>
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >> > --
> >> >> >>> >> > Cheers,
> >> >> >>> >> > Guillaume Nodet
> >> >> >>> >> > ------------------------
> >> >> >>> >> > Blog: http://gnodet.blogspot.com/
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >>
> >> >> >>> >> --
> >> >> >>> >> View this message in context:
> >> >> >>> >>
> >> >> >>>
> >> >>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
> >> >> >>> >> Sent from the ServiceMix - User mailing list archive at
> >> >> Nabble.com.
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >
> >> >> >>> >
> >> >> >>> > --
> >> >> >>> > Cheers,
> >> >> >>> > Guillaume Nodet
> >> >> >>> > ------------------------
> >> >> >>> > Blog: http://gnodet.blogspot.com/
> >> >> >>> >
> >> >> >>> >
> >> >> >>>
> >> >> >>> --
> >> >> >>> View this message in context:
> >> >> >>>
> >> >>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
> >> >> >>> Sent from the ServiceMix - User mailing list archive at
> >> Nabble.com.
> >> >> >>>
> >> >> >>>
> >> >> >>
> >> >> >>
> >> >> >> --
> >> >> >> Cheers,
> >> >> >> Guillaume Nodet
> >> >> >> ------------------------
> >> >> >> Blog: http://gnodet.blogspot.com/
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16469634.html
> >> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Cheers,
> >> > Guillaume Nodet
> >> > ------------------------
> >> > Blog: http://gnodet.blogspot.com/
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16491435.html
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16507340.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
"i suppose the 201 support should go in the DefaultHttpProviderMarshaler.
Does RestProviderMarshaler inherit the DefaultHttpProviderMarshaler ?"
Yes it does. So, just to be clear, put the 201 in
DefaultHttpProviderMarshaler and add a new RestProviderMarshaler, that
extends DefaultHttpProviderMarshaler, that has the contentExpression stuff.
"Well, I suppose we should modify both at the same time if you have the
patch
for both."
I'll attach a diff for each ???XPathExpression and
DefaultHttpProviderMarshaler and a copy of RestProviderMarshaler and and a
config example to the Jira.
Thanks
Tom
gnodet wrote:
>
> On Fri, Apr 4, 2008 at 3:31 PM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>> Guillaume
>>
>> I'll do that but I have a couple of questions. First the use of the new
>> JAXPXPathExpression would be be reliant on the ability to configure the
>> contentExpression provided by the RestProviderMarshaler. In light of our
>> other discussion about the handling of HttpStatus.SC_Created (201) should
>> that configuration be rolled into DefaultHttpProviderMarshaler or should
>> there be a separate RestProviderMarshaler?
>
>
> i suppose the 201 support should go in the DefaultHttpProviderMarshaler.
> Does the
> RestProviderMarshaler inherit the DefaultHttpProviderMarshaler ? If not,
> it
> may be worth
> trying to refactor it a bit so that we can override the needed methods.
>
>
>>
>>
>> Second, there is similar code in the JaxenXPathExpression class would you
>> like the diff for that as well?
>
>
> Well, I suppose we should modify both at the same time if you have the
> patch
> for both.
>
>>
>>
>> Thanks
>> Tom
>>
>>
>> gnodet wrote:
>> >
>> > If you have a svn diff, please attach it to a JIRA whenever you have
>> some
>> > time and i'll take a close look, but it sounds like a reasonable
>> > enhancement
>> > to the JAXPXPathExpression.
>> >
>> > On Thu, Apr 3, 2008 at 9:33 PM, Tom Purcell
>> > <tp...@chariotsolutions.com>
>> > wrote:
>> >
>> >>
>> >> Guillaume
>> >>
>> >> I've made some progress. This is what I did.
>> >>
>> >> First, I switched to JAXP instead of Jaxen. The ONLY reason for this
>> is
>> >> I'm
>> >> on a corporate network and they will not allow access to any URL with
>> the
>> >> "jaxen" in it thus making research difficult. (not your problem, just
>> >> venting).
>> >>
>> >> I understood what you were saying about using a SourceTransformer
>> instead
>> >> of
>> >> toString() but the problem is that by the time my getContentToSend()
>> gets
>> >> the result of the XPath evaluation it is already a String with the XML
>> >> tags
>> >> stripped out.
>> >>
>> >> 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.
>> >>
>> >> I need the NodeSet. Another version of the XPathExpression evaluate
>> >> method,
>> >> evaluate(object, returnType), allows you to control the return type
>> but
>> >> the
>> >> SMX JAXPXPathExpression does not expose a way to call it. I went into
>> the
>> >> SMX JAXPXPathExpression class and did the following:
>> >>
>> >> 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
>> XPathConRestProviderMarshaler
>> >> stants.STRING as the
>> >> QName to provide backward compatibility.
>> >>
>> >> In my new RestProviderMarshaler:
>> >> protected String getContentToSend(MessageExchange exchange,
>> >> NormalizedMessage inMsg) throws Exception {
>> >> String content = null;
>> >>
>> >> if (contentExpression != null) {
>> >> logger.debug("*** Evaluate toString: " +
>> >> contentExpression.evaluate(exchange, inMsg));
>> >> Node node = (Node)contentExpression.evaluate(exchange, inMsg,
>> >> XPathConstants.NODE);
>> >> content = transformer.toString(new DOMSource(node));
>> >> logger.debug("*** Content toString: " + content);
>> >> }
>> >>
>> >> if (content == null) {
>> >> throw new IllegalStateException("Unable to find Content for
>> >> exchange");
>> >> }
>> >> return content;
>> >> }
>> >>
>> >> NOTE:
>> >> I have two calls to contentExpression.evaluate() method in
>> >> JAXPXPathExpression. The first is just in the debug and is there to
>> >> demonstrate the backward compatibility call. This is what it produces
>> in
>> >> the
>> >> log (No XML Tags):
>> >>
>> >> 14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
>> >> toString: ServerAsset This is a Test ServerAsset, created from
>> >> TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
>> >> testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64
>> 5.0.1
>> >> 001
>> >> 2048 2
>> >>
>> >> With the call to the new version (contentExpression.evaluate(exchange,
>> >> inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of
>> XML):
>> >>
>> >> 14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
>> >> toString: <?xml version="1.0" encoding="UTF-8"?><asset
>> >> name="TestServerAsset1207250490590">
>> <class_type>ServerAsset</class_type>
>> >> <description>This is a Test ServerAsset, created from
>> >> TestAssetPersistenceTwo.</description>
>> >> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
>> >> <managed>true</managed> <category
>> >> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
>> >> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
>> >> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/>
>> <mfgName/>
>> >> <os>REDHAT LINUX</os>
>> >>
>> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
>> >> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
>> >> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
>> >> <memory>2048</memory> <cpus>2</cpus> </asset>
>> >>
>> >> I'm not out of the woods yet. My POST is getting to the webapp and the
>> >> webapp is updating the database but things fall apart on the response.
>> >> I'm
>> >> not certain at this point whether its an issue with the wepapp's
>> response
>> >> or
>> >> SMX's handling it or a little of both. I'll let you know what I find
>> out.
>> >>
>> >> On the JAXPXPathExpression code, if there is another approach you
>> think
>> I
>> >> should take or you'd like to get the code let me know.
>> >>
>> >> Thanks
>> >> Tom
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Tom Purcell wrote:
>> >> >
>> >> > Guillaume
>> >> >
>> >> > Thabnks for the input. Responses inline
>> >> >
>> >> > gnodet wrote:
>> >> >>
>> >> >> Have you tried using the JaxenXPathExpression instead of the
>> >> >> JaxenStringXPathExpression ?
>> >> >>
>> >> >> Yes, I got the same result.
>> >> >>
>> >> >> Also, I think you need to change the getContentToSend() method
>> because
>> >> >> using
>> >> >> toString() on the result won't work. Try using the
>> >> >> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the
>> DOM
>> >> >> node
>> >> >> to a String instead.
>> >> >>
>> >> >> Okay, I'll play with this but the call to
>> contentExpression.evaluate()
>> >> in
>> >> >> getContentToSend() returns a String object. At any rate I'll give
>> it
>> a
>> >> >> shot and let you know how it goes.
>> >> >>
>> >> >> Thanks
>> >> >> Tom
>> >> >>
>> >> >> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
>> >> >> <tp...@chariotsolutions.com>
>> >> >> wrote:
>> >> >>
>> >> >>>
>> >> >>> Guillaume
>> >> >>>
>> >> >>> Below is all of what I'm doing. Notice in the logs at the bottom
>> that
>> >> >>> what
>> >> >>> comes in on the NM is of type DOMSource but the object returned by
>> >> the
>> >> >>> contentExpression.evaluate() method is of type String. I think it
>> >> want
>> >> I
>> >> >>> want is for that to be a DOMSource too. I also see the "Content is
>> >> not
>> >> >>> allowed in prolog" meesage but I think that is caused by the fact
>> >> that
>> >> >>> my
>> >> >>> content is just the values and not the XML.
>> >> >>>
>> >> >>> Here's the xbean config:
>> >> >>>
>> >> >>> <http:provider service="wile:wileRestService"
>> >> >>> interfaceName="wileCreate"
>> >> >>> endpoint="wileRestCreate"
>> >> >>> marshaler="#createMarshaler"/>
>> >> >>>
>> >> >>> <bean id="createMarshaler"
>> >> class="jbi.marshal.RestProviderMarshaler">
>> >> >>> <property name="locationURIExpression">
>> >> >>> <bean
>> >> >>>
>> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
>> >> >>> <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.JaxenStringXPathExpression">
>> >> >>> <constructor-arg value="//asset"/>
>> >> >>> </bean>
>> >> >>> </property>
>> >> >>> </bean>
>> >> >>> </pre>
>> >> >>>
>> >> >>> In my RestProviderMarshaler class I added a property for
>> >> >>> contentExpression
>> >> >>> and replaced the createRequest method. Here are the relevant
>> methods:
>> >> >>>
>> >> >>> public void createRequest(MessageExchange exchange,
>> >> NormalizedMessage
>> >> >>> inMsg, SmxHttpExchange httpExchange) throws Exception {
>> >> >>> logger.debug("*** Before CREATE MessageExchange: " +
>> >> exchange);
>> >> >>> logger.debug("*** NM In Content: " + inMsg.getContent());
>> >> >>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
>> >> >>> inMsg));
>> >> >>>
>> >> >>> httpExchange.setURL(getLocationUri(exchange, inMsg));
>> >> >>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
>> >> >>> ByteArrayBuffer(new URI(getLocationUri(exchange,
>> inMsg)).getHost()));
>> >> >>> httpExchange.setMethod(getMethod(exchange, inMsg));
>> >> >>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
>> >> >>> getContentType(exchange, inMsg));
>> >> >>>
>> >> >>> if (getHeaders() != null) {
>> >> >>> for (Map.Entry<String, String> e :
>> >> getHeaders().entrySet())
>> >> {
>> >> >>> httpExchange.setRequestHeader(e.getKey(),
>> >> e.getValue());
>> >> >>> }
>> >> >>> }
>> >> >>>
>> >> >>> String contentToSend = getContentToSend(exchange, inMsg);
>> >> >>> logger.debug("*** Content: " + contentToSend);
>> >> >>>
>> >> >>> if (contentToSend != null) {
>> >> >>> httpExchange.setRequestContent(new
>> >> >>> ByteArrayBuffer(contentToSend.getBytes()));
>> >> >>> }
>> >> >>> }
>> >> >>>
>> >> >>> protected String getContentToSend(MessageExchange exchange,
>> >> >>> NormalizedMessage inMsg) throws Exception {
>> >> >>> String content = null;
>> >> >>> if (contentExpression != null) {
>> >> >>> Object o = contentExpression.evaluate(exchange, inMsg);
>> >> >>> logger.debug("*** Content Object Type: " +
>> o.getClass());
>> >> >>> content = (o != null) ? o.toString() : null;
>> >> >>> }
>> >> >>> if (content == null) {
>> >> >>> throw new IllegalStateException("Unable to find Content
>> >> for
>> >> >>> exchange");
>> >> >>> }
>> >> >>> return content;
>> >> >>> }
>> >> >>>
>> >> >>> Here is what I see from the debugs:
>> >> >>>
>> >> >>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before
>> >> >>> CREATE
>> >> >>> MessageExchange: InOut[
>> >> >>> id: ID:127.0.0.2-11910ec49ca-3:4
>> >> >>> status: Active
>> >> >>> role: provider
>> >> >>> service:
>> >> >>>
>> >>
>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>> <http://www.sungard.com/wile%7DwileRestService>
>> >> <http://www.sungard.com/wile%7DwileRestService>
>> >> >>> endpoint: wileRestCreate
>> >> >>> in: <?xml version="1.0"
>> >> >>>
>> >> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> >> >>> name="TestAsset"> <class_type>BigAsset</class_type>
>> <description>This
>> >> is
>> >> >>> a
>> >> >>> Test Asset</description> <serial_number>12345</serial_number>
>> >> >>> <enabled>true</enabled> <category guid="67890" value="Default"/>
>> >> <type
>> >> >>> guid="09876" value="Default"/> <state guid="54321"
>> value="Default"/>
>> >> >>> </asset> </assetRequest>
>> >> >>> ]
>> >> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
>> >> >>> Content:
>> >> >>> javax.xml.transform.dom.DOMSource@23cae6
>> >> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - ***
>> >> LocationURI:
>> >> >>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
>> >> >>> 16:18:59,409<
>> >>
>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409
>> >> >-
>> >> >>> DEBUG - RestProviderMarshaler - *** Content Object
>> >> >>> Type: class java.lang.String
>> >> >>> 16:18:59,409 - DEBUG - RestProviderMarshaler - ***
>> Content:
>> >> >>> BigAsset This is a Test Asset 12345 true
>> >> >>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
>> >> >>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
>> >> >>> [Fatal Error] :1:1: Content is not allowed in prolog.
>> >> >>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent:
>> InOut[
>> >> >>> id: ID:127.0.0.2-11910ec49ca-3:4
>> >> >>> status: Active
>> >> >>> role: provider
>> >> >>> service:
>> >> >>>
>> >>
>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>> <http://www.sungard.com/wile%7DwileRestService>
>> >> <http://www.sungard.com/wile%7DwileRestService>
>> >> >>> endpoint: wileRestCreate
>> >> >>> in: <?xml version="1.0"
>> >> >>>
>> >> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> >> >>> name="TestAsset"> <class_type>BigAsset</class_type>
>> <description>This
>> >> is
>> >> >>> a
>> >> >>> Test Asset</description> <serial_number>12345</serial_number>
>> >> >>> <enabled>true</enabled> <category guid="67890" value="Default"/>
>> >> <type
>> >> >>> guid="09876" value="Default"/> <state guid="54321"
>> value="Default"/>
>> >> >>> </asset> </assetRequest>
>> >> >>> fault: Unable to display: org.xml.sax.SAXParseException: Content
>> is
>> >> not
>> >> >>> allowed in prolog.
>> >> >>> ]
>> >> >>> 16:18:59,454 - DEBUG - SedaFlow - Called
>> Flow
>> >> send
>> >> >>>
>> >> >>> Thanks
>> >> >>> Tom
>> >> >>>
>> >> >>>
>> >> >>> gnodet wrote:
>> >> >>> >
>> >> >>> > I suppose the creation of the content does not support writing
>> an
>> >> xml
>> >> >>> > element and maybe use toString() or something like that to
>> create
>> >> the
>> >> >>> > content of the request. Could you paste the endpoint definition
>> >> and
>> >> >>> > snippet
>> >> >>> > of code, I'm not sure to fully understand your configuration.
>> >> >>> > I think if you use a marshaler, you can really do anything you
>> >> need.
>> >> >>> I'm
>> >> >>> > sure we could come with something reusable using an expression
>> for
>> >> the
>> >> >>> > URL,
>> >> >>> > the method and the content.
>> >> >>> >
>> >> >>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
>> >> >>> > <tp...@chariotsolutions.com>
>> >> >>> > wrote:
>> >> >>> >
>> >> >>> >>
>> >> >>> >> Guillaume
>> >> >>> >>
>> >> >>> >> The message gets sent to the correct URI but the issue is the
>> >> content
>> >> >>> of
>> >> >>> >> the
>> >> >>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
>> >> >>> returned
>> >> >>> >> by
>> >> >>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent
>> to
>> >> the
>> >> >>> >> RESTful service, is just the values (bar).
>> >> >>> >>
>> >> >>> >> At this point I guess its really a Jaxen question. Can you get
>> it
>> >> to
>> >> >>> >> return
>> >> >>> >> the XML instead of just the values? Otherwise some other
>> parsing
>> >> >>> strategy
>> >> >>> >> is
>> >> >>> >> needed. However, I really liked the idea of just defining an
>> XPath
>> >> >>> >> expression on the endpoint. It seems it would make the
>> marshaler
>> >> >>> pretty
>> >> >>> >> flexible.
>> >> >>> >>
>> >> >>> >> Thanks
>> >> >>> >> Tom
>> >> >>> >>
>> >> >>> >>
>> >> >>> >>
>> >> >>> >> gnodet wrote:
>> >> >>> >> >
>> >> >>> >> > Well, it sounds realy good.
>> >> >>> >> > What exactly does not work when using POST with your
>> marshaler
>> ?
>> >> >>> >> >
>> >> >>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
>> >> >>> >> > <tp...@chariotsolutions.com>
>> >> >>> >> > wrote:
>> >> >>> >> >
>> >> >>> >> >>
>> >> >>> >> >> Guillaume
>> >> >>> >> >>
>> >> >>> >> >> Okay, I'm new to REST so I may be missing something there
>> too
>> >> but
>> >> >>> this
>> >> >>> >> is
>> >> >>> >> >> where I'm at. SMX will receive a JMS message with an XML
>> >> payload.
>> >> >>> The
>> >> >>> >> XML
>> >> >>> >> >> will have two high level nodes. One node's value will be the
>> >> >>> service
>> >> >>> >> to
>> >> >>> >> >> call
>> >> >>> >> >> (will become part of the REST URL). The other node will be a
>> >> big
>> >> >>> chunk
>> >> >>> >> of
>> >> >>> >> >> XML to be POSTed to the service. The content-type is
>> >> >>> >> >> x-www-form-urlencoded.
>> >> >>> >> >>
>> >> >>> >> >> I extended DefaultHttpProviderMarshaler and I call
>> >> >>> >> >>
>> >> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>> >> >>> >> >>
>> >> >>> >> >> This almost works. I use JaxenStringXPathExpression to get
>> the
>> >> >>> value
>> >> >>> >> of
>> >> >>> >> >> the
>> >> >>> >> >> first node and set the REST URL. Then my class has a new
>> >> property,
>> >> >>> >> >> contentExpression, also a JaxenStringXPathExpression. I use
>> >> this
>> >> >>> to
>> >> >>> >> >> define
>> >> >>> >> >> the XPath to the second node, the one with the big chunk of
>> >> XML,
>> >> >>> but
>> >> >>> >> it
>> >> >>> >> >> adds
>> >> >>> >> >> the values of the second node. What I need is the chunk of
>> XML,
>> >> >>> >> elements,
>> >> >>> >> >> attributes and all.
>> >> >>> >> >>
>> >> >>> >> >> I guess I could introduce a Saxon endpoint to do a
>> >> transformation
>> >> >>> and
>> >> >>> >> a
>> >> >>> >> >> router to send the message to different HTTP endpoints based
>> on
>> >> >>> the
>> >> >>> >> first
>> >> >>> >> >> node but that seems a lot less elegant than just dynamically
>> >> >>> >> determining
>> >> >>> >> >> the
>> >> >>> >> >> REST URL in the marshaler. It works fine for GETs but then
>> >> POST,
>> >> >>> I'm
>> >> >>> >> >> learning, is a different story.
>> >> >>> >> >>
>> >> >>> >> >> Any thoughts?
>> >> >>> >> >>
>> >> >>> >> >> Thanks
>> >> >>> >> >> Tom
>> >> >>> >> >>
>> >> >>> >> >>
>> >> >>> >> >> gnodet wrote:
>> >> >>> >> >> >
>> >> >>> >> >> > I really think the best way would be to create your own
>> >> >>> marshaler
>> >> >>> if
>> >> >>> >> >> the
>> >> >>> >> >> > default one does not work for you. If you come up with
>> >> >>> something
>> >> >>> >> >> generic
>> >> >>> >> >> > enough feel free to contribute it back. However, the
>> >> >>> >> >> > DefaultHttpProviderMarshaler should send a POST request if
>> >> the
>> >> >>> input
>> >> >>> >> >> > message
>> >> >>> >> >> > is not null, but this is more like a soap POST rather than
>> a
>> >> >>> form
>> >> >>> >> post
>> >> >>> >> >> > with
>> >> >>> >> >> > key/value pairs. Is that what you'd need ? How do you
>> >> extract
>> >> >>> the
>> >> >>> >> >> > key/value pairs from the exchange ?
>> >> >>> >> >> >
>> >> >>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
>> >> >>> >> >> > <tp...@chariotsolutions.com>
>> >> >>> >> >> > wrote:
>> >> >>> >> >> >
>> >> >>> >> >> >>
>> >> >>> >> >> >> Hello
>> >> >>> >> >> >>
>> >> >>> >> >> >> I'm trying to use the servicemix-http http:provider to
>> call
>> >> a
>> >> >>> >> RESTful
>> >> >>> >> >> >> service. GET works fine but I'm having trouble trying to
>> >> >>> configure
>> >> >>> >> it
>> >> >>> >> >> to
>> >> >>> >> >> >> do
>> >> >>> >> >> >> a post. It appears to me that
>> DefaultHttpProviderMarshaler
>> >> does
>> >> >>> not
>> >> >>> >> >> >> directly
>> >> >>> >> >> >> support this and so I must write my own Marshaler to set
>> the
>> >> >>> >> content.
>> >> >>> >> >> My
>> >> >>> >> >> >> first question is just a request to verify that is
>> correct
>> >> and
>> >> >>> that
>> >> >>> >> >> I'm
>> >> >>> >> >> >> not
>> >> >>> >> >> >> missing something.
>> >> >>> >> >> >>
>> >> >>> >> >> >> My next question is about
>> >> >>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
>> >> >>> >> >> >> SM-580
>> >> <http://issues.apache.org/activemq/browse/SM-580SM-580
>> >> >
>> >> >>> .
>> >> >>> >> This
>> >> >>> >> >> >> appears to address this situation although I'm not
>> certain
>> >> it
>> >> >>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580
>> appears
>> >> to
>> >> >>> be
>> >> >>> >> >> >> scheduled
>> >> >>> >> >> >> for 3.3 so is this what I would use once 3.3 is released
>> and
>> >> >>> when
>> >> >>> >> is
>> >> >>> >> >> 3.3
>> >> >>> >> >> >> scheduled for release?
>> >> >>> >> >> >>
>> >> >>> >> >> >> Thanks
>> >> >>> >> >> >> Tom
>> >> >>> >> >> >> --
>> >> >>> >> >> >> View this message in context:
>> >> >>> >> >> >>
>> >> >>> >> >>
>> >> >>> >>
>> >> >>>
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>> >> >>> >> >> >> Sent from the ServiceMix - User mailing list archive at
>> >> >>> Nabble.com.
>> >> >>> >> >> >>
>> >> >>> >> >> >>
>> >> >>> >> >> >
>> >> >>> >> >> >
>> >> >>> >> >> > --
>> >> >>> >> >> > Cheers,
>> >> >>> >> >> > Guillaume Nodet
>> >> >>> >> >> > ------------------------
>> >> >>> >> >> > Blog: http://gnodet.blogspot.com/
>> >> >>> >> >> >
>> >> >>> >> >> >
>> >> >>> >> >>
>> >> >>> >> >> --
>> >> >>> >> >> View this message in context:
>> >> >>> >> >>
>> >> >>> >>
>> >> >>>
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
>> >> >>> >> >> Sent from the ServiceMix - User mailing list archive at
>> >> >>> Nabble.com.
>> >> >>> >> >>
>> >> >>> >> >>
>> >> >>> >> >
>> >> >>> >> >
>> >> >>> >> > --
>> >> >>> >> > Cheers,
>> >> >>> >> > Guillaume Nodet
>> >> >>> >> > ------------------------
>> >> >>> >> > Blog: http://gnodet.blogspot.com/
>> >> >>> >> >
>> >> >>> >> >
>> >> >>> >>
>> >> >>> >> --
>> >> >>> >> View this message in context:
>> >> >>> >>
>> >> >>>
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
>> >> >>> >> Sent from the ServiceMix - User mailing list archive at
>> >> Nabble.com.
>> >> >>> >>
>> >> >>> >>
>> >> >>> >
>> >> >>> >
>> >> >>> > --
>> >> >>> > Cheers,
>> >> >>> > Guillaume Nodet
>> >> >>> > ------------------------
>> >> >>> > Blog: http://gnodet.blogspot.com/
>> >> >>> >
>> >> >>> >
>> >> >>>
>> >> >>> --
>> >> >>> View this message in context:
>> >> >>>
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
>> >> >>> Sent from the ServiceMix - User mailing list archive at
>> Nabble.com.
>> >> >>>
>> >> >>>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Cheers,
>> >> >> Guillaume Nodet
>> >> >> ------------------------
>> >> >> Blog: http://gnodet.blogspot.com/
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16469634.html
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16491435.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16507340.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
On Fri, Apr 4, 2008 at 3:31 PM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
>
> I'll do that but I have a couple of questions. First the use of the new
> JAXPXPathExpression would be be reliant on the ability to configure the
> contentExpression provided by the RestProviderMarshaler. In light of our
> other discussion about the handling of HttpStatus.SC_Created (201) should
> that configuration be rolled into DefaultHttpProviderMarshaler or should
> there be a separate RestProviderMarshaler?
i suppose the 201 support should go in the DefaultHttpProviderMarshaler.
Does the
RestProviderMarshaler inherit the DefaultHttpProviderMarshaler ? If not, it
may be worth
trying to refactor it a bit so that we can override the needed methods.
>
>
> Second, there is similar code in the JaxenXPathExpression class would you
> like the diff for that as well?
Well, I suppose we should modify both at the same time if you have the patch
for both.
>
>
> Thanks
> Tom
>
>
> gnodet wrote:
> >
> > If you have a svn diff, please attach it to a JIRA whenever you have
> some
> > time and i'll take a close look, but it sounds like a reasonable
> > enhancement
> > to the JAXPXPathExpression.
> >
> > On Thu, Apr 3, 2008 at 9:33 PM, Tom Purcell
> > <tp...@chariotsolutions.com>
> > wrote:
> >
> >>
> >> Guillaume
> >>
> >> I've made some progress. This is what I did.
> >>
> >> First, I switched to JAXP instead of Jaxen. The ONLY reason for this is
> >> I'm
> >> on a corporate network and they will not allow access to any URL with
> the
> >> "jaxen" in it thus making research difficult. (not your problem, just
> >> venting).
> >>
> >> I understood what you were saying about using a SourceTransformer
> instead
> >> of
> >> toString() but the problem is that by the time my getContentToSend()
> gets
> >> the result of the XPath evaluation it is already a String with the XML
> >> tags
> >> stripped out.
> >>
> >> 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.
> >>
> >> I need the NodeSet. Another version of the XPathExpression evaluate
> >> method,
> >> evaluate(object, returnType), allows you to control the return type but
> >> the
> >> SMX JAXPXPathExpression does not expose a way to call it. I went into
> the
> >> SMX JAXPXPathExpression class and did the following:
> >>
> >> 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
> XPathConRestProviderMarshaler
> >> stants.STRING as the
> >> QName to provide backward compatibility.
> >>
> >> In my new RestProviderMarshaler:
> >> protected String getContentToSend(MessageExchange exchange,
> >> NormalizedMessage inMsg) throws Exception {
> >> String content = null;
> >>
> >> if (contentExpression != null) {
> >> logger.debug("*** Evaluate toString: " +
> >> contentExpression.evaluate(exchange, inMsg));
> >> Node node = (Node)contentExpression.evaluate(exchange, inMsg,
> >> XPathConstants.NODE);
> >> content = transformer.toString(new DOMSource(node));
> >> logger.debug("*** Content toString: " + content);
> >> }
> >>
> >> if (content == null) {
> >> throw new IllegalStateException("Unable to find Content for
> >> exchange");
> >> }
> >> return content;
> >> }
> >>
> >> NOTE:
> >> I have two calls to contentExpression.evaluate() method in
> >> JAXPXPathExpression. The first is just in the debug and is there to
> >> demonstrate the backward compatibility call. This is what it produces
> in
> >> the
> >> log (No XML Tags):
> >>
> >> 14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
> >> toString: ServerAsset This is a Test ServerAsset, created from
> >> TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
> >> testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64 5.0.1
> >> 001
> >> 2048 2
> >>
> >> With the call to the new version (contentExpression.evaluate(exchange,
> >> inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of
> XML):
> >>
> >> 14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
> >> toString: <?xml version="1.0" encoding="UTF-8"?><asset
> >> name="TestServerAsset1207250490590">
> <class_type>ServerAsset</class_type>
> >> <description>This is a Test ServerAsset, created from
> >> TestAssetPersistenceTwo.</description>
> >> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
> >> <managed>true</managed> <category
> >> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
> >> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
> >> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/>
> <mfgName/>
> >> <os>REDHAT LINUX</os>
> >>
> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
> >> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
> >> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
> >> <memory>2048</memory> <cpus>2</cpus> </asset>
> >>
> >> I'm not out of the woods yet. My POST is getting to the webapp and the
> >> webapp is updating the database but things fall apart on the response.
> >> I'm
> >> not certain at this point whether its an issue with the wepapp's
> response
> >> or
> >> SMX's handling it or a little of both. I'll let you know what I find
> out.
> >>
> >> On the JAXPXPathExpression code, if there is another approach you think
> I
> >> should take or you'd like to get the code let me know.
> >>
> >> Thanks
> >> Tom
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> Tom Purcell wrote:
> >> >
> >> > Guillaume
> >> >
> >> > Thabnks for the input. Responses inline
> >> >
> >> > gnodet wrote:
> >> >>
> >> >> Have you tried using the JaxenXPathExpression instead of the
> >> >> JaxenStringXPathExpression ?
> >> >>
> >> >> Yes, I got the same result.
> >> >>
> >> >> Also, I think you need to change the getContentToSend() method
> because
> >> >> using
> >> >> toString() on the result won't work. Try using the
> >> >> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the
> DOM
> >> >> node
> >> >> to a String instead.
> >> >>
> >> >> Okay, I'll play with this but the call to
> contentExpression.evaluate()
> >> in
> >> >> getContentToSend() returns a String object. At any rate I'll give it
> a
> >> >> shot and let you know how it goes.
> >> >>
> >> >> Thanks
> >> >> Tom
> >> >>
> >> >> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
> >> >> <tp...@chariotsolutions.com>
> >> >> wrote:
> >> >>
> >> >>>
> >> >>> Guillaume
> >> >>>
> >> >>> Below is all of what I'm doing. Notice in the logs at the bottom
> that
> >> >>> what
> >> >>> comes in on the NM is of type DOMSource but the object returned by
> >> the
> >> >>> contentExpression.evaluate() method is of type String. I think it
> >> want
> >> I
> >> >>> want is for that to be a DOMSource too. I also see the "Content is
> >> not
> >> >>> allowed in prolog" meesage but I think that is caused by the fact
> >> that
> >> >>> my
> >> >>> content is just the values and not the XML.
> >> >>>
> >> >>> Here's the xbean config:
> >> >>>
> >> >>> <http:provider service="wile:wileRestService"
> >> >>> interfaceName="wileCreate"
> >> >>> endpoint="wileRestCreate"
> >> >>> marshaler="#createMarshaler"/>
> >> >>>
> >> >>> <bean id="createMarshaler"
> >> class="jbi.marshal.RestProviderMarshaler">
> >> >>> <property name="locationURIExpression">
> >> >>> <bean
> >> >>>
> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
> >> >>> <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.JaxenStringXPathExpression">
> >> >>> <constructor-arg value="//asset"/>
> >> >>> </bean>
> >> >>> </property>
> >> >>> </bean>
> >> >>> </pre>
> >> >>>
> >> >>> In my RestProviderMarshaler class I added a property for
> >> >>> contentExpression
> >> >>> and replaced the createRequest method. Here are the relevant
> methods:
> >> >>>
> >> >>> public void createRequest(MessageExchange exchange,
> >> NormalizedMessage
> >> >>> inMsg, SmxHttpExchange httpExchange) throws Exception {
> >> >>> logger.debug("*** Before CREATE MessageExchange: " +
> >> exchange);
> >> >>> logger.debug("*** NM In Content: " + inMsg.getContent());
> >> >>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
> >> >>> inMsg));
> >> >>>
> >> >>> httpExchange.setURL(getLocationUri(exchange, inMsg));
> >> >>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
> >> >>> ByteArrayBuffer(new URI(getLocationUri(exchange,
> inMsg)).getHost()));
> >> >>> httpExchange.setMethod(getMethod(exchange, inMsg));
> >> >>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
> >> >>> getContentType(exchange, inMsg));
> >> >>>
> >> >>> if (getHeaders() != null) {
> >> >>> for (Map.Entry<String, String> e :
> >> getHeaders().entrySet())
> >> {
> >> >>> httpExchange.setRequestHeader(e.getKey(),
> >> e.getValue());
> >> >>> }
> >> >>> }
> >> >>>
> >> >>> String contentToSend = getContentToSend(exchange, inMsg);
> >> >>> logger.debug("*** Content: " + contentToSend);
> >> >>>
> >> >>> if (contentToSend != null) {
> >> >>> httpExchange.setRequestContent(new
> >> >>> ByteArrayBuffer(contentToSend.getBytes()));
> >> >>> }
> >> >>> }
> >> >>>
> >> >>> protected String getContentToSend(MessageExchange exchange,
> >> >>> NormalizedMessage inMsg) throws Exception {
> >> >>> String content = null;
> >> >>> if (contentExpression != null) {
> >> >>> Object o = contentExpression.evaluate(exchange, inMsg);
> >> >>> logger.debug("*** Content Object Type: " +
> o.getClass());
> >> >>> content = (o != null) ? o.toString() : null;
> >> >>> }
> >> >>> if (content == null) {
> >> >>> throw new IllegalStateException("Unable to find Content
> >> for
> >> >>> exchange");
> >> >>> }
> >> >>> return content;
> >> >>> }
> >> >>>
> >> >>> Here is what I see from the debugs:
> >> >>>
> >> >>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before
> >> >>> CREATE
> >> >>> MessageExchange: InOut[
> >> >>> id: ID:127.0.0.2-11910ec49ca-3:4
> >> >>> status: Active
> >> >>> role: provider
> >> >>> service:
> >> >>>
> >> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> <http://www.sungard.com/wile%7DwileRestService>
> >> <http://www.sungard.com/wile%7DwileRestService>
> >> >>> endpoint: wileRestCreate
> >> >>> in: <?xml version="1.0"
> >> >>>
> >> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >> >>> name="TestAsset"> <class_type>BigAsset</class_type>
> <description>This
> >> is
> >> >>> a
> >> >>> Test Asset</description> <serial_number>12345</serial_number>
> >> >>> <enabled>true</enabled> <category guid="67890" value="Default"/>
> >> <type
> >> >>> guid="09876" value="Default"/> <state guid="54321"
> value="Default"/>
> >> >>> </asset> </assetRequest>
> >> >>> ]
> >> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
> >> >>> Content:
> >> >>> javax.xml.transform.dom.DOMSource@23cae6
> >> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - ***
> >> LocationURI:
> >> >>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
> >> >>> 16:18:59,409<
> >>
> http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409
> >> >-
> >> >>> DEBUG - RestProviderMarshaler - *** Content Object
> >> >>> Type: class java.lang.String
> >> >>> 16:18:59,409 - DEBUG - RestProviderMarshaler - ***
> Content:
> >> >>> BigAsset This is a Test Asset 12345 true
> >> >>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
> >> >>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
> >> >>> [Fatal Error] :1:1: Content is not allowed in prolog.
> >> >>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent:
> InOut[
> >> >>> id: ID:127.0.0.2-11910ec49ca-3:4
> >> >>> status: Active
> >> >>> role: provider
> >> >>> service:
> >> >>>
> >> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> <http://www.sungard.com/wile%7DwileRestService>
> >> <http://www.sungard.com/wile%7DwileRestService>
> >> >>> endpoint: wileRestCreate
> >> >>> in: <?xml version="1.0"
> >> >>>
> >> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >> >>> name="TestAsset"> <class_type>BigAsset</class_type>
> <description>This
> >> is
> >> >>> a
> >> >>> Test Asset</description> <serial_number>12345</serial_number>
> >> >>> <enabled>true</enabled> <category guid="67890" value="Default"/>
> >> <type
> >> >>> guid="09876" value="Default"/> <state guid="54321"
> value="Default"/>
> >> >>> </asset> </assetRequest>
> >> >>> fault: Unable to display: org.xml.sax.SAXParseException: Content
> is
> >> not
> >> >>> allowed in prolog.
> >> >>> ]
> >> >>> 16:18:59,454 - DEBUG - SedaFlow - Called Flow
> >> send
> >> >>>
> >> >>> Thanks
> >> >>> Tom
> >> >>>
> >> >>>
> >> >>> gnodet wrote:
> >> >>> >
> >> >>> > I suppose the creation of the content does not support writing an
> >> xml
> >> >>> > element and maybe use toString() or something like that to create
> >> the
> >> >>> > content of the request. Could you paste the endpoint definition
> >> and
> >> >>> > snippet
> >> >>> > of code, I'm not sure to fully understand your configuration.
> >> >>> > I think if you use a marshaler, you can really do anything you
> >> need.
> >> >>> I'm
> >> >>> > sure we could come with something reusable using an expression
> for
> >> the
> >> >>> > URL,
> >> >>> > the method and the content.
> >> >>> >
> >> >>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
> >> >>> > <tp...@chariotsolutions.com>
> >> >>> > wrote:
> >> >>> >
> >> >>> >>
> >> >>> >> Guillaume
> >> >>> >>
> >> >>> >> The message gets sent to the correct URI but the issue is the
> >> content
> >> >>> of
> >> >>> >> the
> >> >>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
> >> >>> returned
> >> >>> >> by
> >> >>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent
> to
> >> the
> >> >>> >> RESTful service, is just the values (bar).
> >> >>> >>
> >> >>> >> At this point I guess its really a Jaxen question. Can you get
> it
> >> to
> >> >>> >> return
> >> >>> >> the XML instead of just the values? Otherwise some other parsing
> >> >>> strategy
> >> >>> >> is
> >> >>> >> needed. However, I really liked the idea of just defining an
> XPath
> >> >>> >> expression on the endpoint. It seems it would make the marshaler
> >> >>> pretty
> >> >>> >> flexible.
> >> >>> >>
> >> >>> >> Thanks
> >> >>> >> Tom
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> gnodet wrote:
> >> >>> >> >
> >> >>> >> > Well, it sounds realy good.
> >> >>> >> > What exactly does not work when using POST with your marshaler
> ?
> >> >>> >> >
> >> >>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
> >> >>> >> > <tp...@chariotsolutions.com>
> >> >>> >> > wrote:
> >> >>> >> >
> >> >>> >> >>
> >> >>> >> >> Guillaume
> >> >>> >> >>
> >> >>> >> >> Okay, I'm new to REST so I may be missing something there too
> >> but
> >> >>> this
> >> >>> >> is
> >> >>> >> >> where I'm at. SMX will receive a JMS message with an XML
> >> payload.
> >> >>> The
> >> >>> >> XML
> >> >>> >> >> will have two high level nodes. One node's value will be the
> >> >>> service
> >> >>> >> to
> >> >>> >> >> call
> >> >>> >> >> (will become part of the REST URL). The other node will be a
> >> big
> >> >>> chunk
> >> >>> >> of
> >> >>> >> >> XML to be POSTed to the service. The content-type is
> >> >>> >> >> x-www-form-urlencoded.
> >> >>> >> >>
> >> >>> >> >> I extended DefaultHttpProviderMarshaler and I call
> >> >>> >> >>
> >> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
> >> >>> >> >>
> >> >>> >> >> This almost works. I use JaxenStringXPathExpression to get
> the
> >> >>> value
> >> >>> >> of
> >> >>> >> >> the
> >> >>> >> >> first node and set the REST URL. Then my class has a new
> >> property,
> >> >>> >> >> contentExpression, also a JaxenStringXPathExpression. I use
> >> this
> >> >>> to
> >> >>> >> >> define
> >> >>> >> >> the XPath to the second node, the one with the big chunk of
> >> XML,
> >> >>> but
> >> >>> >> it
> >> >>> >> >> adds
> >> >>> >> >> the values of the second node. What I need is the chunk of
> XML,
> >> >>> >> elements,
> >> >>> >> >> attributes and all.
> >> >>> >> >>
> >> >>> >> >> I guess I could introduce a Saxon endpoint to do a
> >> transformation
> >> >>> and
> >> >>> >> a
> >> >>> >> >> router to send the message to different HTTP endpoints based
> on
> >> >>> the
> >> >>> >> first
> >> >>> >> >> node but that seems a lot less elegant than just dynamically
> >> >>> >> determining
> >> >>> >> >> the
> >> >>> >> >> REST URL in the marshaler. It works fine for GETs but then
> >> POST,
> >> >>> I'm
> >> >>> >> >> learning, is a different story.
> >> >>> >> >>
> >> >>> >> >> Any thoughts?
> >> >>> >> >>
> >> >>> >> >> Thanks
> >> >>> >> >> Tom
> >> >>> >> >>
> >> >>> >> >>
> >> >>> >> >> gnodet wrote:
> >> >>> >> >> >
> >> >>> >> >> > I really think the best way would be to create your own
> >> >>> marshaler
> >> >>> if
> >> >>> >> >> the
> >> >>> >> >> > default one does not work for you. If you come up with
> >> >>> something
> >> >>> >> >> generic
> >> >>> >> >> > enough feel free to contribute it back. However, the
> >> >>> >> >> > DefaultHttpProviderMarshaler should send a POST request if
> >> the
> >> >>> input
> >> >>> >> >> > message
> >> >>> >> >> > is not null, but this is more like a soap POST rather than
> a
> >> >>> form
> >> >>> >> post
> >> >>> >> >> > with
> >> >>> >> >> > key/value pairs. Is that what you'd need ? How do you
> >> extract
> >> >>> the
> >> >>> >> >> > key/value pairs from the exchange ?
> >> >>> >> >> >
> >> >>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
> >> >>> >> >> > <tp...@chariotsolutions.com>
> >> >>> >> >> > wrote:
> >> >>> >> >> >
> >> >>> >> >> >>
> >> >>> >> >> >> Hello
> >> >>> >> >> >>
> >> >>> >> >> >> I'm trying to use the servicemix-http http:provider to
> call
> >> a
> >> >>> >> RESTful
> >> >>> >> >> >> service. GET works fine but I'm having trouble trying to
> >> >>> configure
> >> >>> >> it
> >> >>> >> >> to
> >> >>> >> >> >> do
> >> >>> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler
> >> does
> >> >>> not
> >> >>> >> >> >> directly
> >> >>> >> >> >> support this and so I must write my own Marshaler to set
> the
> >> >>> >> content.
> >> >>> >> >> My
> >> >>> >> >> >> first question is just a request to verify that is correct
> >> and
> >> >>> that
> >> >>> >> >> I'm
> >> >>> >> >> >> not
> >> >>> >> >> >> missing something.
> >> >>> >> >> >>
> >> >>> >> >> >> My next question is about
> >> >>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
> >> >>> >> >> >> SM-580
> >> <http://issues.apache.org/activemq/browse/SM-580SM-580
> >> >
> >> >>> .
> >> >>> >> This
> >> >>> >> >> >> appears to address this situation although I'm not certain
> >> it
> >> >>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears
> >> to
> >> >>> be
> >> >>> >> >> >> scheduled
> >> >>> >> >> >> for 3.3 so is this what I would use once 3.3 is released
> and
> >> >>> when
> >> >>> >> is
> >> >>> >> >> 3.3
> >> >>> >> >> >> scheduled for release?
> >> >>> >> >> >>
> >> >>> >> >> >> Thanks
> >> >>> >> >> >> Tom
> >> >>> >> >> >> --
> >> >>> >> >> >> View this message in context:
> >> >>> >> >> >>
> >> >>> >> >>
> >> >>> >>
> >> >>>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
> >> >>> >> >> >> Sent from the ServiceMix - User mailing list archive at
> >> >>> Nabble.com.
> >> >>> >> >> >>
> >> >>> >> >> >>
> >> >>> >> >> >
> >> >>> >> >> >
> >> >>> >> >> > --
> >> >>> >> >> > Cheers,
> >> >>> >> >> > Guillaume Nodet
> >> >>> >> >> > ------------------------
> >> >>> >> >> > Blog: http://gnodet.blogspot.com/
> >> >>> >> >> >
> >> >>> >> >> >
> >> >>> >> >>
> >> >>> >> >> --
> >> >>> >> >> View this message in context:
> >> >>> >> >>
> >> >>> >>
> >> >>>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
> >> >>> >> >> Sent from the ServiceMix - User mailing list archive at
> >> >>> Nabble.com.
> >> >>> >> >>
> >> >>> >> >>
> >> >>> >> >
> >> >>> >> >
> >> >>> >> > --
> >> >>> >> > Cheers,
> >> >>> >> > Guillaume Nodet
> >> >>> >> > ------------------------
> >> >>> >> > Blog: http://gnodet.blogspot.com/
> >> >>> >> >
> >> >>> >> >
> >> >>> >>
> >> >>> >> --
> >> >>> >> View this message in context:
> >> >>> >>
> >> >>>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
> >> >>> >> Sent from the ServiceMix - User mailing list archive at
> >> Nabble.com.
> >> >>> >>
> >> >>> >>
> >> >>> >
> >> >>> >
> >> >>> > --
> >> >>> > Cheers,
> >> >>> > Guillaume Nodet
> >> >>> > ------------------------
> >> >>> > Blog: http://gnodet.blogspot.com/
> >> >>> >
> >> >>> >
> >> >>>
> >> >>> --
> >> >>> View this message in context:
> >> >>>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
> >> >>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >> >>>
> >> >>>
> >> >>
> >> >>
> >> >> --
> >> >> Cheers,
> >> >> Guillaume Nodet
> >> >> ------------------------
> >> >> Blog: http://gnodet.blogspot.com/
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16469634.html
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16491435.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
I'll do that but I have a couple of questions. First the use of the new
JAXPXPathExpression would be be reliant on the ability to configure the
contentExpression provided by the RestProviderMarshaler. In light of our
other discussion about the handling of HttpStatus.SC_Created (201) should
that configuration be rolled into DefaultHttpProviderMarshaler or should
there be a separate RestProviderMarshaler?
Second, there is similar code in the JaxenXPathExpression class would you
like the diff for that as well?
Thanks
Tom
gnodet wrote:
>
> If you have a svn diff, please attach it to a JIRA whenever you have some
> time and i'll take a close look, but it sounds like a reasonable
> enhancement
> to the JAXPXPathExpression.
>
> On Thu, Apr 3, 2008 at 9:33 PM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>> Guillaume
>>
>> I've made some progress. This is what I did.
>>
>> First, I switched to JAXP instead of Jaxen. The ONLY reason for this is
>> I'm
>> on a corporate network and they will not allow access to any URL with the
>> "jaxen" in it thus making research difficult. (not your problem, just
>> venting).
>>
>> I understood what you were saying about using a SourceTransformer instead
>> of
>> toString() but the problem is that by the time my getContentToSend() gets
>> the result of the XPath evaluation it is already a String with the XML
>> tags
>> stripped out.
>>
>> 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.
>>
>> I need the NodeSet. Another version of the XPathExpression evaluate
>> method,
>> evaluate(object, returnType), allows you to control the return type but
>> the
>> SMX JAXPXPathExpression does not expose a way to call it. I went into the
>> SMX JAXPXPathExpression class and did the following:
>>
>> 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 XPathConRestProviderMarshaler
>> stants.STRING as the
>> QName to provide backward compatibility.
>>
>> In my new RestProviderMarshaler:
>> protected String getContentToSend(MessageExchange exchange,
>> NormalizedMessage inMsg) throws Exception {
>> String content = null;
>>
>> if (contentExpression != null) {
>> logger.debug("*** Evaluate toString: " +
>> contentExpression.evaluate(exchange, inMsg));
>> Node node = (Node)contentExpression.evaluate(exchange, inMsg,
>> XPathConstants.NODE);
>> content = transformer.toString(new DOMSource(node));
>> logger.debug("*** Content toString: " + content);
>> }
>>
>> if (content == null) {
>> throw new IllegalStateException("Unable to find Content for
>> exchange");
>> }
>> return content;
>> }
>>
>> NOTE:
>> I have two calls to contentExpression.evaluate() method in
>> JAXPXPathExpression. The first is just in the debug and is there to
>> demonstrate the backward compatibility call. This is what it produces in
>> the
>> log (No XML Tags):
>>
>> 14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
>> toString: ServerAsset This is a Test ServerAsset, created from
>> TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
>> testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64 5.0.1
>> 001
>> 2048 2
>>
>> With the call to the new version (contentExpression.evaluate(exchange,
>> inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of XML):
>>
>> 14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
>> toString: <?xml version="1.0" encoding="UTF-8"?><asset
>> name="TestServerAsset1207250490590"> <class_type>ServerAsset</class_type>
>> <description>This is a Test ServerAsset, created from
>> TestAssetPersistenceTwo.</description>
>> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
>> <managed>true</managed> <category
>> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
>> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
>> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
>> <os>REDHAT LINUX</os>
>> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
>> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
>> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
>> <memory>2048</memory> <cpus>2</cpus> </asset>
>>
>> I'm not out of the woods yet. My POST is getting to the webapp and the
>> webapp is updating the database but things fall apart on the response.
>> I'm
>> not certain at this point whether its an issue with the wepapp's response
>> or
>> SMX's handling it or a little of both. I'll let you know what I find out.
>>
>> On the JAXPXPathExpression code, if there is another approach you think I
>> should take or you'd like to get the code let me know.
>>
>> Thanks
>> Tom
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Tom Purcell wrote:
>> >
>> > Guillaume
>> >
>> > Thabnks for the input. Responses inline
>> >
>> > gnodet wrote:
>> >>
>> >> Have you tried using the JaxenXPathExpression instead of the
>> >> JaxenStringXPathExpression ?
>> >>
>> >> Yes, I got the same result.
>> >>
>> >> Also, I think you need to change the getContentToSend() method because
>> >> using
>> >> toString() on the result won't work. Try using the
>> >> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the DOM
>> >> node
>> >> to a String instead.
>> >>
>> >> Okay, I'll play with this but the call to contentExpression.evaluate()
>> in
>> >> getContentToSend() returns a String object. At any rate I'll give it a
>> >> shot and let you know how it goes.
>> >>
>> >> Thanks
>> >> Tom
>> >>
>> >> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
>> >> <tp...@chariotsolutions.com>
>> >> wrote:
>> >>
>> >>>
>> >>> Guillaume
>> >>>
>> >>> Below is all of what I'm doing. Notice in the logs at the bottom that
>> >>> what
>> >>> comes in on the NM is of type DOMSource but the object returned by
>> the
>> >>> contentExpression.evaluate() method is of type String. I think it
>> want
>> I
>> >>> want is for that to be a DOMSource too. I also see the "Content is
>> not
>> >>> allowed in prolog" meesage but I think that is caused by the fact
>> that
>> >>> my
>> >>> content is just the values and not the XML.
>> >>>
>> >>> Here's the xbean config:
>> >>>
>> >>> <http:provider service="wile:wileRestService"
>> >>> interfaceName="wileCreate"
>> >>> endpoint="wileRestCreate"
>> >>> marshaler="#createMarshaler"/>
>> >>>
>> >>> <bean id="createMarshaler"
>> class="jbi.marshal.RestProviderMarshaler">
>> >>> <property name="locationURIExpression">
>> >>> <bean
>> >>> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
>> >>> <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.JaxenStringXPathExpression">
>> >>> <constructor-arg value="//asset"/>
>> >>> </bean>
>> >>> </property>
>> >>> </bean>
>> >>> </pre>
>> >>>
>> >>> In my RestProviderMarshaler class I added a property for
>> >>> contentExpression
>> >>> and replaced the createRequest method. Here are the relevant methods:
>> >>>
>> >>> public void createRequest(MessageExchange exchange,
>> NormalizedMessage
>> >>> inMsg, SmxHttpExchange httpExchange) throws Exception {
>> >>> logger.debug("*** Before CREATE MessageExchange: " +
>> exchange);
>> >>> logger.debug("*** NM In Content: " + inMsg.getContent());
>> >>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
>> >>> inMsg));
>> >>>
>> >>> httpExchange.setURL(getLocationUri(exchange, inMsg));
>> >>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
>> >>> ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
>> >>> httpExchange.setMethod(getMethod(exchange, inMsg));
>> >>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
>> >>> getContentType(exchange, inMsg));
>> >>>
>> >>> if (getHeaders() != null) {
>> >>> for (Map.Entry<String, String> e :
>> getHeaders().entrySet())
>> {
>> >>> httpExchange.setRequestHeader(e.getKey(),
>> e.getValue());
>> >>> }
>> >>> }
>> >>>
>> >>> String contentToSend = getContentToSend(exchange, inMsg);
>> >>> logger.debug("*** Content: " + contentToSend);
>> >>>
>> >>> if (contentToSend != null) {
>> >>> httpExchange.setRequestContent(new
>> >>> ByteArrayBuffer(contentToSend.getBytes()));
>> >>> }
>> >>> }
>> >>>
>> >>> protected String getContentToSend(MessageExchange exchange,
>> >>> NormalizedMessage inMsg) throws Exception {
>> >>> String content = null;
>> >>> if (contentExpression != null) {
>> >>> Object o = contentExpression.evaluate(exchange, inMsg);
>> >>> logger.debug("*** Content Object Type: " + o.getClass());
>> >>> content = (o != null) ? o.toString() : null;
>> >>> }
>> >>> if (content == null) {
>> >>> throw new IllegalStateException("Unable to find Content
>> for
>> >>> exchange");
>> >>> }
>> >>> return content;
>> >>> }
>> >>>
>> >>> Here is what I see from the debugs:
>> >>>
>> >>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before
>> >>> CREATE
>> >>> MessageExchange: InOut[
>> >>> id: ID:127.0.0.2-11910ec49ca-3:4
>> >>> status: Active
>> >>> role: provider
>> >>> service:
>> >>>
>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>> <http://www.sungard.com/wile%7DwileRestService>
>> >>> endpoint: wileRestCreate
>> >>> in: <?xml version="1.0"
>> >>>
>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> >>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This
>> is
>> >>> a
>> >>> Test Asset</description> <serial_number>12345</serial_number>
>> >>> <enabled>true</enabled> <category guid="67890" value="Default"/>
>> <type
>> >>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>> >>> </asset> </assetRequest>
>> >>> ]
>> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
>> >>> Content:
>> >>> javax.xml.transform.dom.DOMSource@23cae6
>> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - ***
>> LocationURI:
>> >>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
>> >>> 16:18:59,409<
>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409
>> >-
>> >>> DEBUG - RestProviderMarshaler - *** Content Object
>> >>> Type: class java.lang.String
>> >>> 16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
>> >>> BigAsset This is a Test Asset 12345 true
>> >>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
>> >>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
>> >>> [Fatal Error] :1:1: Content is not allowed in prolog.
>> >>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
>> >>> id: ID:127.0.0.2-11910ec49ca-3:4
>> >>> status: Active
>> >>> role: provider
>> >>> service:
>> >>>
>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>> <http://www.sungard.com/wile%7DwileRestService>
>> >>> endpoint: wileRestCreate
>> >>> in: <?xml version="1.0"
>> >>>
>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> >>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This
>> is
>> >>> a
>> >>> Test Asset</description> <serial_number>12345</serial_number>
>> >>> <enabled>true</enabled> <category guid="67890" value="Default"/>
>> <type
>> >>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>> >>> </asset> </assetRequest>
>> >>> fault: Unable to display: org.xml.sax.SAXParseException: Content is
>> not
>> >>> allowed in prolog.
>> >>> ]
>> >>> 16:18:59,454 - DEBUG - SedaFlow - Called Flow
>> send
>> >>>
>> >>> Thanks
>> >>> Tom
>> >>>
>> >>>
>> >>> gnodet wrote:
>> >>> >
>> >>> > I suppose the creation of the content does not support writing an
>> xml
>> >>> > element and maybe use toString() or something like that to create
>> the
>> >>> > content of the request. Could you paste the endpoint definition
>> and
>> >>> > snippet
>> >>> > of code, I'm not sure to fully understand your configuration.
>> >>> > I think if you use a marshaler, you can really do anything you
>> need.
>> >>> I'm
>> >>> > sure we could come with something reusable using an expression for
>> the
>> >>> > URL,
>> >>> > the method and the content.
>> >>> >
>> >>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
>> >>> > <tp...@chariotsolutions.com>
>> >>> > wrote:
>> >>> >
>> >>> >>
>> >>> >> Guillaume
>> >>> >>
>> >>> >> The message gets sent to the correct URI but the issue is the
>> content
>> >>> of
>> >>> >> the
>> >>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
>> >>> returned
>> >>> >> by
>> >>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent to
>> the
>> >>> >> RESTful service, is just the values (bar).
>> >>> >>
>> >>> >> At this point I guess its really a Jaxen question. Can you get it
>> to
>> >>> >> return
>> >>> >> the XML instead of just the values? Otherwise some other parsing
>> >>> strategy
>> >>> >> is
>> >>> >> needed. However, I really liked the idea of just defining an XPath
>> >>> >> expression on the endpoint. It seems it would make the marshaler
>> >>> pretty
>> >>> >> flexible.
>> >>> >>
>> >>> >> Thanks
>> >>> >> Tom
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> gnodet wrote:
>> >>> >> >
>> >>> >> > Well, it sounds realy good.
>> >>> >> > What exactly does not work when using POST with your marshaler ?
>> >>> >> >
>> >>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
>> >>> >> > <tp...@chariotsolutions.com>
>> >>> >> > wrote:
>> >>> >> >
>> >>> >> >>
>> >>> >> >> Guillaume
>> >>> >> >>
>> >>> >> >> Okay, I'm new to REST so I may be missing something there too
>> but
>> >>> this
>> >>> >> is
>> >>> >> >> where I'm at. SMX will receive a JMS message with an XML
>> payload.
>> >>> The
>> >>> >> XML
>> >>> >> >> will have two high level nodes. One node's value will be the
>> >>> service
>> >>> >> to
>> >>> >> >> call
>> >>> >> >> (will become part of the REST URL). The other node will be a
>> big
>> >>> chunk
>> >>> >> of
>> >>> >> >> XML to be POSTed to the service. The content-type is
>> >>> >> >> x-www-form-urlencoded.
>> >>> >> >>
>> >>> >> >> I extended DefaultHttpProviderMarshaler and I call
>> >>> >> >>
>> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>> >>> >> >>
>> >>> >> >> This almost works. I use JaxenStringXPathExpression to get the
>> >>> value
>> >>> >> of
>> >>> >> >> the
>> >>> >> >> first node and set the REST URL. Then my class has a new
>> property,
>> >>> >> >> contentExpression, also a JaxenStringXPathExpression. I use
>> this
>> >>> to
>> >>> >> >> define
>> >>> >> >> the XPath to the second node, the one with the big chunk of
>> XML,
>> >>> but
>> >>> >> it
>> >>> >> >> adds
>> >>> >> >> the values of the second node. What I need is the chunk of XML,
>> >>> >> elements,
>> >>> >> >> attributes and all.
>> >>> >> >>
>> >>> >> >> I guess I could introduce a Saxon endpoint to do a
>> transformation
>> >>> and
>> >>> >> a
>> >>> >> >> router to send the message to different HTTP endpoints based on
>> >>> the
>> >>> >> first
>> >>> >> >> node but that seems a lot less elegant than just dynamically
>> >>> >> determining
>> >>> >> >> the
>> >>> >> >> REST URL in the marshaler. It works fine for GETs but then
>> POST,
>> >>> I'm
>> >>> >> >> learning, is a different story.
>> >>> >> >>
>> >>> >> >> Any thoughts?
>> >>> >> >>
>> >>> >> >> Thanks
>> >>> >> >> Tom
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> gnodet wrote:
>> >>> >> >> >
>> >>> >> >> > I really think the best way would be to create your own
>> >>> marshaler
>> >>> if
>> >>> >> >> the
>> >>> >> >> > default one does not work for you. If you come up with
>> >>> something
>> >>> >> >> generic
>> >>> >> >> > enough feel free to contribute it back. However, the
>> >>> >> >> > DefaultHttpProviderMarshaler should send a POST request if
>> the
>> >>> input
>> >>> >> >> > message
>> >>> >> >> > is not null, but this is more like a soap POST rather than a
>> >>> form
>> >>> >> post
>> >>> >> >> > with
>> >>> >> >> > key/value pairs. Is that what you'd need ? How do you
>> extract
>> >>> the
>> >>> >> >> > key/value pairs from the exchange ?
>> >>> >> >> >
>> >>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
>> >>> >> >> > <tp...@chariotsolutions.com>
>> >>> >> >> > wrote:
>> >>> >> >> >
>> >>> >> >> >>
>> >>> >> >> >> Hello
>> >>> >> >> >>
>> >>> >> >> >> I'm trying to use the servicemix-http http:provider to call
>> a
>> >>> >> RESTful
>> >>> >> >> >> service. GET works fine but I'm having trouble trying to
>> >>> configure
>> >>> >> it
>> >>> >> >> to
>> >>> >> >> >> do
>> >>> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler
>> does
>> >>> not
>> >>> >> >> >> directly
>> >>> >> >> >> support this and so I must write my own Marshaler to set the
>> >>> >> content.
>> >>> >> >> My
>> >>> >> >> >> first question is just a request to verify that is correct
>> and
>> >>> that
>> >>> >> >> I'm
>> >>> >> >> >> not
>> >>> >> >> >> missing something.
>> >>> >> >> >>
>> >>> >> >> >> My next question is about
>> >>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
>> >>> >> >> >> SM-580
>> <http://issues.apache.org/activemq/browse/SM-580SM-580
>> >
>> >>> .
>> >>> >> This
>> >>> >> >> >> appears to address this situation although I'm not certain
>> it
>> >>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears
>> to
>> >>> be
>> >>> >> >> >> scheduled
>> >>> >> >> >> for 3.3 so is this what I would use once 3.3 is released and
>> >>> when
>> >>> >> is
>> >>> >> >> 3.3
>> >>> >> >> >> scheduled for release?
>> >>> >> >> >>
>> >>> >> >> >> Thanks
>> >>> >> >> >> Tom
>> >>> >> >> >> --
>> >>> >> >> >> View this message in context:
>> >>> >> >> >>
>> >>> >> >>
>> >>> >>
>> >>>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>> >>> >> >> >> Sent from the ServiceMix - User mailing list archive at
>> >>> Nabble.com.
>> >>> >> >> >>
>> >>> >> >> >>
>> >>> >> >> >
>> >>> >> >> >
>> >>> >> >> > --
>> >>> >> >> > Cheers,
>> >>> >> >> > Guillaume Nodet
>> >>> >> >> > ------------------------
>> >>> >> >> > Blog: http://gnodet.blogspot.com/
>> >>> >> >> >
>> >>> >> >> >
>> >>> >> >>
>> >>> >> >> --
>> >>> >> >> View this message in context:
>> >>> >> >>
>> >>> >>
>> >>>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
>> >>> >> >> Sent from the ServiceMix - User mailing list archive at
>> >>> Nabble.com.
>> >>> >> >>
>> >>> >> >>
>> >>> >> >
>> >>> >> >
>> >>> >> > --
>> >>> >> > Cheers,
>> >>> >> > Guillaume Nodet
>> >>> >> > ------------------------
>> >>> >> > Blog: http://gnodet.blogspot.com/
>> >>> >> >
>> >>> >> >
>> >>> >>
>> >>> >> --
>> >>> >> View this message in context:
>> >>> >>
>> >>>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
>> >>> >> Sent from the ServiceMix - User mailing list archive at
>> Nabble.com.
>> >>> >>
>> >>> >>
>> >>> >
>> >>> >
>> >>> > --
>> >>> > Cheers,
>> >>> > Guillaume Nodet
>> >>> > ------------------------
>> >>> > Blog: http://gnodet.blogspot.com/
>> >>> >
>> >>> >
>> >>>
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
>> >>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>
>> >>
>> >> --
>> >> Cheers,
>> >> Guillaume Nodet
>> >> ------------------------
>> >> Blog: http://gnodet.blogspot.com/
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16469634.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16491435.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
If you have a svn diff, please attach it to a JIRA whenever you have some
time and i'll take a close look, but it sounds like a reasonable enhancement
to the JAXPXPathExpression.
On Thu, Apr 3, 2008 at 9:33 PM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
>
> I've made some progress. This is what I did.
>
> First, I switched to JAXP instead of Jaxen. The ONLY reason for this is
> I'm
> on a corporate network and they will not allow access to any URL with the
> "jaxen" in it thus making research difficult. (not your problem, just
> venting).
>
> I understood what you were saying about using a SourceTransformer instead
> of
> toString() but the problem is that by the time my getContentToSend() gets
> the result of the XPath evaluation it is already a String with the XML
> tags
> stripped out.
>
> 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.
>
> I need the NodeSet. Another version of the XPathExpression evaluate
> method,
> evaluate(object, returnType), allows you to control the return type but
> the
> SMX JAXPXPathExpression does not expose a way to call it. I went into the
> SMX JAXPXPathExpression class and did the following:
>
> 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.
>
> In my new RestProviderMarshaler:
> protected String getContentToSend(MessageExchange exchange,
> NormalizedMessage inMsg) throws Exception {
> String content = null;
>
> if (contentExpression != null) {
> logger.debug("*** Evaluate toString: " +
> contentExpression.evaluate(exchange, inMsg));
> Node node = (Node)contentExpression.evaluate(exchange, inMsg,
> XPathConstants.NODE);
> content = transformer.toString(new DOMSource(node));
> logger.debug("*** Content toString: " + content);
> }
>
> if (content == null) {
> throw new IllegalStateException("Unable to find Content for
> exchange");
> }
> return content;
> }
>
> NOTE:
> I have two calls to contentExpression.evaluate() method in
> JAXPXPathExpression. The first is just in the debug and is there to
> demonstrate the backward compatibility call. This is what it produces in
> the
> log (No XML Tags):
>
> 14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
> toString: ServerAsset This is a Test ServerAsset, created from
> TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
> testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64 5.0.1
> 001
> 2048 2
>
> With the call to the new version (contentExpression.evaluate(exchange,
> inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of XML):
>
> 14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
> toString: <?xml version="1.0" encoding="UTF-8"?><asset
> name="TestServerAsset1207250490590"> <class_type>ServerAsset</class_type>
> <description>This is a Test ServerAsset, created from
> TestAssetPersistenceTwo.</description>
> <serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
> <managed>true</managed> <category
> guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
> guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
> guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
> <os>REDHAT LINUX</os>
> <host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
> <domain_name>sgns.net</domain_name> <platform>OS64</platform>
> <os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
> <memory>2048</memory> <cpus>2</cpus> </asset>
>
> I'm not out of the woods yet. My POST is getting to the webapp and the
> webapp is updating the database but things fall apart on the response. I'm
> not certain at this point whether its an issue with the wepapp's response
> or
> SMX's handling it or a little of both. I'll let you know what I find out.
>
> On the JAXPXPathExpression code, if there is another approach you think I
> should take or you'd like to get the code let me know.
>
> Thanks
> Tom
>
>
>
>
>
>
>
>
>
> Tom Purcell wrote:
> >
> > Guillaume
> >
> > Thabnks for the input. Responses inline
> >
> > gnodet wrote:
> >>
> >> Have you tried using the JaxenXPathExpression instead of the
> >> JaxenStringXPathExpression ?
> >>
> >> Yes, I got the same result.
> >>
> >> Also, I think you need to change the getContentToSend() method because
> >> using
> >> toString() on the result won't work. Try using the
> >> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the DOM
> >> node
> >> to a String instead.
> >>
> >> Okay, I'll play with this but the call to contentExpression.evaluate()
> in
> >> getContentToSend() returns a String object. At any rate I'll give it a
> >> shot and let you know how it goes.
> >>
> >> Thanks
> >> Tom
> >>
> >> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
> >> <tp...@chariotsolutions.com>
> >> wrote:
> >>
> >>>
> >>> Guillaume
> >>>
> >>> Below is all of what I'm doing. Notice in the logs at the bottom that
> >>> what
> >>> comes in on the NM is of type DOMSource but the object returned by the
> >>> contentExpression.evaluate() method is of type String. I think it want
> I
> >>> want is for that to be a DOMSource too. I also see the "Content is not
> >>> allowed in prolog" meesage but I think that is caused by the fact that
> >>> my
> >>> content is just the values and not the XML.
> >>>
> >>> Here's the xbean config:
> >>>
> >>> <http:provider service="wile:wileRestService"
> >>> interfaceName="wileCreate"
> >>> endpoint="wileRestCreate"
> >>> marshaler="#createMarshaler"/>
> >>>
> >>> <bean id="createMarshaler"
> class="jbi.marshal.RestProviderMarshaler">
> >>> <property name="locationURIExpression">
> >>> <bean
> >>> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
> >>> <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.JaxenStringXPathExpression">
> >>> <constructor-arg value="//asset"/>
> >>> </bean>
> >>> </property>
> >>> </bean>
> >>> </pre>
> >>>
> >>> In my RestProviderMarshaler class I added a property for
> >>> contentExpression
> >>> and replaced the createRequest method. Here are the relevant methods:
> >>>
> >>> public void createRequest(MessageExchange exchange,
> NormalizedMessage
> >>> inMsg, SmxHttpExchange httpExchange) throws Exception {
> >>> logger.debug("*** Before CREATE MessageExchange: " + exchange);
> >>> logger.debug("*** NM In Content: " + inMsg.getContent());
> >>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
> >>> inMsg));
> >>>
> >>> httpExchange.setURL(getLocationUri(exchange, inMsg));
> >>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
> >>> ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
> >>> httpExchange.setMethod(getMethod(exchange, inMsg));
> >>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
> >>> getContentType(exchange, inMsg));
> >>>
> >>> if (getHeaders() != null) {
> >>> for (Map.Entry<String, String> e : getHeaders().entrySet())
> {
> >>> httpExchange.setRequestHeader(e.getKey(),
> e.getValue());
> >>> }
> >>> }
> >>>
> >>> String contentToSend = getContentToSend(exchange, inMsg);
> >>> logger.debug("*** Content: " + contentToSend);
> >>>
> >>> if (contentToSend != null) {
> >>> httpExchange.setRequestContent(new
> >>> ByteArrayBuffer(contentToSend.getBytes()));
> >>> }
> >>> }
> >>>
> >>> protected String getContentToSend(MessageExchange exchange,
> >>> NormalizedMessage inMsg) throws Exception {
> >>> String content = null;
> >>> if (contentExpression != null) {
> >>> Object o = contentExpression.evaluate(exchange, inMsg);
> >>> logger.debug("*** Content Object Type: " + o.getClass());
> >>> content = (o != null) ? o.toString() : null;
> >>> }
> >>> if (content == null) {
> >>> throw new IllegalStateException("Unable to find Content for
> >>> exchange");
> >>> }
> >>> return content;
> >>> }
> >>>
> >>> Here is what I see from the debugs:
> >>>
> >>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before
> >>> CREATE
> >>> MessageExchange: InOut[
> >>> id: ID:127.0.0.2-11910ec49ca-3:4
> >>> status: Active
> >>> role: provider
> >>> service:
> >>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> <http://www.sungard.com/wile%7DwileRestService>
> >>> endpoint: wileRestCreate
> >>> in: <?xml version="1.0"
> >>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This
> is
> >>> a
> >>> Test Asset</description> <serial_number>12345</serial_number>
> >>> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
> >>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
> >>> </asset> </assetRequest>
> >>> ]
> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
> >>> Content:
> >>> javax.xml.transform.dom.DOMSource@23cae6
> >>> 16:18:59,408 - DEBUG - RestProviderMarshaler - ***
> LocationURI:
> >>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
> >>> 16:18:59,409<
> http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409
> >-
> >>> DEBUG - RestProviderMarshaler - *** Content Object
> >>> Type: class java.lang.String
> >>> 16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
> >>> BigAsset This is a Test Asset 12345 true
> >>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
> >>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
> >>> [Fatal Error] :1:1: Content is not allowed in prolog.
> >>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
> >>> id: ID:127.0.0.2-11910ec49ca-3:4
> >>> status: Active
> >>> role: provider
> >>> service:
> >>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> <http://www.sungard.com/wile%7DwileRestService>
> >>> endpoint: wileRestCreate
> >>> in: <?xml version="1.0"
> >>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> >>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This
> is
> >>> a
> >>> Test Asset</description> <serial_number>12345</serial_number>
> >>> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
> >>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
> >>> </asset> </assetRequest>
> >>> fault: Unable to display: org.xml.sax.SAXParseException: Content is
> not
> >>> allowed in prolog.
> >>> ]
> >>> 16:18:59,454 - DEBUG - SedaFlow - Called Flow
> send
> >>>
> >>> Thanks
> >>> Tom
> >>>
> >>>
> >>> gnodet wrote:
> >>> >
> >>> > I suppose the creation of the content does not support writing an
> xml
> >>> > element and maybe use toString() or something like that to create
> the
> >>> > content of the request. Could you paste the endpoint definition and
> >>> > snippet
> >>> > of code, I'm not sure to fully understand your configuration.
> >>> > I think if you use a marshaler, you can really do anything you need.
> >>> I'm
> >>> > sure we could come with something reusable using an expression for
> the
> >>> > URL,
> >>> > the method and the content.
> >>> >
> >>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
> >>> > <tp...@chariotsolutions.com>
> >>> > wrote:
> >>> >
> >>> >>
> >>> >> Guillaume
> >>> >>
> >>> >> The message gets sent to the correct URI but the issue is the
> content
> >>> of
> >>> >> the
> >>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
> >>> returned
> >>> >> by
> >>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent to
> the
> >>> >> RESTful service, is just the values (bar).
> >>> >>
> >>> >> At this point I guess its really a Jaxen question. Can you get it
> to
> >>> >> return
> >>> >> the XML instead of just the values? Otherwise some other parsing
> >>> strategy
> >>> >> is
> >>> >> needed. However, I really liked the idea of just defining an XPath
> >>> >> expression on the endpoint. It seems it would make the marshaler
> >>> pretty
> >>> >> flexible.
> >>> >>
> >>> >> Thanks
> >>> >> Tom
> >>> >>
> >>> >>
> >>> >>
> >>> >> gnodet wrote:
> >>> >> >
> >>> >> > Well, it sounds realy good.
> >>> >> > What exactly does not work when using POST with your marshaler ?
> >>> >> >
> >>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
> >>> >> > <tp...@chariotsolutions.com>
> >>> >> > wrote:
> >>> >> >
> >>> >> >>
> >>> >> >> Guillaume
> >>> >> >>
> >>> >> >> Okay, I'm new to REST so I may be missing something there too
> but
> >>> this
> >>> >> is
> >>> >> >> where I'm at. SMX will receive a JMS message with an XML
> payload.
> >>> The
> >>> >> XML
> >>> >> >> will have two high level nodes. One node's value will be the
> >>> service
> >>> >> to
> >>> >> >> call
> >>> >> >> (will become part of the REST URL). The other node will be a big
> >>> chunk
> >>> >> of
> >>> >> >> XML to be POSTed to the service. The content-type is
> >>> >> >> x-www-form-urlencoded.
> >>> >> >>
> >>> >> >> I extended DefaultHttpProviderMarshaler and I call
> >>> >> >>
> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
> >>> >> >>
> >>> >> >> This almost works. I use JaxenStringXPathExpression to get the
> >>> value
> >>> >> of
> >>> >> >> the
> >>> >> >> first node and set the REST URL. Then my class has a new
> property,
> >>> >> >> contentExpression, also a JaxenStringXPathExpression. I use this
> >>> to
> >>> >> >> define
> >>> >> >> the XPath to the second node, the one with the big chunk of XML,
> >>> but
> >>> >> it
> >>> >> >> adds
> >>> >> >> the values of the second node. What I need is the chunk of XML,
> >>> >> elements,
> >>> >> >> attributes and all.
> >>> >> >>
> >>> >> >> I guess I could introduce a Saxon endpoint to do a
> transformation
> >>> and
> >>> >> a
> >>> >> >> router to send the message to different HTTP endpoints based on
> >>> the
> >>> >> first
> >>> >> >> node but that seems a lot less elegant than just dynamically
> >>> >> determining
> >>> >> >> the
> >>> >> >> REST URL in the marshaler. It works fine for GETs but then POST,
> >>> I'm
> >>> >> >> learning, is a different story.
> >>> >> >>
> >>> >> >> Any thoughts?
> >>> >> >>
> >>> >> >> Thanks
> >>> >> >> Tom
> >>> >> >>
> >>> >> >>
> >>> >> >> gnodet wrote:
> >>> >> >> >
> >>> >> >> > I really think the best way would be to create your own
> >>> marshaler
> >>> if
> >>> >> >> the
> >>> >> >> > default one does not work for you. If you come up with
> >>> something
> >>> >> >> generic
> >>> >> >> > enough feel free to contribute it back. However, the
> >>> >> >> > DefaultHttpProviderMarshaler should send a POST request if the
> >>> input
> >>> >> >> > message
> >>> >> >> > is not null, but this is more like a soap POST rather than a
> >>> form
> >>> >> post
> >>> >> >> > with
> >>> >> >> > key/value pairs. Is that what you'd need ? How do you
> extract
> >>> the
> >>> >> >> > key/value pairs from the exchange ?
> >>> >> >> >
> >>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
> >>> >> >> > <tp...@chariotsolutions.com>
> >>> >> >> > wrote:
> >>> >> >> >
> >>> >> >> >>
> >>> >> >> >> Hello
> >>> >> >> >>
> >>> >> >> >> I'm trying to use the servicemix-http http:provider to call a
> >>> >> RESTful
> >>> >> >> >> service. GET works fine but I'm having trouble trying to
> >>> configure
> >>> >> it
> >>> >> >> to
> >>> >> >> >> do
> >>> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler
> does
> >>> not
> >>> >> >> >> directly
> >>> >> >> >> support this and so I must write my own Marshaler to set the
> >>> >> content.
> >>> >> >> My
> >>> >> >> >> first question is just a request to verify that is correct
> and
> >>> that
> >>> >> >> I'm
> >>> >> >> >> not
> >>> >> >> >> missing something.
> >>> >> >> >>
> >>> >> >> >> My next question is about
> >>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
> >>> >> >> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580
> >
> >>> .
> >>> >> This
> >>> >> >> >> appears to address this situation although I'm not certain it
> >>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears to
> >>> be
> >>> >> >> >> scheduled
> >>> >> >> >> for 3.3 so is this what I would use once 3.3 is released and
> >>> when
> >>> >> is
> >>> >> >> 3.3
> >>> >> >> >> scheduled for release?
> >>> >> >> >>
> >>> >> >> >> Thanks
> >>> >> >> >> Tom
> >>> >> >> >> --
> >>> >> >> >> View this message in context:
> >>> >> >> >>
> >>> >> >>
> >>> >>
> >>>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
> >>> >> >> >> Sent from the ServiceMix - User mailing list archive at
> >>> Nabble.com.
> >>> >> >> >>
> >>> >> >> >>
> >>> >> >> >
> >>> >> >> >
> >>> >> >> > --
> >>> >> >> > Cheers,
> >>> >> >> > Guillaume Nodet
> >>> >> >> > ------------------------
> >>> >> >> > Blog: http://gnodet.blogspot.com/
> >>> >> >> >
> >>> >> >> >
> >>> >> >>
> >>> >> >> --
> >>> >> >> View this message in context:
> >>> >> >>
> >>> >>
> >>>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
> >>> >> >> Sent from the ServiceMix - User mailing list archive at
> >>> Nabble.com.
> >>> >> >>
> >>> >> >>
> >>> >> >
> >>> >> >
> >>> >> > --
> >>> >> > Cheers,
> >>> >> > Guillaume Nodet
> >>> >> > ------------------------
> >>> >> > Blog: http://gnodet.blogspot.com/
> >>> >> >
> >>> >> >
> >>> >>
> >>> >> --
> >>> >> View this message in context:
> >>> >>
> >>>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
> >>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>> >>
> >>> >>
> >>> >
> >>> >
> >>> > --
> >>> > Cheers,
> >>> > Guillaume Nodet
> >>> > ------------------------
> >>> > Blog: http://gnodet.blogspot.com/
> >>> >
> >>> >
> >>>
> >>> --
> >>> View this message in context:
> >>>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
> >>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>>
> >>>
> >>
> >>
> >> --
> >> Cheers,
> >> Guillaume Nodet
> >> ------------------------
> >> Blog: http://gnodet.blogspot.com/
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16469634.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
I've made some progress. This is what I did.
First, I switched to JAXP instead of Jaxen. The ONLY reason for this is I'm
on a corporate network and they will not allow access to any URL with the
"jaxen" in it thus making research difficult. (not your problem, just
venting).
I understood what you were saying about using a SourceTransformer instead of
toString() but the problem is that by the time my getContentToSend() gets
the result of the XPath evaluation it is already a String with the XML tags
stripped out.
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.
I need the NodeSet. Another version of the XPathExpression evaluate method,
evaluate(object, returnType), allows you to control the return type but the
SMX JAXPXPathExpression does not expose a way to call it. I went into the
SMX JAXPXPathExpression class and did the following:
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.
In my new RestProviderMarshaler:
protected String getContentToSend(MessageExchange exchange,
NormalizedMessage inMsg) throws Exception {
String content = null;
if (contentExpression != null) {
logger.debug("*** Evaluate toString: " +
contentExpression.evaluate(exchange, inMsg));
Node node = (Node)contentExpression.evaluate(exchange, inMsg,
XPathConstants.NODE);
content = transformer.toString(new DOMSource(node));
logger.debug("*** Content toString: " + content);
}
if (content == null) {
throw new IllegalStateException("Unable to find Content for
exchange");
}
return content;
}
NOTE:
I have two calls to contentExpression.evaluate() method in
JAXPXPathExpression. The first is just in the debug and is there to
demonstrate the backward compatibility call. This is what it produces in the
log (No XML Tags):
14:21:31,263 - DEBUG - RestProviderMarshaler - *** Evaluate
toString: ServerAsset This is a Test ServerAsset, created from
TestAssetPersistenceTwo. SGNS-0202 true true REDHAT LINUX
testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1 sgns.net OS64 5.0.1 001
2048 2
With the call to the new version (contentExpression.evaluate(exchange,
inMsg, XPathConstants.NODE)) produces this (A nice healthy chunk of XML):
14:21:31,268 - DEBUG - RestProviderMarshaler - *** Content
toString: <?xml version="1.0" encoding="UTF-8"?><asset
name="TestServerAsset1207250490590"> <class_type>ServerAsset</class_type>
<description>This is a Test ServerAsset, created from
TestAssetPersistenceTwo.</description>
<serial_number>SGNS-0202</serial_number> <enabled>true</enabled>
<managed>true</managed> <category
guid="42E213B8-3F31-E288-05A7-7D855CF32329" value="Default"/> <type
guid="30E6FD81-2D8E-B45B-CA53-703ADEDA3BDB" value="Default"/> <state
guid="26BC358E-9F90-FE7F-5199-01DB9FBB72FE" value="Default"/> <mfgName/>
<os>REDHAT LINUX</os>
<host_name>testserverassetc092803e-f2bd-9cb4-1f34-1da6f42053f1</host_name>
<domain_name>sgns.net</domain_name> <platform>OS64</platform>
<os_version>5.0.1</os_version> <os_patch_level>001</os_patch_level>
<memory>2048</memory> <cpus>2</cpus> </asset>
I'm not out of the woods yet. My POST is getting to the webapp and the
webapp is updating the database but things fall apart on the response. I'm
not certain at this point whether its an issue with the wepapp's response or
SMX's handling it or a little of both. I'll let you know what I find out.
On the JAXPXPathExpression code, if there is another approach you think I
should take or you'd like to get the code let me know.
Thanks
Tom
Tom Purcell wrote:
>
> Guillaume
>
> Thabnks for the input. Responses inline
>
> gnodet wrote:
>>
>> Have you tried using the JaxenXPathExpression instead of the
>> JaxenStringXPathExpression ?
>>
>> Yes, I got the same result.
>>
>> Also, I think you need to change the getContentToSend() method because
>> using
>> toString() on the result won't work. Try using the
>> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the DOM
>> node
>> to a String instead.
>>
>> Okay, I'll play with this but the call to contentExpression.evaluate() in
>> getContentToSend() returns a String object. At any rate I'll give it a
>> shot and let you know how it goes.
>>
>> Thanks
>> Tom
>>
>> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
>> <tp...@chariotsolutions.com>
>> wrote:
>>
>>>
>>> Guillaume
>>>
>>> Below is all of what I'm doing. Notice in the logs at the bottom that
>>> what
>>> comes in on the NM is of type DOMSource but the object returned by the
>>> contentExpression.evaluate() method is of type String. I think it want I
>>> want is for that to be a DOMSource too. I also see the "Content is not
>>> allowed in prolog" meesage but I think that is caused by the fact that
>>> my
>>> content is just the values and not the XML.
>>>
>>> Here's the xbean config:
>>>
>>> <http:provider service="wile:wileRestService"
>>> interfaceName="wileCreate"
>>> endpoint="wileRestCreate"
>>> marshaler="#createMarshaler"/>
>>>
>>> <bean id="createMarshaler" class="jbi.marshal.RestProviderMarshaler">
>>> <property name="locationURIExpression">
>>> <bean
>>> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
>>> <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.JaxenStringXPathExpression">
>>> <constructor-arg value="//asset"/>
>>> </bean>
>>> </property>
>>> </bean>
>>> </pre>
>>>
>>> In my RestProviderMarshaler class I added a property for
>>> contentExpression
>>> and replaced the createRequest method. Here are the relevant methods:
>>>
>>> public void createRequest(MessageExchange exchange, NormalizedMessage
>>> inMsg, SmxHttpExchange httpExchange) throws Exception {
>>> logger.debug("*** Before CREATE MessageExchange: " + exchange);
>>> logger.debug("*** NM In Content: " + inMsg.getContent());
>>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
>>> inMsg));
>>>
>>> httpExchange.setURL(getLocationUri(exchange, inMsg));
>>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
>>> ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
>>> httpExchange.setMethod(getMethod(exchange, inMsg));
>>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
>>> getContentType(exchange, inMsg));
>>>
>>> if (getHeaders() != null) {
>>> for (Map.Entry<String, String> e : getHeaders().entrySet()) {
>>> httpExchange.setRequestHeader(e.getKey(), e.getValue());
>>> }
>>> }
>>>
>>> String contentToSend = getContentToSend(exchange, inMsg);
>>> logger.debug("*** Content: " + contentToSend);
>>>
>>> if (contentToSend != null) {
>>> httpExchange.setRequestContent(new
>>> ByteArrayBuffer(contentToSend.getBytes()));
>>> }
>>> }
>>>
>>> protected String getContentToSend(MessageExchange exchange,
>>> NormalizedMessage inMsg) throws Exception {
>>> String content = null;
>>> if (contentExpression != null) {
>>> Object o = contentExpression.evaluate(exchange, inMsg);
>>> logger.debug("*** Content Object Type: " + o.getClass());
>>> content = (o != null) ? o.toString() : null;
>>> }
>>> if (content == null) {
>>> throw new IllegalStateException("Unable to find Content for
>>> exchange");
>>> }
>>> return content;
>>> }
>>>
>>> Here is what I see from the debugs:
>>>
>>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before
>>> CREATE
>>> MessageExchange: InOut[
>>> id: ID:127.0.0.2-11910ec49ca-3:4
>>> status: Active
>>> role: provider
>>> service:
>>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>>> endpoint: wileRestCreate
>>> in: <?xml version="1.0"
>>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This is
>>> a
>>> Test Asset</description> <serial_number>12345</serial_number>
>>> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
>>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>>> </asset> </assetRequest>
>>> ]
>>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
>>> Content:
>>> javax.xml.transform.dom.DOMSource@23cae6
>>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** LocationURI:
>>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
>>> 16:18:59,409<http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409>-
>>> DEBUG - RestProviderMarshaler - *** Content Object
>>> Type: class java.lang.String
>>> 16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
>>> BigAsset This is a Test Asset 12345 true
>>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
>>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
>>> [Fatal Error] :1:1: Content is not allowed in prolog.
>>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
>>> id: ID:127.0.0.2-11910ec49ca-3:4
>>> status: Active
>>> role: provider
>>> service:
>>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>>> endpoint: wileRestCreate
>>> in: <?xml version="1.0"
>>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This is
>>> a
>>> Test Asset</description> <serial_number>12345</serial_number>
>>> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
>>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>>> </asset> </assetRequest>
>>> fault: Unable to display: org.xml.sax.SAXParseException: Content is not
>>> allowed in prolog.
>>> ]
>>> 16:18:59,454 - DEBUG - SedaFlow - Called Flow send
>>>
>>> Thanks
>>> Tom
>>>
>>>
>>> gnodet wrote:
>>> >
>>> > I suppose the creation of the content does not support writing an xml
>>> > element and maybe use toString() or something like that to create the
>>> > content of the request. Could you paste the endpoint definition and
>>> > snippet
>>> > of code, I'm not sure to fully understand your configuration.
>>> > I think if you use a marshaler, you can really do anything you need.
>>> I'm
>>> > sure we could come with something reusable using an expression for the
>>> > URL,
>>> > the method and the content.
>>> >
>>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
>>> > <tp...@chariotsolutions.com>
>>> > wrote:
>>> >
>>> >>
>>> >> Guillaume
>>> >>
>>> >> The message gets sent to the correct URI but the issue is the content
>>> of
>>> >> the
>>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
>>> returned
>>> >> by
>>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent to the
>>> >> RESTful service, is just the values (bar).
>>> >>
>>> >> At this point I guess its really a Jaxen question. Can you get it to
>>> >> return
>>> >> the XML instead of just the values? Otherwise some other parsing
>>> strategy
>>> >> is
>>> >> needed. However, I really liked the idea of just defining an XPath
>>> >> expression on the endpoint. It seems it would make the marshaler
>>> pretty
>>> >> flexible.
>>> >>
>>> >> Thanks
>>> >> Tom
>>> >>
>>> >>
>>> >>
>>> >> gnodet wrote:
>>> >> >
>>> >> > Well, it sounds realy good.
>>> >> > What exactly does not work when using POST with your marshaler ?
>>> >> >
>>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
>>> >> > <tp...@chariotsolutions.com>
>>> >> > wrote:
>>> >> >
>>> >> >>
>>> >> >> Guillaume
>>> >> >>
>>> >> >> Okay, I'm new to REST so I may be missing something there too but
>>> this
>>> >> is
>>> >> >> where I'm at. SMX will receive a JMS message with an XML payload.
>>> The
>>> >> XML
>>> >> >> will have two high level nodes. One node's value will be the
>>> service
>>> >> to
>>> >> >> call
>>> >> >> (will become part of the REST URL). The other node will be a big
>>> chunk
>>> >> of
>>> >> >> XML to be POSTed to the service. The content-type is
>>> >> >> x-www-form-urlencoded.
>>> >> >>
>>> >> >> I extended DefaultHttpProviderMarshaler and I call
>>> >> >> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>>> >> >>
>>> >> >> This almost works. I use JaxenStringXPathExpression to get the
>>> value
>>> >> of
>>> >> >> the
>>> >> >> first node and set the REST URL. Then my class has a new property,
>>> >> >> contentExpression, also a JaxenStringXPathExpression. I use this
>>> to
>>> >> >> define
>>> >> >> the XPath to the second node, the one with the big chunk of XML,
>>> but
>>> >> it
>>> >> >> adds
>>> >> >> the values of the second node. What I need is the chunk of XML,
>>> >> elements,
>>> >> >> attributes and all.
>>> >> >>
>>> >> >> I guess I could introduce a Saxon endpoint to do a transformation
>>> and
>>> >> a
>>> >> >> router to send the message to different HTTP endpoints based on
>>> the
>>> >> first
>>> >> >> node but that seems a lot less elegant than just dynamically
>>> >> determining
>>> >> >> the
>>> >> >> REST URL in the marshaler. It works fine for GETs but then POST,
>>> I'm
>>> >> >> learning, is a different story.
>>> >> >>
>>> >> >> Any thoughts?
>>> >> >>
>>> >> >> Thanks
>>> >> >> Tom
>>> >> >>
>>> >> >>
>>> >> >> gnodet wrote:
>>> >> >> >
>>> >> >> > I really think the best way would be to create your own
>>> marshaler
>>> if
>>> >> >> the
>>> >> >> > default one does not work for you. If you come up with
>>> something
>>> >> >> generic
>>> >> >> > enough feel free to contribute it back. However, the
>>> >> >> > DefaultHttpProviderMarshaler should send a POST request if the
>>> input
>>> >> >> > message
>>> >> >> > is not null, but this is more like a soap POST rather than a
>>> form
>>> >> post
>>> >> >> > with
>>> >> >> > key/value pairs. Is that what you'd need ? How do you extract
>>> the
>>> >> >> > key/value pairs from the exchange ?
>>> >> >> >
>>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
>>> >> >> > <tp...@chariotsolutions.com>
>>> >> >> > wrote:
>>> >> >> >
>>> >> >> >>
>>> >> >> >> Hello
>>> >> >> >>
>>> >> >> >> I'm trying to use the servicemix-http http:provider to call a
>>> >> RESTful
>>> >> >> >> service. GET works fine but I'm having trouble trying to
>>> configure
>>> >> it
>>> >> >> to
>>> >> >> >> do
>>> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler does
>>> not
>>> >> >> >> directly
>>> >> >> >> support this and so I must write my own Marshaler to set the
>>> >> content.
>>> >> >> My
>>> >> >> >> first question is just a request to verify that is correct and
>>> that
>>> >> >> I'm
>>> >> >> >> not
>>> >> >> >> missing something.
>>> >> >> >>
>>> >> >> >> My next question is about
>>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
>>> >> >> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580>
>>> .
>>> >> This
>>> >> >> >> appears to address this situation although I'm not certain it
>>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears to
>>> be
>>> >> >> >> scheduled
>>> >> >> >> for 3.3 so is this what I would use once 3.3 is released and
>>> when
>>> >> is
>>> >> >> 3.3
>>> >> >> >> scheduled for release?
>>> >> >> >>
>>> >> >> >> Thanks
>>> >> >> >> Tom
>>> >> >> >> --
>>> >> >> >> View this message in context:
>>> >> >> >>
>>> >> >>
>>> >>
>>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>>> >> >> >> Sent from the ServiceMix - User mailing list archive at
>>> Nabble.com.
>>> >> >> >>
>>> >> >> >>
>>> >> >> >
>>> >> >> >
>>> >> >> > --
>>> >> >> > Cheers,
>>> >> >> > Guillaume Nodet
>>> >> >> > ------------------------
>>> >> >> > Blog: http://gnodet.blogspot.com/
>>> >> >> >
>>> >> >> >
>>> >> >>
>>> >> >> --
>>> >> >> View this message in context:
>>> >> >>
>>> >>
>>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
>>> >> >> Sent from the ServiceMix - User mailing list archive at
>>> Nabble.com.
>>> >> >>
>>> >> >>
>>> >> >
>>> >> >
>>> >> > --
>>> >> > Cheers,
>>> >> > Guillaume Nodet
>>> >> > ------------------------
>>> >> > Blog: http://gnodet.blogspot.com/
>>> >> >
>>> >> >
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
>>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> > Cheers,
>>> > Guillaume Nodet
>>> > ------------------------
>>> > Blog: http://gnodet.blogspot.com/
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>>
>>
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16469634.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
Thabnks for the input. Responses inline
gnodet wrote:
>
> Have you tried using the JaxenXPathExpression instead of the
> JaxenStringXPathExpression ?
>
> Yes, I got the same result.
>
> Also, I think you need to change the getContentToSend() method because
> using
> toString() on the result won't work. Try using the
> org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the DOM node
> to a String instead.
>
> Okay, I'll play with this but the call to contentExpression.evaluate() in
> getContentToSend() returns a String object. At any rate I'll give it a
> shot and let you know how it goes.
>
> Thanks
> Tom
>
> On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>> Guillaume
>>
>> Below is all of what I'm doing. Notice in the logs at the bottom that
>> what
>> comes in on the NM is of type DOMSource but the object returned by the
>> contentExpression.evaluate() method is of type String. I think it want I
>> want is for that to be a DOMSource too. I also see the "Content is not
>> allowed in prolog" meesage but I think that is caused by the fact that my
>> content is just the values and not the XML.
>>
>> Here's the xbean config:
>>
>> <http:provider service="wile:wileRestService"
>> interfaceName="wileCreate"
>> endpoint="wileRestCreate"
>> marshaler="#createMarshaler"/>
>>
>> <bean id="createMarshaler" class="jbi.marshal.RestProviderMarshaler">
>> <property name="locationURIExpression">
>> <bean
>> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
>> <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.JaxenStringXPathExpression">
>> <constructor-arg value="//asset"/>
>> </bean>
>> </property>
>> </bean>
>> </pre>
>>
>> In my RestProviderMarshaler class I added a property for
>> contentExpression
>> and replaced the createRequest method. Here are the relevant methods:
>>
>> public void createRequest(MessageExchange exchange, NormalizedMessage
>> inMsg, SmxHttpExchange httpExchange) throws Exception {
>> logger.debug("*** Before CREATE MessageExchange: " + exchange);
>> logger.debug("*** NM In Content: " + inMsg.getContent());
>> logger.debug("*** LocationURI: " + getLocationUri(exchange,
>> inMsg));
>>
>> httpExchange.setURL(getLocationUri(exchange, inMsg));
>> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
>> ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
>> httpExchange.setMethod(getMethod(exchange, inMsg));
>> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
>> getContentType(exchange, inMsg));
>>
>> if (getHeaders() != null) {
>> for (Map.Entry<String, String> e : getHeaders().entrySet()) {
>> httpExchange.setRequestHeader(e.getKey(), e.getValue());
>> }
>> }
>>
>> String contentToSend = getContentToSend(exchange, inMsg);
>> logger.debug("*** Content: " + contentToSend);
>>
>> if (contentToSend != null) {
>> httpExchange.setRequestContent(new
>> ByteArrayBuffer(contentToSend.getBytes()));
>> }
>> }
>>
>> protected String getContentToSend(MessageExchange exchange,
>> NormalizedMessage inMsg) throws Exception {
>> String content = null;
>> if (contentExpression != null) {
>> Object o = contentExpression.evaluate(exchange, inMsg);
>> logger.debug("*** Content Object Type: " + o.getClass());
>> content = (o != null) ? o.toString() : null;
>> }
>> if (content == null) {
>> throw new IllegalStateException("Unable to find Content for
>> exchange");
>> }
>> return content;
>> }
>>
>> Here is what I see from the debugs:
>>
>> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before CREATE
>> MessageExchange: InOut[
>> id: ID:127.0.0.2-11910ec49ca-3:4
>> status: Active
>> role: provider
>> service:
>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>> endpoint: wileRestCreate
>> in: <?xml version="1.0"
>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This is
>> a
>> Test Asset</description> <serial_number>12345</serial_number>
>> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>> </asset> </assetRequest>
>> ]
>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In
>> Content:
>> javax.xml.transform.dom.DOMSource@23cae6
>> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** LocationURI:
>> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
>> 16:18:59,409<http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409>-
>> DEBUG - RestProviderMarshaler - *** Content Object
>> Type: class java.lang.String
>> 16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
>> BigAsset This is a Test Asset 12345 true
>> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
>> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
>> [Fatal Error] :1:1: Content is not allowed in prolog.
>> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
>> id: ID:127.0.0.2-11910ec49ca-3:4
>> status: Active
>> role: provider
>> service:
>> {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
>> endpoint: wileRestCreate
>> in: <?xml version="1.0"
>> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
>> name="TestAsset"> <class_type>BigAsset</class_type> <description>This is
>> a
>> Test Asset</description> <serial_number>12345</serial_number>
>> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
>> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
>> </asset> </assetRequest>
>> fault: Unable to display: org.xml.sax.SAXParseException: Content is not
>> allowed in prolog.
>> ]
>> 16:18:59,454 - DEBUG - SedaFlow - Called Flow send
>>
>> Thanks
>> Tom
>>
>>
>> gnodet wrote:
>> >
>> > I suppose the creation of the content does not support writing an xml
>> > element and maybe use toString() or something like that to create the
>> > content of the request. Could you paste the endpoint definition and
>> > snippet
>> > of code, I'm not sure to fully understand your configuration.
>> > I think if you use a marshaler, you can really do anything you need.
>> I'm
>> > sure we could come with something reusable using an expression for the
>> > URL,
>> > the method and the content.
>> >
>> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
>> > <tp...@chariotsolutions.com>
>> > wrote:
>> >
>> >>
>> >> Guillaume
>> >>
>> >> The message gets sent to the correct URI but the issue is the content
>> of
>> >> the
>> >> message. I need to send the XML (<foo>bar</foo>) but what gets
>> returned
>> >> by
>> >> contentExpression.evaluate(exchange, inMsg), subsequently sent to the
>> >> RESTful service, is just the values (bar).
>> >>
>> >> At this point I guess its really a Jaxen question. Can you get it to
>> >> return
>> >> the XML instead of just the values? Otherwise some other parsing
>> strategy
>> >> is
>> >> needed. However, I really liked the idea of just defining an XPath
>> >> expression on the endpoint. It seems it would make the marshaler
>> pretty
>> >> flexible.
>> >>
>> >> Thanks
>> >> Tom
>> >>
>> >>
>> >>
>> >> gnodet wrote:
>> >> >
>> >> > Well, it sounds realy good.
>> >> > What exactly does not work when using POST with your marshaler ?
>> >> >
>> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
>> >> > <tp...@chariotsolutions.com>
>> >> > wrote:
>> >> >
>> >> >>
>> >> >> Guillaume
>> >> >>
>> >> >> Okay, I'm new to REST so I may be missing something there too but
>> this
>> >> is
>> >> >> where I'm at. SMX will receive a JMS message with an XML payload.
>> The
>> >> XML
>> >> >> will have two high level nodes. One node's value will be the
>> service
>> >> to
>> >> >> call
>> >> >> (will become part of the REST URL). The other node will be a big
>> chunk
>> >> of
>> >> >> XML to be POSTed to the service. The content-type is
>> >> >> x-www-form-urlencoded.
>> >> >>
>> >> >> I extended DefaultHttpProviderMarshaler and I call
>> >> >> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>> >> >>
>> >> >> This almost works. I use JaxenStringXPathExpression to get the
>> value
>> >> of
>> >> >> the
>> >> >> first node and set the REST URL. Then my class has a new property,
>> >> >> contentExpression, also a JaxenStringXPathExpression. I use this to
>> >> >> define
>> >> >> the XPath to the second node, the one with the big chunk of XML,
>> but
>> >> it
>> >> >> adds
>> >> >> the values of the second node. What I need is the chunk of XML,
>> >> elements,
>> >> >> attributes and all.
>> >> >>
>> >> >> I guess I could introduce a Saxon endpoint to do a transformation
>> and
>> >> a
>> >> >> router to send the message to different HTTP endpoints based on the
>> >> first
>> >> >> node but that seems a lot less elegant than just dynamically
>> >> determining
>> >> >> the
>> >> >> REST URL in the marshaler. It works fine for GETs but then POST,
>> I'm
>> >> >> learning, is a different story.
>> >> >>
>> >> >> Any thoughts?
>> >> >>
>> >> >> Thanks
>> >> >> Tom
>> >> >>
>> >> >>
>> >> >> gnodet wrote:
>> >> >> >
>> >> >> > I really think the best way would be to create your own marshaler
>> if
>> >> >> the
>> >> >> > default one does not work for you. If you come up with something
>> >> >> generic
>> >> >> > enough feel free to contribute it back. However, the
>> >> >> > DefaultHttpProviderMarshaler should send a POST request if the
>> input
>> >> >> > message
>> >> >> > is not null, but this is more like a soap POST rather than a form
>> >> post
>> >> >> > with
>> >> >> > key/value pairs. Is that what you'd need ? How do you extract
>> the
>> >> >> > key/value pairs from the exchange ?
>> >> >> >
>> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
>> >> >> > <tp...@chariotsolutions.com>
>> >> >> > wrote:
>> >> >> >
>> >> >> >>
>> >> >> >> Hello
>> >> >> >>
>> >> >> >> I'm trying to use the servicemix-http http:provider to call a
>> >> RESTful
>> >> >> >> service. GET works fine but I'm having trouble trying to
>> configure
>> >> it
>> >> >> to
>> >> >> >> do
>> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler does
>> not
>> >> >> >> directly
>> >> >> >> support this and so I must write my own Marshaler to set the
>> >> content.
>> >> >> My
>> >> >> >> first question is just a request to verify that is correct and
>> that
>> >> >> I'm
>> >> >> >> not
>> >> >> >> missing something.
>> >> >> >>
>> >> >> >> My next question is about
>> >> >> >> http://issues.apache.org/activemq/browse/SM-580
>> >> >> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580> .
>> >> This
>> >> >> >> appears to address this situation although I'm not certain it
>> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears to be
>> >> >> >> scheduled
>> >> >> >> for 3.3 so is this what I would use once 3.3 is released and
>> when
>> >> is
>> >> >> 3.3
>> >> >> >> scheduled for release?
>> >> >> >>
>> >> >> >> Thanks
>> >> >> >> Tom
>> >> >> >> --
>> >> >> >> View this message in context:
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>> >> >> >> Sent from the ServiceMix - User mailing list archive at
>> Nabble.com.
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Cheers,
>> >> >> > Guillaume Nodet
>> >> >> > ------------------------
>> >> >> > Blog: http://gnodet.blogspot.com/
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
>> >> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Cheers,
>> >> > Guillaume Nodet
>> >> > ------------------------
>> >> > Blog: http://gnodet.blogspot.com/
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16467425.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
Have you tried using the JaxenXPathExpression instead of the
JaxenStringXPathExpression ?
Also, I think you need to change the getContentToSend() method because using
toString() on the result won't work. Try using the
org.apache.servicemix.jbi.jaxp.*SourceTransformer* to convert the DOM node
to a String instead.
On Wed, Apr 2, 2008 at 11:27 PM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
>
> Below is all of what I'm doing. Notice in the logs at the bottom that what
> comes in on the NM is of type DOMSource but the object returned by the
> contentExpression.evaluate() method is of type String. I think it want I
> want is for that to be a DOMSource too. I also see the "Content is not
> allowed in prolog" meesage but I think that is caused by the fact that my
> content is just the values and not the XML.
>
> Here's the xbean config:
>
> <http:provider service="wile:wileRestService"
> interfaceName="wileCreate"
> endpoint="wileRestCreate"
> marshaler="#createMarshaler"/>
>
> <bean id="createMarshaler" class="jbi.marshal.RestProviderMarshaler">
> <property name="locationURIExpression">
> <bean
> class="org.apache.servicemix.expression.JaxenStringXPathExpression">
> <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.JaxenStringXPathExpression">
> <constructor-arg value="//asset"/>
> </bean>
> </property>
> </bean>
> </pre>
>
> In my RestProviderMarshaler class I added a property for contentExpression
> and replaced the createRequest method. Here are the relevant methods:
>
> public void createRequest(MessageExchange exchange, NormalizedMessage
> inMsg, SmxHttpExchange httpExchange) throws Exception {
> logger.debug("*** Before CREATE MessageExchange: " + exchange);
> logger.debug("*** NM In Content: " + inMsg.getContent());
> logger.debug("*** LocationURI: " + getLocationUri(exchange,
> inMsg));
>
> httpExchange.setURL(getLocationUri(exchange, inMsg));
> httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
> ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
> httpExchange.setMethod(getMethod(exchange, inMsg));
> httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
> getContentType(exchange, inMsg));
>
> if (getHeaders() != null) {
> for (Map.Entry<String, String> e : getHeaders().entrySet()) {
> httpExchange.setRequestHeader(e.getKey(), e.getValue());
> }
> }
>
> String contentToSend = getContentToSend(exchange, inMsg);
> logger.debug("*** Content: " + contentToSend);
>
> if (contentToSend != null) {
> httpExchange.setRequestContent(new
> ByteArrayBuffer(contentToSend.getBytes()));
> }
> }
>
> protected String getContentToSend(MessageExchange exchange,
> NormalizedMessage inMsg) throws Exception {
> String content = null;
> if (contentExpression != null) {
> Object o = contentExpression.evaluate(exchange, inMsg);
> logger.debug("*** Content Object Type: " + o.getClass());
> content = (o != null) ? o.toString() : null;
> }
> if (content == null) {
> throw new IllegalStateException("Unable to find Content for
> exchange");
> }
> return content;
> }
>
> Here is what I see from the debugs:
>
> 16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before CREATE
> MessageExchange: InOut[
> id: ID:127.0.0.2-11910ec49ca-3:4
> status: Active
> role: provider
> service: {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> endpoint: wileRestCreate
> in: <?xml version="1.0"
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> name="TestAsset"> <class_type>BigAsset</class_type> <description>This is a
> Test Asset</description> <serial_number>12345</serial_number>
> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
> </asset> </assetRequest>
> ]
> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In Content:
> javax.xml.transform.dom.DOMSource@23cae6
> 16:18:59,408 - DEBUG - RestProviderMarshaler - *** LocationURI:
> http://localhost:8080/wile-www/assetmanagement/assetservice/asset
> 16:18:59,409<http://localhost:8080/wile-www/assetmanagement/assetservice/asset16:18:59,409>- DEBUG - RestProviderMarshaler - *** Content Object
> Type: class java.lang.String
> 16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
> BigAsset This is a Test Asset 12345 true
> 16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
> ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
> [Fatal Error] :1:1: Content is not allowed in prolog.
> 16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
> id: ID:127.0.0.2-11910ec49ca-3:4
> status: Active
> role: provider
> service: {http://www.sungard.com/wile}wileRestService<http://www.sungard.com/wile%7DwileRestService>
> endpoint: wileRestCreate
> in: <?xml version="1.0"
> encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
> name="TestAsset"> <class_type>BigAsset</class_type> <description>This is a
> Test Asset</description> <serial_number>12345</serial_number>
> <enabled>true</enabled> <category guid="67890" value="Default"/> <type
> guid="09876" value="Default"/> <state guid="54321" value="Default"/>
> </asset> </assetRequest>
> fault: Unable to display: org.xml.sax.SAXParseException: Content is not
> allowed in prolog.
> ]
> 16:18:59,454 - DEBUG - SedaFlow - Called Flow send
>
> Thanks
> Tom
>
>
> gnodet wrote:
> >
> > I suppose the creation of the content does not support writing an xml
> > element and maybe use toString() or something like that to create the
> > content of the request. Could you paste the endpoint definition and
> > snippet
> > of code, I'm not sure to fully understand your configuration.
> > I think if you use a marshaler, you can really do anything you need. I'm
> > sure we could come with something reusable using an expression for the
> > URL,
> > the method and the content.
> >
> > On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
> > <tp...@chariotsolutions.com>
> > wrote:
> >
> >>
> >> Guillaume
> >>
> >> The message gets sent to the correct URI but the issue is the content
> of
> >> the
> >> message. I need to send the XML (<foo>bar</foo>) but what gets returned
> >> by
> >> contentExpression.evaluate(exchange, inMsg), subsequently sent to the
> >> RESTful service, is just the values (bar).
> >>
> >> At this point I guess its really a Jaxen question. Can you get it to
> >> return
> >> the XML instead of just the values? Otherwise some other parsing
> strategy
> >> is
> >> needed. However, I really liked the idea of just defining an XPath
> >> expression on the endpoint. It seems it would make the marshaler pretty
> >> flexible.
> >>
> >> Thanks
> >> Tom
> >>
> >>
> >>
> >> gnodet wrote:
> >> >
> >> > Well, it sounds realy good.
> >> > What exactly does not work when using POST with your marshaler ?
> >> >
> >> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
> >> > <tp...@chariotsolutions.com>
> >> > wrote:
> >> >
> >> >>
> >> >> Guillaume
> >> >>
> >> >> Okay, I'm new to REST so I may be missing something there too but
> this
> >> is
> >> >> where I'm at. SMX will receive a JMS message with an XML payload.
> The
> >> XML
> >> >> will have two high level nodes. One node's value will be the service
> >> to
> >> >> call
> >> >> (will become part of the REST URL). The other node will be a big
> chunk
> >> of
> >> >> XML to be POSTed to the service. The content-type is
> >> >> x-www-form-urlencoded.
> >> >>
> >> >> I extended DefaultHttpProviderMarshaler and I call
> >> >> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
> >> >>
> >> >> This almost works. I use JaxenStringXPathExpression to get the value
> >> of
> >> >> the
> >> >> first node and set the REST URL. Then my class has a new property,
> >> >> contentExpression, also a JaxenStringXPathExpression. I use this to
> >> >> define
> >> >> the XPath to the second node, the one with the big chunk of XML, but
> >> it
> >> >> adds
> >> >> the values of the second node. What I need is the chunk of XML,
> >> elements,
> >> >> attributes and all.
> >> >>
> >> >> I guess I could introduce a Saxon endpoint to do a transformation
> and
> >> a
> >> >> router to send the message to different HTTP endpoints based on the
> >> first
> >> >> node but that seems a lot less elegant than just dynamically
> >> determining
> >> >> the
> >> >> REST URL in the marshaler. It works fine for GETs but then POST, I'm
> >> >> learning, is a different story.
> >> >>
> >> >> Any thoughts?
> >> >>
> >> >> Thanks
> >> >> Tom
> >> >>
> >> >>
> >> >> gnodet wrote:
> >> >> >
> >> >> > I really think the best way would be to create your own marshaler
> if
> >> >> the
> >> >> > default one does not work for you. If you come up with something
> >> >> generic
> >> >> > enough feel free to contribute it back. However, the
> >> >> > DefaultHttpProviderMarshaler should send a POST request if the
> input
> >> >> > message
> >> >> > is not null, but this is more like a soap POST rather than a form
> >> post
> >> >> > with
> >> >> > key/value pairs. Is that what you'd need ? How do you extract
> the
> >> >> > key/value pairs from the exchange ?
> >> >> >
> >> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
> >> >> > <tp...@chariotsolutions.com>
> >> >> > wrote:
> >> >> >
> >> >> >>
> >> >> >> Hello
> >> >> >>
> >> >> >> I'm trying to use the servicemix-http http:provider to call a
> >> RESTful
> >> >> >> service. GET works fine but I'm having trouble trying to
> configure
> >> it
> >> >> to
> >> >> >> do
> >> >> >> a post. It appears to me that DefaultHttpProviderMarshaler does
> not
> >> >> >> directly
> >> >> >> support this and so I must write my own Marshaler to set the
> >> content.
> >> >> My
> >> >> >> first question is just a request to verify that is correct and
> that
> >> >> I'm
> >> >> >> not
> >> >> >> missing something.
> >> >> >>
> >> >> >> My next question is about
> >> >> >> http://issues.apache.org/activemq/browse/SM-580
> >> >> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580> .
> >> This
> >> >> >> appears to address this situation although I'm not certain it
> >> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears to be
> >> >> >> scheduled
> >> >> >> for 3.3 so is this what I would use once 3.3 is released and when
> >> is
> >> >> 3.3
> >> >> >> scheduled for release?
> >> >> >>
> >> >> >> Thanks
> >> >> >> Tom
> >> >> >> --
> >> >> >> View this message in context:
> >> >> >>
> >> >>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
> >> >> >> Sent from the ServiceMix - User mailing list archive at
> Nabble.com.
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Cheers,
> >> >> > Guillaume Nodet
> >> >> > ------------------------
> >> >> > Blog: http://gnodet.blogspot.com/
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
> >> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Cheers,
> >> > Guillaume Nodet
> >> > ------------------------
> >> > Blog: http://gnodet.blogspot.com/
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
Below is all of what I'm doing. Notice in the logs at the bottom that what
comes in on the NM is of type DOMSource but the object returned by the
contentExpression.evaluate() method is of type String. I think it want I
want is for that to be a DOMSource too. I also see the "Content is not
allowed in prolog" meesage but I think that is caused by the fact that my
content is just the values and not the XML.
Here's the xbean config:
<http:provider service="wile:wileRestService"
interfaceName="wileCreate"
endpoint="wileRestCreate"
marshaler="#createMarshaler"/>
<bean id="createMarshaler" class="jbi.marshal.RestProviderMarshaler">
<property name="locationURIExpression">
<bean
class="org.apache.servicemix.expression.JaxenStringXPathExpression">
<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.JaxenStringXPathExpression">
<constructor-arg value="//asset"/>
</bean>
</property>
</bean>
</pre>
In my RestProviderMarshaler class I added a property for contentExpression
and replaced the createRequest method. Here are the relevant methods:
public void createRequest(MessageExchange exchange, NormalizedMessage
inMsg, SmxHttpExchange httpExchange) throws Exception {
logger.debug("*** Before CREATE MessageExchange: " + exchange);
logger.debug("*** NM In Content: " + inMsg.getContent());
logger.debug("*** LocationURI: " + getLocationUri(exchange, inMsg));
httpExchange.setURL(getLocationUri(exchange, inMsg));
httpExchange.addRequestHeader(HttpHeaders.HOST_BUFFER, new
ByteArrayBuffer(new URI(getLocationUri(exchange, inMsg)).getHost()));
httpExchange.setMethod(getMethod(exchange, inMsg));
httpExchange.setRequestHeader(HttpHeaders.CONTENT_TYPE,
getContentType(exchange, inMsg));
if (getHeaders() != null) {
for (Map.Entry<String, String> e : getHeaders().entrySet()) {
httpExchange.setRequestHeader(e.getKey(), e.getValue());
}
}
String contentToSend = getContentToSend(exchange, inMsg);
logger.debug("*** Content: " + contentToSend);
if (contentToSend != null) {
httpExchange.setRequestContent(new
ByteArrayBuffer(contentToSend.getBytes()));
}
}
protected String getContentToSend(MessageExchange exchange,
NormalizedMessage inMsg) throws Exception {
String content = null;
if (contentExpression != null) {
Object o = contentExpression.evaluate(exchange, inMsg);
logger.debug("*** Content Object Type: " + o.getClass());
content = (o != null) ? o.toString() : null;
}
if (content == null) {
throw new IllegalStateException("Unable to find Content for
exchange");
}
return content;
}
Here is what I see from the debugs:
16:18:59,407 - DEBUG - RestProviderMarshaler - *** Before CREATE
MessageExchange: InOut[
id: ID:127.0.0.2-11910ec49ca-3:4
status: Active
role: provider
service: {http://www.sungard.com/wile}wileRestService
endpoint: wileRestCreate
in: <?xml version="1.0"
encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
name="TestAsset"> <class_type>BigAsset</class_type> <description>This is a
Test Asset</description> <serial_number>12345</serial_number>
<enabled>true</enabled> <category guid="67890" value="Default"/> <type
guid="09876" value="Default"/> <state guid="54321" value="Default"/>
</asset> </assetRequest>
]
16:18:59,408 - DEBUG - RestProviderMarshaler - *** NM In Content:
javax.xml.transform.dom.DOMSource@23cae6
16:18:59,408 - DEBUG - RestProviderMarshaler - *** LocationURI:
http://localhost:8080/wile-www/assetmanagement/assetservice/asset
16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content Object
Type: class java.lang.String
16:18:59,409 - DEBUG - RestProviderMarshaler - *** Content:
BigAsset This is a Test Asset 12345 true
16:18:59,446 - DEBUG - DeliveryChannelImpl - Send
ID:127.0.0.2-11910ec49ca-3:4 in DeliveryChannel{servicemix-http}
[Fatal Error] :1:1: Content is not allowed in prolog.
16:18:59,451 - TRACE - DeliveryChannelImpl - Sent: InOut[
id: ID:127.0.0.2-11910ec49ca-3:4
status: Active
role: provider
service: {http://www.sungard.com/wile}wileRestService
endpoint: wileRestCreate
in: <?xml version="1.0"
encoding="UTF-8"?><assetRequest><perspective>asset</perspective><asset
name="TestAsset"> <class_type>BigAsset</class_type> <description>This is a
Test Asset</description> <serial_number>12345</serial_number>
<enabled>true</enabled> <category guid="67890" value="Default"/> <type
guid="09876" value="Default"/> <state guid="54321" value="Default"/>
</asset> </assetRequest>
fault: Unable to display: org.xml.sax.SAXParseException: Content is not
allowed in prolog.
]
16:18:59,454 - DEBUG - SedaFlow - Called Flow send
Thanks
Tom
gnodet wrote:
>
> I suppose the creation of the content does not support writing an xml
> element and maybe use toString() or something like that to create the
> content of the request. Could you paste the endpoint definition and
> snippet
> of code, I'm not sure to fully understand your configuration.
> I think if you use a marshaler, you can really do anything you need. I'm
> sure we could come with something reusable using an expression for the
> URL,
> the method and the content.
>
> On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>> Guillaume
>>
>> The message gets sent to the correct URI but the issue is the content of
>> the
>> message. I need to send the XML (<foo>bar</foo>) but what gets returned
>> by
>> contentExpression.evaluate(exchange, inMsg), subsequently sent to the
>> RESTful service, is just the values (bar).
>>
>> At this point I guess its really a Jaxen question. Can you get it to
>> return
>> the XML instead of just the values? Otherwise some other parsing strategy
>> is
>> needed. However, I really liked the idea of just defining an XPath
>> expression on the endpoint. It seems it would make the marshaler pretty
>> flexible.
>>
>> Thanks
>> Tom
>>
>>
>>
>> gnodet wrote:
>> >
>> > Well, it sounds realy good.
>> > What exactly does not work when using POST with your marshaler ?
>> >
>> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
>> > <tp...@chariotsolutions.com>
>> > wrote:
>> >
>> >>
>> >> Guillaume
>> >>
>> >> Okay, I'm new to REST so I may be missing something there too but this
>> is
>> >> where I'm at. SMX will receive a JMS message with an XML payload. The
>> XML
>> >> will have two high level nodes. One node's value will be the service
>> to
>> >> call
>> >> (will become part of the REST URL). The other node will be a big chunk
>> of
>> >> XML to be POSTed to the service. The content-type is
>> >> x-www-form-urlencoded.
>> >>
>> >> I extended DefaultHttpProviderMarshaler and I call
>> >> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>> >>
>> >> This almost works. I use JaxenStringXPathExpression to get the value
>> of
>> >> the
>> >> first node and set the REST URL. Then my class has a new property,
>> >> contentExpression, also a JaxenStringXPathExpression. I use this to
>> >> define
>> >> the XPath to the second node, the one with the big chunk of XML, but
>> it
>> >> adds
>> >> the values of the second node. What I need is the chunk of XML,
>> elements,
>> >> attributes and all.
>> >>
>> >> I guess I could introduce a Saxon endpoint to do a transformation and
>> a
>> >> router to send the message to different HTTP endpoints based on the
>> first
>> >> node but that seems a lot less elegant than just dynamically
>> determining
>> >> the
>> >> REST URL in the marshaler. It works fine for GETs but then POST, I'm
>> >> learning, is a different story.
>> >>
>> >> Any thoughts?
>> >>
>> >> Thanks
>> >> Tom
>> >>
>> >>
>> >> gnodet wrote:
>> >> >
>> >> > I really think the best way would be to create your own marshaler if
>> >> the
>> >> > default one does not work for you. If you come up with something
>> >> generic
>> >> > enough feel free to contribute it back. However, the
>> >> > DefaultHttpProviderMarshaler should send a POST request if the input
>> >> > message
>> >> > is not null, but this is more like a soap POST rather than a form
>> post
>> >> > with
>> >> > key/value pairs. Is that what you'd need ? How do you extract the
>> >> > key/value pairs from the exchange ?
>> >> >
>> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
>> >> > <tp...@chariotsolutions.com>
>> >> > wrote:
>> >> >
>> >> >>
>> >> >> Hello
>> >> >>
>> >> >> I'm trying to use the servicemix-http http:provider to call a
>> RESTful
>> >> >> service. GET works fine but I'm having trouble trying to configure
>> it
>> >> to
>> >> >> do
>> >> >> a post. It appears to me that DefaultHttpProviderMarshaler does not
>> >> >> directly
>> >> >> support this and so I must write my own Marshaler to set the
>> content.
>> >> My
>> >> >> first question is just a request to verify that is correct and that
>> >> I'm
>> >> >> not
>> >> >> missing something.
>> >> >>
>> >> >> My next question is about
>> >> >> http://issues.apache.org/activemq/browse/SM-580
>> >> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580> .
>> This
>> >> >> appears to address this situation although I'm not certain it
>> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears to be
>> >> >> scheduled
>> >> >> for 3.3 so is this what I would use once 3.3 is released and when
>> is
>> >> 3.3
>> >> >> scheduled for release?
>> >> >>
>> >> >> Thanks
>> >> >> Tom
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>> >> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Cheers,
>> >> > Guillaume Nodet
>> >> > ------------------------
>> >> > Blog: http://gnodet.blogspot.com/
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16452156.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
I suppose the creation of the content does not support writing an xml
element and maybe use toString() or something like that to create the
content of the request. Could you paste the endpoint definition and snippet
of code, I'm not sure to fully understand your configuration.
I think if you use a marshaler, you can really do anything you need. I'm
sure we could come with something reusable using an expression for the URL,
the method and the content.
On Wed, Apr 2, 2008 at 2:33 PM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
>
> The message gets sent to the correct URI but the issue is the content of
> the
> message. I need to send the XML (<foo>bar</foo>) but what gets returned by
> contentExpression.evaluate(exchange, inMsg), subsequently sent to the
> RESTful service, is just the values (bar).
>
> At this point I guess its really a Jaxen question. Can you get it to
> return
> the XML instead of just the values? Otherwise some other parsing strategy
> is
> needed. However, I really liked the idea of just defining an XPath
> expression on the endpoint. It seems it would make the marshaler pretty
> flexible.
>
> Thanks
> Tom
>
>
>
> gnodet wrote:
> >
> > Well, it sounds realy good.
> > What exactly does not work when using POST with your marshaler ?
> >
> > On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
> > <tp...@chariotsolutions.com>
> > wrote:
> >
> >>
> >> Guillaume
> >>
> >> Okay, I'm new to REST so I may be missing something there too but this
> is
> >> where I'm at. SMX will receive a JMS message with an XML payload. The
> XML
> >> will have two high level nodes. One node's value will be the service to
> >> call
> >> (will become part of the REST URL). The other node will be a big chunk
> of
> >> XML to be POSTed to the service. The content-type is
> >> x-www-form-urlencoded.
> >>
> >> I extended DefaultHttpProviderMarshaler and I call
> >> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
> >>
> >> This almost works. I use JaxenStringXPathExpression to get the value of
> >> the
> >> first node and set the REST URL. Then my class has a new property,
> >> contentExpression, also a JaxenStringXPathExpression. I use this to
> >> define
> >> the XPath to the second node, the one with the big chunk of XML, but it
> >> adds
> >> the values of the second node. What I need is the chunk of XML,
> elements,
> >> attributes and all.
> >>
> >> I guess I could introduce a Saxon endpoint to do a transformation and a
> >> router to send the message to different HTTP endpoints based on the
> first
> >> node but that seems a lot less elegant than just dynamically
> determining
> >> the
> >> REST URL in the marshaler. It works fine for GETs but then POST, I'm
> >> learning, is a different story.
> >>
> >> Any thoughts?
> >>
> >> Thanks
> >> Tom
> >>
> >>
> >> gnodet wrote:
> >> >
> >> > I really think the best way would be to create your own marshaler if
> >> the
> >> > default one does not work for you. If you come up with something
> >> generic
> >> > enough feel free to contribute it back. However, the
> >> > DefaultHttpProviderMarshaler should send a POST request if the input
> >> > message
> >> > is not null, but this is more like a soap POST rather than a form
> post
> >> > with
> >> > key/value pairs. Is that what you'd need ? How do you extract the
> >> > key/value pairs from the exchange ?
> >> >
> >> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
> >> > <tp...@chariotsolutions.com>
> >> > wrote:
> >> >
> >> >>
> >> >> Hello
> >> >>
> >> >> I'm trying to use the servicemix-http http:provider to call a
> RESTful
> >> >> service. GET works fine but I'm having trouble trying to configure
> it
> >> to
> >> >> do
> >> >> a post. It appears to me that DefaultHttpProviderMarshaler does not
> >> >> directly
> >> >> support this and so I must write my own Marshaler to set the
> content.
> >> My
> >> >> first question is just a request to verify that is correct and that
> >> I'm
> >> >> not
> >> >> missing something.
> >> >>
> >> >> My next question is about
> >> >> http://issues.apache.org/activemq/browse/SM-580
> >> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580> .
> This
> >> >> appears to address this situation although I'm not certain it
> >> >> does so in a RESTful way (I'm new to REST). SM-580 appears to be
> >> >> scheduled
> >> >> for 3.3 so is this what I would use once 3.3 is released and when is
> >> 3.3
> >> >> scheduled for release?
> >> >>
> >> >> Thanks
> >> >> Tom
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
> >> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Cheers,
> >> > Guillaume Nodet
> >> > ------------------------
> >> > Blog: http://gnodet.blogspot.com/
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
The message gets sent to the correct URI but the issue is the content of the
message. I need to send the XML (<foo>bar</foo>) but what gets returned by
contentExpression.evaluate(exchange, inMsg), subsequently sent to the
RESTful service, is just the values (bar).
At this point I guess its really a Jaxen question. Can you get it to return
the XML instead of just the values? Otherwise some other parsing strategy is
needed. However, I really liked the idea of just defining an XPath
expression on the endpoint. It seems it would make the marshaler pretty
flexible.
Thanks
Tom
gnodet wrote:
>
> Well, it sounds realy good.
> What exactly does not work when using POST with your marshaler ?
>
> On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>> Guillaume
>>
>> Okay, I'm new to REST so I may be missing something there too but this is
>> where I'm at. SMX will receive a JMS message with an XML payload. The XML
>> will have two high level nodes. One node's value will be the service to
>> call
>> (will become part of the REST URL). The other node will be a big chunk of
>> XML to be POSTed to the service. The content-type is
>> x-www-form-urlencoded.
>>
>> I extended DefaultHttpProviderMarshaler and I call
>> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>>
>> This almost works. I use JaxenStringXPathExpression to get the value of
>> the
>> first node and set the REST URL. Then my class has a new property,
>> contentExpression, also a JaxenStringXPathExpression. I use this to
>> define
>> the XPath to the second node, the one with the big chunk of XML, but it
>> adds
>> the values of the second node. What I need is the chunk of XML, elements,
>> attributes and all.
>>
>> I guess I could introduce a Saxon endpoint to do a transformation and a
>> router to send the message to different HTTP endpoints based on the first
>> node but that seems a lot less elegant than just dynamically determining
>> the
>> REST URL in the marshaler. It works fine for GETs but then POST, I'm
>> learning, is a different story.
>>
>> Any thoughts?
>>
>> Thanks
>> Tom
>>
>>
>> gnodet wrote:
>> >
>> > I really think the best way would be to create your own marshaler if
>> the
>> > default one does not work for you. If you come up with something
>> generic
>> > enough feel free to contribute it back. However, the
>> > DefaultHttpProviderMarshaler should send a POST request if the input
>> > message
>> > is not null, but this is more like a soap POST rather than a form post
>> > with
>> > key/value pairs. Is that what you'd need ? How do you extract the
>> > key/value pairs from the exchange ?
>> >
>> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
>> > <tp...@chariotsolutions.com>
>> > wrote:
>> >
>> >>
>> >> Hello
>> >>
>> >> I'm trying to use the servicemix-http http:provider to call a RESTful
>> >> service. GET works fine but I'm having trouble trying to configure it
>> to
>> >> do
>> >> a post. It appears to me that DefaultHttpProviderMarshaler does not
>> >> directly
>> >> support this and so I must write my own Marshaler to set the content.
>> My
>> >> first question is just a request to verify that is correct and that
>> I'm
>> >> not
>> >> missing something.
>> >>
>> >> My next question is about
>> >> http://issues.apache.org/activemq/browse/SM-580
>> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580> . This
>> >> appears to address this situation although I'm not certain it
>> >> does so in a RESTful way (I'm new to REST). SM-580 appears to be
>> >> scheduled
>> >> for 3.3 so is this what I would use once 3.3 is released and when is
>> 3.3
>> >> scheduled for release?
>> >>
>> >> Thanks
>> >> Tom
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16446910.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
Well, it sounds realy good.
What exactly does not work when using POST with your marshaler ?
On Wed, Apr 2, 2008 at 12:00 AM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Guillaume
>
> Okay, I'm new to REST so I may be missing something there too but this is
> where I'm at. SMX will receive a JMS message with an XML payload. The XML
> will have two high level nodes. One node's value will be the service to
> call
> (will become part of the REST URL). The other node will be a big chunk of
> XML to be POSTed to the service. The content-type is
> x-www-form-urlencoded.
>
> I extended DefaultHttpProviderMarshaler and I call
> httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
>
> This almost works. I use JaxenStringXPathExpression to get the value of
> the
> first node and set the REST URL. Then my class has a new property,
> contentExpression, also a JaxenStringXPathExpression. I use this to define
> the XPath to the second node, the one with the big chunk of XML, but it
> adds
> the values of the second node. What I need is the chunk of XML, elements,
> attributes and all.
>
> I guess I could introduce a Saxon endpoint to do a transformation and a
> router to send the message to different HTTP endpoints based on the first
> node but that seems a lot less elegant than just dynamically determining
> the
> REST URL in the marshaler. It works fine for GETs but then POST, I'm
> learning, is a different story.
>
> Any thoughts?
>
> Thanks
> Tom
>
>
> gnodet wrote:
> >
> > I really think the best way would be to create your own marshaler if the
> > default one does not work for you. If you come up with something
> generic
> > enough feel free to contribute it back. However, the
> > DefaultHttpProviderMarshaler should send a POST request if the input
> > message
> > is not null, but this is more like a soap POST rather than a form post
> > with
> > key/value pairs. Is that what you'd need ? How do you extract the
> > key/value pairs from the exchange ?
> >
> > On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
> > <tp...@chariotsolutions.com>
> > wrote:
> >
> >>
> >> Hello
> >>
> >> I'm trying to use the servicemix-http http:provider to call a RESTful
> >> service. GET works fine but I'm having trouble trying to configure it
> to
> >> do
> >> a post. It appears to me that DefaultHttpProviderMarshaler does not
> >> directly
> >> support this and so I must write my own Marshaler to set the content.
> My
> >> first question is just a request to verify that is correct and that I'm
> >> not
> >> missing something.
> >>
> >> My next question is about
> >> http://issues.apache.org/activemq/browse/SM-580
> >> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580> . This
> >> appears to address this situation although I'm not certain it
> >> does so in a RESTful way (I'm new to REST). SM-580 appears to be
> >> scheduled
> >> for 3.3 so is this what I would use once 3.3 is released and when is
> 3.3
> >> scheduled for release?
> >>
> >> Thanks
> >> Tom
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
> >> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Re: servicemix-http Post support
Posted by Tom Purcell <tp...@chariotsolutions.com>.
Guillaume
Okay, I'm new to REST so I may be missing something there too but this is
where I'm at. SMX will receive a JMS message with an XML payload. The XML
will have two high level nodes. One node's value will be the service to call
(will become part of the REST URL). The other node will be a big chunk of
XML to be POSTed to the service. The content-type is x-www-form-urlencoded.
I extended DefaultHttpProviderMarshaler and I call
httpExchange.setRequestContent(bigXmlChunkContentOfTheSecondNode).
This almost works. I use JaxenStringXPathExpression to get the value of the
first node and set the REST URL. Then my class has a new property,
contentExpression, also a JaxenStringXPathExpression. I use this to define
the XPath to the second node, the one with the big chunk of XML, but it adds
the values of the second node. What I need is the chunk of XML, elements,
attributes and all.
I guess I could introduce a Saxon endpoint to do a transformation and a
router to send the message to different HTTP endpoints based on the first
node but that seems a lot less elegant than just dynamically determining the
REST URL in the marshaler. It works fine for GETs but then POST, I'm
learning, is a different story.
Any thoughts?
Thanks
Tom
gnodet wrote:
>
> I really think the best way would be to create your own marshaler if the
> default one does not work for you. If you come up with something generic
> enough feel free to contribute it back. However, the
> DefaultHttpProviderMarshaler should send a POST request if the input
> message
> is not null, but this is more like a soap POST rather than a form post
> with
> key/value pairs. Is that what you'd need ? How do you extract the
> key/value pairs from the exchange ?
>
> On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell
> <tp...@chariotsolutions.com>
> wrote:
>
>>
>> Hello
>>
>> I'm trying to use the servicemix-http http:provider to call a RESTful
>> service. GET works fine but I'm having trouble trying to configure it to
>> do
>> a post. It appears to me that DefaultHttpProviderMarshaler does not
>> directly
>> support this and so I must write my own Marshaler to set the content. My
>> first question is just a request to verify that is correct and that I'm
>> not
>> missing something.
>>
>> My next question is about
>> http://issues.apache.org/activemq/browse/SM-580
>> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580> . This
>> appears to address this situation although I'm not certain it
>> does so in a RESTful way (I'm new to REST). SM-580 appears to be
>> scheduled
>> for 3.3 so is this what I would use once 3.3 is released and when is 3.3
>> scheduled for release?
>>
>> Thanks
>> Tom
>> --
>> View this message in context:
>> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>
--
View this message in context: http://www.nabble.com/servicemix-http-Post-support-tp16418421p16427193.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: servicemix-http Post support
Posted by Guillaume Nodet <gn...@gmail.com>.
I really think the best way would be to create your own marshaler if the
default one does not work for you. If you come up with something generic
enough feel free to contribute it back. However, the
DefaultHttpProviderMarshaler should send a POST request if the input message
is not null, but this is more like a soap POST rather than a form post with
key/value pairs. Is that what you'd need ? How do you extract the
key/value pairs from the exchange ?
On Tue, Apr 1, 2008 at 3:26 PM, Tom Purcell <tp...@chariotsolutions.com>
wrote:
>
> Hello
>
> I'm trying to use the servicemix-http http:provider to call a RESTful
> service. GET works fine but I'm having trouble trying to configure it to
> do
> a post. It appears to me that DefaultHttpProviderMarshaler does not
> directly
> support this and so I must write my own Marshaler to set the content. My
> first question is just a request to verify that is correct and that I'm
> not
> missing something.
>
> My next question is about http://issues.apache.org/activemq/browse/SM-580
> SM-580 <http://issues.apache.org/activemq/browse/SM-580SM-580> . This
> appears to address this situation although I'm not certain it
> does so in a RESTful way (I'm new to REST). SM-580 appears to be scheduled
> for 3.3 so is this what I would use once 3.3 is released and when is 3.3
> scheduled for release?
>
> Thanks
> Tom
> --
> View this message in context:
> http://www.nabble.com/servicemix-http-Post-support-tp16418421s12049p16418421.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/