The Content Web Service

From Plnwiki

Allows the retrieval of content stored by the LOCKSS daemon.


Upcoming (1.68)


The Content web service WSDL (Web Services Description Language) file, an XML file that describes the functionality of a web service, can be obtained from the LOCKSS web application; if the application is running on port 80 of localhost, the URL


will display the WSDL file of the Content web service.

The WSDL file is particularly useful to automatically generate client stubs and other artifacts.

For Java, two tools that are widely available are wsimport and wsdl2java.

For Python, there is wsdl2py.

For .NET, Content Service (fetchFile) requires MTOM-encoded WCF Service Model .NET Client Configuration


The following is an example of a web service client that obtains the content pointed to by the link

import javax.xml.namespace.QName;


public class ContentWsExample {
  private static final String USER_NAME = "lockss-u";
  private static final String PASSWORD = "lockss-p";
  private static final String ADDRESS_LOCATION =
  private static final String TARGET_NAMESPACE = "";
  private static final String SERVICE_NAME = "ContentServiceImplService";
  private static final String TIMEOUT_KEY =
  // The length of the client connection timeout in seconds.
  private static final int TIMEOUT_VALUE = 600;
  private static final String URL =

   * The main method.
   * @param args
   *          A String[] with the command line arguments.
   * @throws Exception
  public static void main(String args[]) throws Exception {
    ContentWsExample example = new ContentWsExample();

    // Authenticate.

    // Get the service.
    Service service = Service.create(new URL(ADDRESS_LOCATION), new QName(

    ContentService port = service.getPort(ContentService.class);

    // Set the client connection timeout.
    (( port).getRequestContext().put(TIMEOUT_KEY,
	new Integer(TIMEOUT_VALUE*1000));

    // Call the service and get the results of the operation.
    ContentResult result = port.fetchFile(URL, null);

    // Write the received content to a local file.
    File outputFile = result.writeContentToFile("/tmp/content869571.pdf");

   * Sets the authenticator that will be used by the networking code when the
   * HTTP server asks for authentication.
  private void authenticate() {
    Authenticator.setDefault(new Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
	return new PasswordAuthentication(USER_NAME, PASSWORD.toCharArray());