Here is the code, apologies did not have time to clean it up.
The exception here has not be caught yet in my 4 trials with this so
far. I do not think I made any change in the way the web service is
accessed.
public class RESTClient {
public static void main(String[] args) {
// System.out.println(test);
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
client.addFilter(new LoggingFilter());
// System.out.println(test);
WebResource service = client.resource(getBaseURI());
File f = new File(/home/monika/post.xml);
// System.out.println(f.exists());
// String
//
response=service.header(Content-Type,text/xml).post(String.class,f);
String response = ;
//ClientResponse response= null;
try {
response=
service.type(MediaType.TEXT_XML).post(String.class, f);
} catch (UniformInterfaceException e) {
// System.out.println(test);
// System.out.println(e.getClass());
// System.out.println(e.getResponse().toString());
}
// System.out.println(test);
System.out.println(response.toString());
}
private static URI getBaseURI() {
return
UriBuilder.fromUri(http://lod.openlinksw.com/fct/service;).build();
}
// curl -H Content-Type: text/xml -d @post.xml
}
Post file now has this query:
?xml version=1.0?
query xmlns=http://openlinksw.com/services/facets/1.0; inference=
same-as=
textKingsley/text
property iri=[foaf:knows]
view type=list /
/property
/query
Hugh Williams wrote:
Hi Monika,
Good to hear this is working'ish for you now ...
What was the change you made to make it work, was their any change in the way
it accesses the Virtuoso facet's web service endpoint ?
You can post Jersey code to this mailing list or a reference to you blog, which
ever you prefer ...
Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support
Twitter: http://twitter.com/OpenLink
On 10 Mar 2010, at 08:26, Monika Solanki wrote:
Hi Hugh,
I actually got it working, although I do not understand how and why the
change made a difference :). The code is also behaving non
deterministically so I am going to keep experimenting. I can post the
code to the list or point to my blog as since this list is not really
for Jersey, so I am not sure if it is allowed to post jersey code here.
Monika
Hugh Williams wrote:
Hi Monika,
You indicated in your email to me that the post.xml file contained:
?xml version=1.0?
query xmlns=http://openlinksw.com/services/facets/1.0; inference=
same-as=
textMike/text
property iri=[foaf:knows]
view type=list /
/property
/query
but when I execute if against the http://lod.openlinksw.com/fct/service web service using curl it
returns an empty response, I presume curl also gives a similar response for you ? Changing the text
field content from Mike to Kingsley does provide a response, so you might
want to try that.
In terms of logging on the server their is no additional logging enabled on
this server. What I have done is setup a local server with additional logging
enabled on the server and also to the client. This can be accessed as:
$ curl -H Content-Type: text/xml -d @post.xml
http://nevisian.dyndns.org:8890/fct/service
With the following simple post file contents, which returns data:
$ more post.xml
?xml version=1.0?
query xmlns=http://openlinksw.com/services/facets/1.0; inference=
same-as=
textcnet/text
view type=text limit=10 offset=/
/query
Can you try querying this server using your Jersey client, and let me know how
this works and it any additional error information is reported for the cause of
any failures. I can also check the server to see any errors are being logged at
that end ...
Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support
Twitter: http://twitter.com/OpenLink
On 9 Mar 2010, at 20:30, Monika Solanki wrote:
Hello,
Does anyone have any experience with this. I am not able to do a POST
of the query file using Jersey. The server keeps throwing 500.
Code below:
{
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
client.addFilter(new LoggingFilter());
System.out.println(test);
WebResource service = client.resource(getBaseURI());
File f = new File(/home/monika/post.xml);
System.out.println(f.exists());
String
response=service.type(MediaType.TEXT_XML).accept(MediaType.TEXT_XML).post(String.class,f);
System.out.println(response.toString());
}
private static URI getBaseURI() {
return UriBuilder.fromUri(
http://lod.openlinksw.com/fct/service;).build