Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 1002

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="15. Web Services" />
  <meta name="dc.subject" content="15. Web Services" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="webservices.html" title="Chapter Contents" />
  <link rel="prev" href="soap.html" title="SOAP" />
  <link rel="next" href="vfoafssl.html" title="WebID Protocol Support" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>15. Web Services</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="wsdl" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>15. Web Services</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="webservices.html">Chapter Contents</a> | <a class="link" href="soap.html" title="SOAP">Prev</a> | <a class="link" href="vfoafssl.html" title="WebID Protocol Support">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="webservices.html">Web Services</a>
   </div>
    <br />
   <div>
      <a href="soap.html">SOAP</a>
   </div>
   <div class="selected">
      <a href="wsdl.html">WSDL</a>
    <div>
        <a href="#exposplaswsdl" title="Exposing Stored Procedures as WSDL Services">Exposing Stored Procedures as WSDL Services</a>
        <a href="#expcplx_types" title="Exposing SQL Stored Procedures containing complex datatype definitions">Exposing SQL Stored Procedures containing complex datatype definitions</a>
        <a href="#exp3rdprtyprocwsdl" title="Exposing Third Party SQL Stored Procedures as WSDL-Compliant Web Services">Exposing Third Party SQL Stored Procedures as WSDL-Compliant Web Services</a>
        <a href="#wsdlheadermessages" title="WSDL Descriptions of SOAP Header Messages">WSDL Descriptions of SOAP Header Messages</a>
        <a href="#importwsdl" title="Importing A WSDL File &amp; SOAP/WSDL Proxying">Importing A WSDL File &amp; SOAP/WSDL Proxying</a>
        <a href="#soapwsdlinterop" title="SOAP/WSDL Interoperability">SOAP/WSDL Interoperability</a>
    </div>
   </div>
   <div>
      <a href="vfoafssl.html">WebID Protocol Support</a>
   </div>
   <div>
      <a href="voauth.html">OAuth Support</a>
   </div>
   <div>
      <a href="vwsssupport.html">WS-Security (WSS) Support in Virtuoso SOAP Server</a>
   </div>
   <div>
      <a href="ws-routing.html">Web Services Routing Protocol (WS-Routing)</a>
   </div>
   <div>
      <a href="warm.html">Web Services Reliable Messaging Protocol (WS-ReliableMessaging)</a>
   </div>
   <div>
      <a href="vwstrust.html">Web Services Trust Protocol (WS-Trust)</a>
   </div>
   <div>
      <a href="xmlxmla.html">XML for Analysis Provider</a>
   </div>
   <div>
      <a href="xmlrpc.html">XML-RPC support</a>
   </div>
   <div>
      <a href="syncml.html">SyncML</a>
   </div>
   <div>
      <a href="uddi.html">UDDI</a>
   </div>
   <div>
      <a href="expwsmodules.html">Exposing Persistent Stored Modules as Web Services</a>
   </div>
   <div>
      <a href="vsmx.html">Testing Web Published Web Services</a>
   </div>
   <div>
      <a href="bpel.html">BPEL Reference</a>
   </div>
   <div>
      <a href="xsql.html">XSQL</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="wsdl" />
    <h2>15.2. WSDL</h2>
    <p>The Web Services Description Language (WSDL) is a standard, structured way of
    describing SOAP messages and Web services.  It is an XML format
    for describing the network services offered by a
    service provider.  The provider will publish a WSDL file that contains details
    about the services provided, and the set of operations
    within each service that the provider supports.  For each of the
    operations, the WSDL file also describes the format that the client must follow
    in requesting an operation.</p>
    <p>Since the WSDL file sets up requirements for both the provider and service
    requester, this file is like a contract between the two.  The provider agrees to
    provide certain services if the client sends a properly formatted SOAP
    request.  Suppose that we have a WSDL file defining a service called
    StockQuoteService.  This service describes operations such as
    getTradePrice, getLowestTradePrice, and getHighestTradePrice.  You place this WSDL
    file on the service provider server.  A client who wishes to send a SOAP request to
    this server must first obtain a copy of the WSDL file from the provider, and then
    use it to format a suitable SOAP request.  The client sends this request to the provider.
    The provider executes the requested operation and sends the results back to
    the client requester as a SOAP response.</p>

  <div class="tip">
      <div class="tiptitle">See Also:</div>
  <p>The specification of WSDL and its file structures can be found on
  <a href="http://www.w3.org/TR/wsdl">the W3C site</a>.</p>
  </div>

  <a name="exposplaswsdl" />
    <h3>15.2.1. Exposing Stored Procedures as WSDL Services</h3>
    <p>Virtuoso can be both a provider and a client of WSDL.  In
    this section we will explain
    how to use Virtuoso to expose procedures as SOAP messages, and then publish
    them as WSDL consumables.</p>

