wiki:WebServices

Version 6 (modified by ebmoore, 12 years ago) (diff)

--

SOAP Web Services

Wiki pages and WSDL locations

Term confusion

By the way, Web Services terms overload common terms which causes some confusion. Here is a rough correspondence:

  • port: like Java Class, Perl module, etc.
  • operation: like Java Method, Perl function, etc.; may take parameters

So you call the TransformationServer with the Web Services port TransformationServer and the Web Services operation transformXML.

Documentation may also refer to the endpoint or location which is a full URL including server and path where the SOAP client POSTs its message; in this case the endpoint is http://femur.biostr.washington.edu:8080/Transformer/services/TransformationWS. You usually don't need to know the endpoint, since most clients generate it using information in the WSDL.

Example clients

These examples query the SaxonWebService; for the syntax used with the other services, see their individual wiki pages.

Example: AngloSaxon

AngloSaxon is an pre-beta product written by Eider designed to call Web Services from within Saxon, an open source XSLT/XQuery processor.

let $q := 
"
<results> 
{ 
$pv/patient[pnum=50]/pnum
} 
</results>
"

let $a := anglo:xquery("http://cuboid.biostr.washington.edu:8080/SaxonWebService/wsdl/XQuery.wsdl", "XQuery", "doXQuery", $q)
return 
<foo>
{$a}
</foo>

Example: Apache Axis

This example is modified from the Apache Axis documentation, save this as testClient.java:

// http://www.apache.org/licenses/LICENSE-2.0
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

public class testClient
{
   public static void main(String [] args) {
       try {
           String endpoint = "http://cuboid.biostr.washington.edu:8080/SaxonWebService/services/XQuery";
           Service  service = new Service();
           Call     call    = (Call) service.createCall();

           call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName(new QName("http://soapinterop.org/", "doXQuery") );

           call.addParameter("xquery", org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
           call.setReturnType(org.apache.axis.Constants.XSD_STRING);

           String xquery = ""+
             "<results> {"+ 
             "$pv/patient[pnum=50]/pnum"+ 
             "}</results>";
           String ret = (String) call.invoke(new Object[] {xquery});

           System.out.println("QUERY: \n" + xquery + "\nRESULTS: \n\n" + ret + "\n");
       } catch (Exception e) {
           System.err.println(e.toString());
       }
   }
}

On SIG Linux machines, you can compile and run testClient.java with:

CP=/usr/share/java/axis/axis.jar
CP=$CP:/usr/share/java/axis/axis-ant.jar
CP=$CP:/usr/share/java/axis/jaxrpc.jar
CP=$CP:/usr/share/java/axis/saaj.jar
CP=$CP:/usr/share/java/commons-discovery.jar
CP=$CP:/usr/share/java/commons-logging.jar
CP=$CP:/usr/share/java/log4j.jar
CP=$CP:/usr/share/java/webserviceutils.jar
CP=$CP:/usr/share/java/wsdl4j.jar
javac -cp $CP testClient.java 
java -cp $CP testClient

Example: perl SOAP::Lite

For more information see http://guide.soaplite.com, especially Access with service description (WSDL))

#!/usr/bin/perl
use SOAP::Lite;
# if you want debug output including SOAP faults add '+trace':
#use SOAP::Lite +trace;
$q = '
let $p := $pv/patient[pnum=117] 
return $p/pnum
';
print SOAP::Lite
  -> service("http://cuboid.biostr.washington.edu:8080/SaxonWebService/wsdl/XQuery.wsdl")
  -> doXQuery("$q");
print "\n";