Hi,

> http://localhost:8080/rest/push?X=<moo />
> 
> I want to build an interface where a user can paste XML into a web form 
> and press submit.  As opposed to doing wget --post-file test.xml 
> http://localhost:8080/rest/push

I'm not sure if XML can be pasted like that, perhaps some escaping will need to 
be done, but either way, when dealing with complex query parameters, perhaps 
two options are available :

1. Add a static valueOf(String s) method to MyObject :

class MyObject {
public static MyObject valueOf(String xmlString) {
    // convert that XML into an instance of MyObject somehow
}

and then just do 

Response post(@QueryParam("X") MyObject o) {...}


2. Have a custom MessageBodyReader for MyObject, in its readFrom() method 
ignore the input stream, but instead deserialize the given query parameter into 
MyObject. For this to work, an instance of JAX-RS UriInfo will need to be 
injected into a custom reader's @Context-annotated field of type UriInfo by the 
runtime, UriInfo will provide an access to query parameters. CXF though does 
not support yet the injection of context fields so at the tine being option1 
would be the way to go.

and then just do 

Response post(MyObject o) {...}


Cheers, Sergey

> 
> 
> John Baker
> -- 
> Web SSO 
> IT Infrastructure 
> Deutsche Bank London
> 
> URL:  http://websso.cto.gt.intranet.db.com
> 
> 
> 
> 
> "Sergey Beryozkin" <[EMAIL PROTECTED]> 
> 12/05/2008 11:58
> Please respond to
> [email protected]
> 
> 
> To
> <[email protected]>
> cc
> <[email protected]>
> Subject
> Re: HTTP multipart/form-data and REST
> 
> 
> 
> 
> 
> 
> I'm feeling so slow myself :-), it it because it's Monday ?
> 
> 
>> Hi,
>>
>> I'm talking about deserialising to an object - I've been looking at
>> JAXBElementProvider which I assume is the default provider for:
>>
>> public Response post(MyObject o);
> 
> JAXBElementProvider is a default provider for serializing/deserilizing 
> JAXB-annotated classes, when application/xml media type is 
> used...On input, it will take the whole input body and attempt to 
> deserialize it, on output it will take the response entity and 
> serialize it into the provided output stream...
> 
>>
>> and I want to submit the XML with the parameter 'X' and deserialise to
>> MyObject.
> 
> I really don't understand it. Can you please elaborate on what does it 
> mean to 'submit the XML with the parameter 'X'' ?
> 
> Cheers, Sergey
> 
>>
>>
>> John Baker
>> -- 
>> Web SSO
>> IT Infrastructure
>> Deutsche Bank London
>>
>> URL:  http://websso.cto.gt.intranet.db.com
>>
>>
>>
>>
>> "Sergey Beryozkin" <[EMAIL PROTECTED]>
>> 12/05/2008 11:34
>> Please respond to
>> [email protected]
>>
>>
>> To
>> <[email protected]>
>> cc
>> <[email protected]>
>> Subject
>> Re: HTTP multipart/form-data and REST
>>
>>
>>
>>
>>
>>
>> Hi,
>>
>>
>>> Sergey,
>>>
>>> Thanks for updating the docs and there's no need to apologise for a
>> delay
>>> in responding (in reference to another mail you sent) - your rapid
>>> feedback on responses is most welcome to those of us in a corporate
>> world
>>> trying to demonstrate that open source is often better than close (BEA
>>> have a lot to learn!).
>>
>> thanks :-)
>>
>>>
>>> So consider my example - I'd like to deserialise the value of parameter
>> X,
>>> instead of deserialising the body of the POST.  How do I go about this?
>> I
>>> appreciate I need to write a message body reader bu what does the
>>> deserializing?
>>
>> Lets assume a request looks like this :
>>
>> POST /service?param1=1&param2=2
>>
>> <someXML/>
>>
>> When you say 'deserialise the value of parameter X', do you refer to 
> query
>> parameters like 'param1' above ?
>> If yes then yiu just need to use @QueryParam :
>>
>> Response post(@QueryParam("param1") String p1)
>>
>> The query parameter param1 will be converted into a String or it can be
>> converted into other type like Long or Integer which have a
>> constructor accepting a string and/or valueOf(String) method...
>>
>> Or are you referring to deserializing some pieces from the <someXML/> 
> body
>> ? You were talking about dealing with multipart/form-data
>> earlier, is it still the problem we're discussing here ?
>>
>> Cheers, Sergey
>>
>>
>>>
>>>
>>> John Baker
>>> -- 
>>> Web SSO
>>> IT Infrastructure
>>> Deutsche Bank London
>>>
>>> URL:  http://websso.cto.gt.intranet.db.com
>>>
>>>
>>
>> ----------------------------
>> IONA Technologies PLC (registered in Ireland)
>> Registered Number: 171387
>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, 
> Ireland
>>
>>
>>
>> ---
>>
>> This e-mail may contain confidential and/or privileged information. If 
> you are not the intended recipient (or have received this 
>> e-mail in error) please notify the sender immediately and delete this 
> e-mail. Any unauthorized copying, disclosure or distribution 
>> of the material in this e-mail is strictly forbidden.
>>
>> Please refer to http://www.db.com/en/content/eu_disclosures.htm for 
> additional EU corporate and regulatory disclosures. 
> 
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> 
> 
> 
> ---
> 
> This e-mail may contain confidential and/or privileged information. If you 
> are not the intended recipient (or have received this e-mail in error) please 
> notify the sender immediately and delete this e-mail. Any unauthorized 
> copying, disclosure or distribution of the material in this e-mail is 
> strictly forbidden.
> 
> Please refer to http://www.db.com/en/content/eu_disclosures.htm for 
> additional EU corporate and regulatory disclosures.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Reply via email to