<p>In the descriptions below, lines preceded by <span class="computeroutput">SQL&gt;</span>
denote that the command is intended to be issued using
the <a href="isql.html">ISQL</a> command line interface to Virtuoso.</p>

<p>Virtuoso procedures can easily be published as WSDL consumables.
We follow the same steps as we would take to create SOAP objects and
then for every SOAP object Virtuoso automatically generates a WSDL
file entry.  The default Virtuoso has the user SOAP and reserved HTTP
path of <span class="computeroutput">/SOAP/</span>.  All procedures that are created in
the default qualifier namespace of the SOAP user (WS.SOAP) and have
had a &#39;grant execute to SOAP&#39; permissions established in the database
are available to SOAP and thus are automatically available to WSDL.
In Virtuoso this is done by requesting the file
<span class="computeroutput">services.wsdl</span> from the server via HTTP from the
<span class="computeroutput">/SOAP/</span> path:
<span class="computeroutput">http://[host:port]/SOAP/services.wsdl</span>.
WSDL files such as this are often referred to as &quot;endpoints&quot;
for services.
</p>
<p>
<a href="webserver.html#virtdir">Virtual directories</a> increase our
flexibility by allowing us to map logical HTTP paths to the location
<span class="computeroutput">/SOAP/</span>.  This means that we can separate WSDL/SOAP functionality,
making groups of services available under different locations.
We will now demonstrate this:</p>

<ol>
      <li>
        <p>First, create a new user in the database for
creating the stored procedures as SOAP messages:</p>
<div>
          <pre class="programlisting">SQL&gt;CREATE USER SOAPDEMO;</pre>
        </div>
</li>
      <li>
        <p>Now, set the default catalogue/qualifier for
