Good catch ! Could you raise a JIRA and I'll fix it asap. On Wed, Apr 9, 2008 at 12:54 AM, Tom Purcell <[EMAIL PROTECTED]> 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 > > <[EMAIL PROTECTED]> > > 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@ > [EMAIL PROTECTED] > >> 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: > >> [EMAIL PROTECTED] > >> =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: > >> [EMAIL PROTECTED] > >> 13:39:26,466 - DEBUG - RestProviderMarshaler - *** exchange > >> message: > >> [EMAIL PROTECTED] > >> {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 > >> > <[EMAIL PROTECTED]> > >> > 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/