I'm trying to make a directory of my web services to make them more visible (findable) and started with this:
Keith Chapman's Blog: RESTfull Mashup with WSDL 2.0 - WSO2 Mashup Server
and the referenced WSDL file he uses. I think he in turn uses the useful IBM page on this subject, and the WSDL primer, core definition and adjunct pages. Apart from that, there's not much out there on using WSDL for RESTful services.
In theory this could all also be done in RDF, or even a mixture of the two... this might provide both the functional definition in WSDL and the ontological framework ('find me all the atlas web services which give run information') in RDF. I'll start with WSDL, progress to UDDI and then try to backtrack and insert some RDF.
Showing posts with label REST. Show all posts
Showing posts with label REST. Show all posts
Tuesday, 7 July 2009
Thursday, 28 May 2009
Java 'PUT' for RESTful service
I was looking around for a Java example of 'PUT' for the CherryPy/COOL server, and at least came across a 'GET' at Jose Sandovals blog... but not much on the other methods. Andrea Formica (Atlas Muons) is trying to use it to upload calibrations. Here's the solution he came up with, using Apache's library:
public String coolPutCherryPyHttpClient() throws IOException, FileNotFoundException{
String res = "none";
HttpClient client = new HttpClient();
PutMethod put = new PutMethod(this.writenodeUrl);
try {
String payloaddata = " 999 999. "
+ "";
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials(this.name, this.psswd);
client.getState().setCredentials(new AuthScope(serverUrl, portNumber, AuthScope.ANY_REALM), defaultcreds);
NameValuePair par = new NameValuePair();
par.setName("payload");
par.setValue(payloaddata);
NameValuePair[] params = new NameValuePair[1];
params[0] = par;
put.setQueryString(params);
// Execute the method.
int statusCode = client.executeMethod(put);
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " + put.getStatusLine());
}
// Read the response body.
byte[] responseBody = put.getResponseBody();
// Deal with the response.
// Use caution: ensure correct character encoding and is not binary data
res = new String(responseBody);
System.out.println(new String(responseBody));
} catch (HttpException e) {
System.err.println("Fatal protocol violation: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
System.err.println("Fatal transport error: " + e.getMessage());
e.printStackTrace();
} finally {
// Release the connection.
put.releaseConnection();
}
return res;
}
Subscribe to:
Posts (Atom)