<docbook><section><title>VirtTipsAndTricksSOAPRequestsAgainstSPARQLEndpoint</title><para> </para>
<title>How Can I send SOAP requests to a Virtuoso SPARQL Endpoint?</title>How Can I send SOAP requests to a Virtuoso SPARQL Endpoint?
<para> The following example presents a sample scenario on how to execute a SPARQL query as a SOAP request to the Virtuoso SPARQL Endpoint.</para>
<orderedlist spacing="compact"><listitem>Assume the following sample SOAP request containing simple SPARQL query: <programlisting>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
   &lt;soapenv:Body&gt;
      &lt;query-request xmlns=&quot;http://www.w3.org/2005/09/sparql-protocol-types/#&quot;&gt;
         &lt;query xmlns=&quot;&quot;&gt;SELECT DISTINCT ?z FROM virtrdf: {?x ?y ?z .} LIMIT 10&lt;/query&gt;
      &lt;/query-request&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;
</programlisting></listitem>
<listitem>Save locally the content from above for ex.
 to file with the name &quot;soap.xml&quot;.
</listitem>
<listitem>To pass the SOAP request to a Virtuoso SPARQL Endpoint, execute the following curl command: <programlisting>$ curl -d@soap.xml -H &quot;Content-Type:text/xml&quot; -H &quot;SOAPAction: &#39;&#39;&quot; http://localhost:8890/sparql
&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
  &lt;soapenv:Body&gt;
    &lt;query-result xmlns=&quot;http://www.w3.org/2005/09/sparql-protocol-types/#&quot;&gt;
      &lt;sparql xmlns=&quot;http://www.w3.org/2005/sparql-results#&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd&quot;&gt;
        &lt;head&gt;
         &lt;variable name=&quot;z&quot;/&gt;
        &lt;/head&gt;
        &lt;results distinct=&quot;false&quot; ordered=&quot;true&quot;&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#QuadStorage&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#array-of-QuadMapFormat&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#QuadMap&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#QuadMapValue&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#array-of-QuadMapColumn&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#QuadMapColumn&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#array-of-QuadMapATable&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#QuadMapATable&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;
          &lt;result&gt;
            &lt;binding name=&quot;z&quot;&gt;
             &lt;uri&gt;http://www.openlinksw.com/schemas/virtrdf#QuadMapFText&lt;/uri&gt;
            &lt;/binding&gt;
          &lt;/result&gt;          
        &lt;/results&gt;        
      &lt;/sparql&gt;
    &lt;/query-result&gt;
  &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;
</programlisting> </listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2">Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtTipsAndTricksGuide">Virtuoso Tips and Tricks Collection</ulink> </listitem>
<listitem><ulink url="http://docs.openlinksw.com/virtuoso/soap.html#soapovervw">Virtuoso SOAP</ulink> </listitem>
</itemizedlist></section></docbook>