the new user to the WS catalogue where we will create procedures
to be used as SOAP objects:</p>
<div>
          <pre class="programlisting">SQL&gt;USER_SET_QUALIFIER (&#39;SOAPDEMO&#39;, &#39;WS&#39;);</pre>
        </div>
</li>
      <li>
        <p>Now  create a new <a href="webserver.html#virtdir">virtual host</a>
definition, using the <a href="fn_vhost_define.html">vhost_define()</a>,
so that we can find our SOAP objects later at a desired location.</p>
<div>
          <pre class="programlisting">
SQL&gt;VHOST_DEFINE (vhost=&gt;&#39;*ini*&#39;,lhost=&gt;&#39;*ini*&#39;,lpath=&gt;&#39;/services&#39;,ppath=&gt;&#39;/SOAP/&#39;,soap_user=&gt;&#39;SOAPDEMO&#39;);
</pre>
        </div>
<p>If the mapping already exists, producing an error in the call above, and is not being
used, then you can remove it using the command:</p>
<div>
          <pre class="programlisting">
SQL&gt;VHOST_REMOVE (vhost=&gt;&#39;*ini*&#39;,lhost=&gt;&#39;*ini*&#39;,lpath=&gt;&#39;/services&#39;)
</pre>
        </div>
<div class="note">
          <div class="notetitle">Note:</div>
          <p>*ini* is a special indicator telling
Virtuoso to take the default values from its initialization file.</p>
        </div>
</li>
      <li>
        <p>Now create a simple SOAPTEST procedure and grant the appropriate
privileges to the SOAPDEMO user:</p>
<div>
          <pre class="programlisting">
SQL&gt; create procedure
  WS.SOAPDEMO.SOAPTEST (in par varchar)
{
  return (upper(par));
};

SQL&gt; grant execute on WS.SOAPDEMO.SOAPTEST to SOAPDEMO;
</pre>
        </div>
</li>
      <li>
        <p>Now test this new SOAP object&#39;s availability by using
<a href="fn_soap_client.html">soap_client()</a>.
This function would normally return a vector representation of the
SOAP object but since we know the dimensions of the object ahead of
time we can pin-point the entry using the <a href="fn_aref.html">aref()</a> function as
follows:</p>
<div>
          <pre class="programlisting">
SQL&gt; select aref(aref(
	soap_client (url=&gt;sprintf (&#39;http://localhost:%s/services&#39;, server_http_port ()),
	operation=&gt;&#39;SOAPTEST&#39;, parameters=&gt;vector(&#39;par&#39;, &#39;demotext&#39;)), 1), 1);
callret
VARCHAR
_______

DEMOTEXT

</pre>
        </div>
<p>The actual SOAP object looks more like:</p>
<div>
          <pre class="programlisting">
((&quot;SOAPTESTResponse&quot; ) ((&quot;CallReturn&quot; ) &quot;DEMOTEXT&quot; ) )
</pre>
        </div>
<p>which was generated in a Virtuoso server log for debugging purposes using
the <a href="fn_dbg_obj_print.html">dbg_obj_print()</a> function.</p>
</li>
      <li>
        <p>Procedures that exist under the WS.SOAPDEMO namespace
and have been granted execution to the new SOAPDEMO user are  now available
as SOAP services and described by WSDL in this example, Virtuoso would publish
them from the URL:</p>
<div>
          <pre class="programlisting">
http://localhost/services/services.wsdl
</pre>
        </div>
<p>which will yield the following WSDL description:</p>
<div>
          <pre class="screen">

&lt;?xml version=&#39;1.0&#39;?&gt;
&lt;definitions
 targetNamespace=&#39;services.wsdl&#39;
 xmlns:xsd=&#39;http://www.w3.org/1999/XMLSchema&#39;
 xmlns:soap=&#39;http://schemas.xmlsoap.org/wsdl/soap/&#39;
 xmlns:tns =&#39;services.wsdl&#39;
 xmlns =&#39;http://schemas.xmlsoap.org/wsdl/&#39;
 name=&#39;VirtuosoSOAP&#39;&gt;
	&lt;message name=&#39;SOAPTEST&#39;&gt;
		&lt;part name=&#39;par&#39; type=&#39;xsd:string&#39;/&gt;
	&lt;/message&gt;
	&lt;message name=&#39;SOAPTESTResponse&#39;&gt;
		&lt;part name=&#39;CallReturn&#39; type=&#39;xsd:string&#39;/&gt;
	&lt;/message&gt;
	&lt;portType name=&#39;SOAPPortType&#39;&gt;
		&lt;operation name=&#39;SOAPTEST&#39;&gt;
			&lt;input message=&#39;tns:SOAPTEST&#39; name=&#39;SOAPTEST&#39;/&gt;
			&lt;output message=&#39;tns:SOAPTESTResponse&#39; name=&#39;SOAPTESTResponse&#39;/&gt;
		&lt;/operation&gt;
	&lt;/portType&gt;
	&lt;binding name=&#39;SOAPBinding&#39; type=&#39;tns:SOAPPortType&#39;&gt;
		&lt;soap:binding style=&#39;rpc&#39; transport=&#39;http://schemas.xmlsoap.org/soap/http&#39;/&gt;
		&lt;operation name=&#39;SOAPTEST&#39;&gt;
			&lt;soap:operation soapAction=&#39;urn:openlinksw.com:virtuoso_soap_schema#SOAPTEST&#39;/&gt;
			&lt;input&gt;
				&lt;soap:body use=&#39;encoded&#39; namespace=&#39;urn:openlinksw.com:virtuoso_soap_schema&#39; encodingStyle=&#39;http://schemas.xmlsoap.org/soap/encoding/&#39; /&gt;
			&lt;/input&gt;
			&lt;output&gt;
				&lt;soap:body use=&#39;encoded&#39; namespace=&#39;urn:openlinksw.com:virtuoso_soap_schema&#39; encodingStyle=&#39;http://schemas.xmlsoap.org/soap/encoding/&#39; /&gt;
			&lt;/output&gt;
		&lt;/operation&gt;
	&lt;/binding&gt;
	&lt;service name=&#39;SOAPService&#39;&gt;
		&lt;port name=&#39;SOAPPort&#39; binding=&#39;tns:SOAPBinding&#39;&gt;
			&lt;soap:address location=&#39;http://localhost/services&#39;/&gt;
		&lt;/port&gt;
	&lt;/service&gt;
&lt;/definitions&gt;

</pre>
        </div>
<div class="tip">
          <div class="tiptitle">See Also:</div>
<p>The <a href="vsmx.html">Testing Web Services (VSMX)</a> section
describes Virtuoso&#39;s ability to also automatically generate a test page for
your SOAP services, simply by replacing services.wsdl with services.vsmx in the
URL.</p>
        </div>

</li>
    </ol>

  <br />

  
      <a name="expcplx_types" />
    <h3>15.2.2. Exposing SQL Stored Procedures containing complex datatype definitions</h3>
      <p>
	  When parameters of a PL procedure or UDT (User Defined Type) methods contain
	  parameters declared as UDT or/and as ARRAY then WSDL generation will
	  include XML Schema for them. The schema types in this case will be generated every time
	  WSDL URL is accessed. Also the XMLSchema datatypes will be generated following
	  the default encoding rules forced via &#39;Use&#39; SOAP option to the given virtual directory.
      </p>
      <a name="ex_expcplx_types_1" />
    <div class="example">
	  <div class="exampletitle">Exposing a PL Stored procedures containing complex datatypes</div>
	  <p>
	      The following example will create a virtual directory &#39;/soap-lit&#39; on default HTTP
	      listener and will expose a single method accepting a array of structures which
	      contains an array of integers, integer, varchar and float members. The SOAP message
	      will use the document/literal encoding rules (option Use=literal).
	  </p>
	<div>
        <pre class="programlisting">
create user SOAP_U1;

VHOST_DEFINE (	lpath=&gt;&#39;/soap-lit&#39;,
		ppath=&gt;&#39;/SOAP/&#39;, soap_user=&gt;&#39;SOAP_U1&#39;,
    		soap_opts=&gt;
	    	vector (&#39;ServiceName&#39;, &#39;Literal&#39;,
		    &#39;Namespace&#39;, &#39;http://temp.uri&#39;,
		    &#39;SchemaNS&#39;, &#39;http://temp.uri&#39;,
		    &#39;MethodInSoapAction&#39;, &#39;yes&#39;,
		    &#39;elementFormDefault&#39;, &#39;unqualified&#39;,
		    &#39;Use&#39;, &#39;literal&#39;));

create type SOAP_StructA as (varString varchar, varInt integer, varFloat real, varArray integer array);

create procedure echoStructArray (in sa DB.DBA.SOAP_StructA array) returns DB.DBA.SOAP_StructA array
{
  return sa;
};


grant execute on SOAP_StructA to SOAP_U1;
grant execute on echoStructArray to SOAP_U1;

</pre>
      </div>
<p>
    This would produce the following WSDL file when accessing the http://[host:port]/soap-lit/services.wsdl URL.
</p>
	<div>
        <pre class="programlisting">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;definitions xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:http=&quot;http://schemas.xmlsoap.org/wsdl/http/&quot; xmlns:mime=&quot;http://schemas.xmlsoap.org/wsdl/mime/&quot; xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot; xmlns:dime=&quot;http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/&quot; xmlns:wsdl=&quot;http://schemas.xmlsoap.org/wsdl/&quot; xmlns:soapenc=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; xmlns:content=&quot;http://schemas.xmlsoap.org/ws/2002/04/content-type/&quot; xmlns:ref=&quot;http://schemas.xmlsoap.org/ws/2002/04/reference/&quot; xmlns:ns0=&quot;http://temp.uri&quot; xmlns:dl=&quot;http://temp.uri&quot; xmlns:tns=&quot;services.wsdl&quot; xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot; targetNamespace=&quot;services.wsdl&quot; name=&quot;VirtuosoLiteral&quot;&gt;
  &lt;types&gt;
    &lt;schema xmlns=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:wsdl=&quot;http://schemas.xmlsoap.org/wsdl/&quot; targetNamespace=&quot;http://temp.uri&quot;&gt;
      &lt;complexType name=&quot;echoStructArray_Response_t&quot;&gt;
        &lt;sequence&gt;
          &lt;element name=&quot;item&quot; type=&quot;ns0:SOAP_StructA&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot; nillable=&quot;true&quot;/&gt;
        &lt;/sequence&gt;
      &lt;/complexType&gt;
      &lt;complexType name=&quot;echoStructArray_sa_t&quot;&gt;
        &lt;sequence&gt;
          &lt;element name=&quot;item&quot; type=&quot;ns0:SOAP_StructA&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot; nillable=&quot;true&quot;/&gt;
        &lt;/sequence&gt;
      &lt;/complexType&gt;
      &lt;complexType name=&quot;SOAP_StructA&quot;&gt;
        &lt;all&gt;
          &lt;element name=&quot;varString&quot; type=&quot;string&quot; nillable=&quot;true&quot;/&gt;
          &lt;element name=&quot;varInt&quot; type=&quot;int&quot; nillable=&quot;true&quot;/&gt;
          &lt;element name=&quot;varFloat&quot; type=&quot;float&quot; nillable=&quot;true&quot;/&gt;
          &lt;element name=&quot;varArray&quot; type=&quot;ns0:SOAP_StructA_varArray_t&quot; nillable=&quot;true&quot;/&gt;
        &lt;/all&gt;
      &lt;/complexType&gt;
      &lt;complexType name=&quot;SOAP_StructA_varArray_t&quot;&gt;
        &lt;sequence&gt;
          &lt;element name=&quot;item&quot; type=&quot;int&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot; nillable=&quot;true&quot;/&gt;
        &lt;/sequence&gt;
      &lt;/complexType&gt;
      &lt;element name=&quot;echoStructArray&quot;&gt;
        &lt;complexType&gt;
          &lt;sequence&gt;
            &lt;element minOccurs=&quot;1&quot; maxOccurs=&quot;1&quot; name=&quot;sa&quot; type=&quot;ns0:echoStructArray_sa_t&quot;/&gt;
          &lt;/sequence&gt;
        &lt;/complexType&gt;
      &lt;/element&gt;
      &lt;element name=&quot;echoStructArrayResponse&quot;&gt;
        &lt;complexType&gt;
          &lt;all&gt;
            &lt;element minOccurs=&quot;1&quot; maxOccurs=&quot;1&quot; name=&quot;CallReturn&quot; type=&quot;ns0:echoStructArray_Response_t&quot;/&gt;
          &lt;/all&gt;
        &lt;/complexType&gt;
      &lt;/element&gt;
    &lt;/schema&gt;
  &lt;/types&gt;
  &lt;message name=&quot;echoStructArrayRequest&quot;&gt;
    &lt;part element=&quot;dl:echoStructArray&quot; name=&quot;parameters&quot;/&gt;
  &lt;/message&gt;
  &lt;message name=&quot;echoStructArrayResponse&quot;&gt;
    &lt;part element=&quot;dl:echoStructArrayResponse&quot; name=&quot;parameters&quot;/&gt;
  &lt;/message&gt;
  &lt;portType name=&quot;LiteralDocLiteralPortType&quot;&gt;
    &lt;operation name=&quot;echoStructArray&quot;&gt;
      &lt;input message=&quot;tns:echoStructArrayRequest&quot; name=&quot;echoStructArrayRequest&quot;/&gt;
      &lt;output message=&quot;tns:echoStructArrayResponse&quot; name=&quot;echoStructArrayResponse&quot;/&gt;
    &lt;/operation&gt;
  &lt;/portType&gt;
  &lt;binding name=&quot;LiteralDocLiteralBinding&quot; type=&quot;tns:LiteralDocLiteralPortType&quot;&gt;
    &lt;soap:binding style=&quot;document&quot; transport=&quot;http://schemas.xmlsoap.org/soap/http&quot;/&gt;
    &lt;operation name=&quot;echoStructArray&quot;&gt;
      &lt;soap:operation soapAction=&quot;http://temp.uri#echoStructArray&quot; style=&quot;document&quot;/&gt;
      &lt;input name=&quot;echoStructArrayRequest&quot;&gt;
        &lt;soap:body use=&quot;literal&quot;/&gt;
      &lt;/input&gt;
      &lt;output name=&quot;echoStructArrayResponse&quot;&gt;
        &lt;soap:body use=&quot;literal&quot;/&gt;
      &lt;/output&gt;
    &lt;/operation&gt;
  &lt;/binding&gt;
  &lt;service name=&quot;VirtuosoLiteral&quot;&gt;
    &lt;documentation&gt;Virtuoso SOAP services&lt;/documentation&gt;
    &lt;port name=&quot;LiteralDocLiteralPort&quot; binding=&quot;tns:LiteralDocLiteralBinding&quot;&gt;
      &lt;soap:address location=&quot;http://localhost:8890/soap-lit&quot;/&gt;
    &lt;/port&gt;
  &lt;/service&gt;
&lt;/definitions&gt;
	    </pre>
      </div>
      </div>
  <br />


<a name="exp3rdprtyprocwsdl" />
    <h3>15.2.3. Exposing Third Party SQL Stored Procedures as WSDL-Compliant Web Services</h3>
<p>Virtuoso can expose any of its available PL resource to the SOAP
world, and subsequently to the WDSL file.  This includes data from remote
attached tables and procedures.  All you have to do is make sure that the entry point
exists as a stored procedure in the correct namespace with the appropriate grants, as before.</p>
<div class="tip">
      <div class="tiptitle">See Also</div>
<p>The <a href="">Virtual Database</a> chapter for information regarding use of
remote data sources and their tables.</p>
    </div>
	<p>Because remote procedures may not be directly compatible you are required
	to write a Virtuoso wrapper function first to handle the remote procedure.
	Below is a sample MS SQLServer procedure and an accompanying Virtuoso wrapper
	function.  The MS SQLServer function returns a result set based on a simple join
	query with a filter input.  The Virtuoso procedure calls the remote procedure,
	iterates through the result set returned and produces XML output.</p>
	<p>MS SQLServer procedure:</p>
<div>
      <pre class="programlisting">

create procedure ms_remote
        @mask varchar(15)
as
  select c.CustomerID, c.CompanyName, o.OrderDate,
      o.ShippedDate,ol.ProductID, ol.Quantity, ol.Discount
    from Northwind..Customers c
      inner join Northwind..Orders o on c.CustomerID = o.CustomerID
      inner join Northwind..&quot;Order Details&quot; ol on o.OrderID = ol.OrderID
    where c.CustomerID like @mask
;

</pre>
    </div>
  <p>Virtuoso wrapper function:</p>
<div>
      <pre class="programlisting">

create procedure WS.SOAP.ms_remote_call (
  in dsn varchar, in uid varchar, in pwd varchar, in mask varchar)
{
  declare m, r, ses any;
  vd_remote_data_source (dsn, &#39;&#39;, uid, pwd);
  rexecute (dsn, &#39;ms_remote ?&#39;, null, null, vector (mask), 1000, m, r);
  ses := string_output ();
  http (&#39;&lt;?xml version=&quot;1.0&quot; ?&gt;\n&lt;remote&gt;\n&#39;, ses);
  if (isarray(m) and isarray (r))
    {
      declare i, l, j, k integer;
      declare md, rs any;
      md := m[0];
      i := 0; l := length (md); k := length (r); j := 0;
      while (j &lt; k)
       {
	 http (&#39;&lt;record &#39;, ses);
         i:=0;
         while (i &lt; l)
           {
	     dbg_obj_print (md[i][0],r[j][i]);
	     http (sprintf (&#39; %s=&quot;%s&quot;&#39;, trim(md[i][0]), trim(cast (r[j][i] as varchar))), ses);
             i := i + 1;
	   }
	 http (&#39; /&gt;\n&#39;, ses);
         j := j + 1;
       }
    }
  http (&#39;&lt;/remote&gt;&#39;, ses);
  return string_output_string (ses);
};

</pre>
    </div>
  <p>Now, as before, we grant execute rights to the SOAP user:</p>
<div>
      <pre class="programlisting">
grant execute on WS.SOAP.ms_remote_call to SOAP;
</pre>
    </div>
  <p>The third-party procedures can now be accessed via SOAP and are listed in the
  WSDL file.</p>
<br />

  <a name="wsdlheadermessages" />
    <h3>15.2.4. WSDL Descriptions of SOAP Header Messages</h3>
  <p>The Virtuoso web server automatically generates WSDL descriptions for
  procedures exposed as SOAP messages, and those exposed to have parameters
  bound to SOAP Header messages.</p>

  <p>Consider the sample of the Interop.INTEROP.echoVoid procedure defined
  as an example in the SOAP section as:</p>

  <div>
      <pre class="programlisting">
create procedure
Interop.INTEROP.echoVoid
   (in echoMeStringRequest nvarchar := NULL __soap_header &#39;http://www.w3.org/2001/XMLSchema:string&#39;,
    out echoMeStringResponse nvarchar := NULL __soap_header &#39;http://www.w3.org/2001/XMLSchema:string&#39;)
   __soap_type &#39;__VOID__&#39;
{
  if (echoMeStringRequest is not null)
    echoMeStringResponse := echoMeStringRequest;
};</pre>
    </div>

  <p>The WSDL description will now contain the header messages also.  No extra
  user intervention is required.  The WSDL file that will result will look
  like:</p>

  <div>
      <pre class="programlisting">
 ......... WSDL excerpt (consider http://[host:port]/Interop/services.wsdl of an demo DB) ............
	&lt;message name=&quot;echoVoidRequest&quot;&gt;&lt;/message&gt;
	&lt;message name=&quot;echoVoidResponse&quot;&gt;&lt;/message&gt;
	&lt;message name=&quot;echoVoidechoMeStringRequest&quot;&gt;
		&lt;part name=&quot;echoMeStringRequest&quot; type=&quot;xsd:string&quot; /&gt;
	&lt;/message&gt;
	&lt;message name=&quot;echoVoidechoMeStringResponse&quot;&gt;
		&lt;part name=&quot;echoMeStringResponse&quot; type=&quot;xsd:string&quot; /&gt;
	&lt;/message&gt;
 ........ in bindings section note the soap:header sections.............
	&lt;operation name=&quot;echoVoid&quot;&gt;
	&lt;soap:operation soapAction=&quot;http://soapinterop.org/&quot; /&gt;
	&lt;input&gt;
	&lt;soap:body use=&quot;encoded&quot; namespace=&quot;http://soapinterop.org/&quot; encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; /&gt;
	&lt;soap:header use=&quot;encoded&quot; message=&quot;tns:echoVoidechoMeStringRequest&quot; part=&quot;echoMeStringRequest&quot; namespace=&quot;http://soapinterop.org/echoheader/&quot; encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; /&gt;
	&lt;/input&gt;
	&lt;output&gt;
	&lt;soap:body use=&quot;encoded&quot; namespace=&quot;http://soapinterop.org/&quot; encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; /&gt;
	&lt;soap:header use=&quot;encoded&quot; message=&quot;tns:echoVoidechoMeStringResponse&quot; part=&quot;echoMeStringResponse&quot; namespace=&quot;http://soapinterop.org/echoheader/&quot; encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; /&gt;
	&lt;/output&gt;
	&lt;/operation&gt;
 ........more..........
 </pre>
    </div>
 <br />

 <a name="importwsdl" />
    <h3>15.2.5. Importing A WSDL File &amp; SOAP/WSDL Proxying</h3>
 <p>Virtuoso can import WSDL files from other locations using the function:</p>
 <p>
      <a href="fn_soap_wsdl_import.html">soap_wsdl_import()</a>
    </p>
 <p>This function reads the descriptions of SOAP messages available in the
 WSDL file and automatically creates Virtuoso stored procedure wrappers for
 executing the SOAP messages directly from Virtuoso in procedures.  These
 generated procedures can then be exposed as SOAP messages in the normal way
 from the Virtuoso SOAP server, and of course fully described by an automatically
 generated WSDL file for them, thus creating a proxy service for original messages.</p>
 <br />

 <a name="soapwsdlinterop" />
    <h3>15.2.6. SOAP/WSDL Interoperability</h3>
 <p>A key feature of the Web services promise is that Web services published
 with one server can be called from any other client.  The ability of each
 implementation to make use of each others&#39; output is called interoperability.
 Thus, Web services created with Virtuoso should interoperate smoothly with
 services created with Microsoft&#39;s .NET, Sun&#39;s Java, and so on.  Interoperable
 Web services mean that developers and users do not have to think about which
 programming language or operating system the services are hosted on.</p>
 <p>The evolving nature of the SOAP specification, as well as its complexity,
 leads to differences in SOAP implementations.  Unfortunately, these
 implementation differences decrease interoperability.  To counteract this
 problem, a volunteer group of SOAP application builders has developed a series
 of interoperability tests.</p>
 <p>OpenLink, as a participant in this group, ensures that its SOAP
 implementation interoperates fully.  This means that Virtuoso&#39;s SOAP server
 properly exposes your Web services so they can be used by any client.  It also
 means that Virtuoso can call services published by any compliant provider.</p>
 <p>You can view the Round 1 &quot;Interoperability Lab&quot; at
 <a href="http://www.xmethods.net/ilab/">www.xmethods.net</a>
 and the Round 2 at <a href="http://www.whitemesa.com/interop.htm">www.whitemesa.com</a>.
 Please note that OpenLink has no connection with these companies; they are
 simply places that volunteered to host the testing reference documents on
 their servers.</p>
 <p>The Round 2 tests include base functionality (which duplicates Round
 1) as well as more advanced tests labeled &quot;Group B&quot; and &quot;Group C&quot;.  The WSDL
 published by OpenLink containing the descriptions of these tests can be found
 at <a href="http://demo.openlinksw.com:8890/Interop/">http://demo.openlinksw.com:8890/Interop/</a>.
 This URL will be updated as new interoperability tests are devised.</p>
 <p>The SOAP implementation passes all known interoperability tests.</p>
 <br />
<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="soap.html" title="SOAP">Previous</a>
          <br />SOAP</td>
     <td align="center" width="34%">
          <a href="webservices.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="vfoafssl.html" title="WebID Protocol Support">Next</a>
          <br />WebID Protocol Support</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>