Hi Markus,
What version of Jersey are you using? With 0.6 or greater you can do this:
ClientResponse cr = r.post(ClientResponse.class, "content");
String h = cr.getMetadata().getFirst("X-My-Header");
String e = cr.getEntity(String.class);
When you utilize ClientResponse you will need to explicitly check the
status code for errors (unless you write a ClientFilter that checks and
throws an exception).
Paul.
Markus Kolb wrote:
> Bruno Luiz Pereira da Silva wrote on 2008-05-17 17:57:
>> I don't know which client API you're using, but using
>> commons-http-client, this is pretty easy.
>
> Oh, yes, of course...
> I use Jersey (com.sun.jersey.api.client.*) for this.
> Mostly the com.sun.jersey.api.client.WebResource class.
> So both sides are driven by Jersey... but I couldn't found anything to
> get the HTTP Headers.
> Do I have to use com.sun.jersey.api.client.ClientFilter?
>
>
>
> [...]
>> On Sat, May 17, 2008 at 12:42 PM, Markus Kolb <java-sun_at_tower-net.de
>> <mailto:java-sun_at_tower-net.de>> wrote:
>>
>> Hello,
>>
>> I need some help...
>> My client does a POST and in the response from WebService I've inserted
>> a custom X Header with Response.ok().header(...).build()
>> OK, that's fine, the header is there.
>> How does the client get the custom X Header?
>> I tried to get it from WebResource with the head().
>> But there is only getLanguage(), getStatus(), etc. and nothing to get a
>> custom header?!
>> How can this be done?
>>
>> Many thanks
>> Markus
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> <mailto:users-unsubscribe_at_jersey.dev.java.net>
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>> <mailto:users-help_at_jersey.dev.java.net>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109