users@jersey.java.net

Re: [Jersey] Struggling to post file to a REST web service through Jersey Client

From: Monika Solanki <m.solanki_at_mcs.le.ac.uk>
Date: Tue, 09 Mar 2010 20:17:33 +0000

Here is the output from the log:

09-Mar-2010 20:13:55 com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client out-bound request
1 > POST http://lod.openlinksw.com/fct/service
1 > Content-Type: text/xml
1 > Accept: text/xml
1 >
<?xml version="1.0"?>
<query xmlns="http://openlinksw.com/services/facets/1.0" inference=""
same-as="">
  <text>Mike</text>
 <property iri="[foaf:knows]">
    <view type="list" />
  </property>
</query>









09-Mar-2010 20:14:20 com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client in-bound response
1 < 509
1 < Date: Tue, 09 Mar 2010 20:14:20 GMT
1 < Content-Length: 0
1 < Connection: Keep-Alive
1 < Accept-Ranges: bytes
1 < Content-Type: text/xml; charset="UTF-8"
1 < Server: Virtuoso/06.01.3127 (Linux) x86_64-generic-linux-glibc25-64 VDB
1 <

Exception in thread "main"
com.sun.jersey.api.client.UniformInterfaceException: POST
http://lod.openlinksw.com/fct/service returned a response status of 509
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:563)
    at com.sun.jersey.api.client.WebResource.access$300(WebResource.java:69)
    at
com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:499)
    at RESTClient.main(RESTClient.java:27)

Monika

Paul Sandoz wrote:
> On Mar 9, 2010, at 5:36 PM, Monika Solanki wrote:
>
>
>> Hi Paul,
>>
>> One thing that was mentioned to me was that I should provide the
>>
>> "Content-Type", which should be "text/xml"
>>
>>
>> but I thought I took care of this.
>>
>
> Yes, the type method takes care of that.
>
>
>
>> Other than that I don't know what
>> else to look for.
>>
>>
>
> Do you have access to the server logs? or is this a public service?
>
> If you enable logging you might get some clues if there is any info in
> the 500 response.
>
> client.addFilter(new LoggingFilter());
>
> My own suspicious are that the server cannot process the XML document
> in the post.xml file.
>
> Paul.
>
>
>> Monka
>> Paul Sandoz wrote:
>>
>>> Hi Monika,
>>>
>>> Your client code looks OK.
>>>
>>> What is the server side? any more details in the server logs?
>>>
>>> Paul.
>>>
>>> On Mar 9, 2010, at 2:36 PM, Monika Solanki wrote:
>>>
>>>
>>>
>>>> Hello,
>>>>
>>>> I am trying to send an XML file and get the response back as text/
>>>> xml. The server is throwing 500. Please could someone help me with
>>>> my code below
>>>> {
>>>> ClientConfig config = new DefaultClientConfig();
>>>> Client client = Client.create(config);
>>>> WebResource service = client.resource(getBaseURI());
>>>> File f = new File("/home/monika/post.xml");
>>>> System.out.println(f.exists());
>>>> String response;
>>>> response =
>>>> service
>>>> .type
>>>> (MediaType.TEXT_XML).accept(MediaType.TEXT_XML).post(String.class,
>>>> f);
>>>>
>>>> }
>>>>
>>>> private static URI getBaseURI() {
>>>> return UriBuilder.fromUri(
>>>> "http://lod.openlinksw.com/fct/service").build();
>>>> }
>>>>
>>>> --
>>>> Dr Monika Solanki
>>>> F27 Department of Computer Science
>>>> University of Leicester
>>>> Leicester LE1 7RH
>>>> United Kingdom
>>>> Tel: +44 116 252 3828
>>>> Google: 52.653791,-1.158414
>>>> http://www.cs.le.ac.uk/people/ms491
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>> For additional commands, e-mail: 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
>>>
>>>
>>>
>> --
>> Dr Monika Solanki
>> F27 Department of Computer Science
>> University of Leicester
>> Leicester LE1 7RH
>> United Kingdom
>> WebID: http://www.cs.le.ac.uk/people/ms491/foaf.rdf#monika
>> Google Coordinates: 52.653791,-1.158414
>> Tel: +44 116 252 3828
>> Web: http://www.cs.le.ac.uk/people/ms491/
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: 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
>
>

-- 
Dr Monika Solanki
F27 Department of Computer Science
University of Leicester
Leicester LE1 7RH
United Kingdom
Tel: +44 116 252 3828
Google: 52.653791,-1.158414
http://www.cs.le.ac.uk/people/ms491