java Apache/Axis soap/rdf tester

/* stolen from apache Axis examples by Doug and Glen */
// http://lists.w3.org/Archives/Public/www-archive/2001Jul/0020.html
// for perl equiv i'm trying to clone

package samples.misc ;

import java.net.*;
import java.io.*;
import java.util.*;

import org.apache.axis.*;
import org.apache.axis.utils.Debug ;
import org.apache.axis.utils.Options ;
import org.apache.axis.client.ServiceClient ;
import org.apache.axis.transport.http.HTTPTransport ;


public class RDFQClient {


    public static String query =  "SELECT ?x, ?l, ?c" +
	"FROM     http://xmlns.com/wordnet/1.6/Job "+
	"WHERE "+
	"  (web::type ?x rdfs::Class) "+
	"  (rdfs::label ?x ?l) "+
	"  (rdfs::description ?x ?c) "+
	"USING web FOR http://www.w3.org/1999/02/22-rdf-syntax-ns# "+
       	"rdfs FOR http://www.w3.org/2000/01/rdf-schema#";

   public static String data = "http://xmlns.com/wordnet/1.6/Job";

    public static String msg = "<SOAP-ENV:Envelope " +
        "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
        "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" > " +
        "<SOAP-ENV:Body>\n" +

        "<rq:squish xmlns:rq=\"http://rdfweb.org/RDF/RDFWeb/SOAPDemo\">\n" +
        "<rq:query>" + query + "</rq:query>"+
	"<rq:data>"+ data +"</rq:data>"+
        "</rq:squish>\n" +

        "</SOAP-ENV:Body></SOAP-ENV:Envelope>\n";

    /**
     * Send a hardcoded message to the server, and print the response.
     *
     * @param args the command line arguments (mainly for specifying URL)
     * @param service an optional service argument, which will be used for
     * specifying the transport-level service
     */
    public static String doTest (String args[], String service) throws Exception {
      Options      opts    = new Options( args );
      String       url     = opts.getURL();
      String       action  = "EchoService" ;

        if (service != null) {
            action = service;
        }

      Debug.setDebugLevel( opts.isFlagSet( 'd' ) );

      args = opts.getRemainingArgs();
      if ( args != null ) action = args[0];

      ServiceClient client = new ServiceClient(new HTTPTransport());



      // RDF Query setup...
      url = "http://fireball.dyndns.org/cgi-bin/soap"; // danbri hack
      action = "http://rdfweb.org/RDF/RDFWeb/SOAPDemo#squish";


      client.set(HTTPTransport.URL, url);
      client.set(HTTPTransport.ACTION, action);

      Message        reqMsg      = new Message( msg );
      Message        resMsg     = null ;

      System.out.println( "Request:\n" + msg );
      System.out.println( "Url: " + url );
      System.out.println( "soap action is: " + action );

      client.setRequestMessage( reqMsg );
      client.invoke();
      resMsg = client.getMessageContext().getResponseMessage();

      System.out.println( "Response:\n" + resMsg.getAsString() );
        return (String)resMsg.getAsString();
    }

  public static void main(String args[]) throws Exception{
    doTest(args, null);
  }
  public static void mainWithService(String args[], String service) throws Exception{
    doTest(args, service);
  }
}

Received on Friday, 27 July 2001 19:16:05 UTC