]> git.mjollnir.org Git - moodle.git/commitdiff
web service MDL-12886 alpha SOAP server/client
authorjerome <jerome>
Thu, 15 Jan 2009 07:27:22 +0000 (07:27 +0000)
committerjerome <jerome>
Thu, 15 Jan 2009 07:27:22 +0000 (07:27 +0000)
webservice/soap/moodle.wsdl [new file with mode: 0644]
webservice/soap/server.php [new file with mode: 0644]
webservice/soap/testclient/index.php [new file with mode: 0644]

diff --git a/webservice/soap/moodle.wsdl b/webservice/soap/moodle.wsdl
new file mode 100644 (file)
index 0000000..d1ee37b
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version ='1.0' encoding ='UTF-8' ?>
+        <definitions name='User'
+          targetNamespace='http://example.org/User'
+          xmlns:tns=' http://example.org/User '
+          xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
+          xmlns:xsd='http://www.w3.org/2001/XMLSchema'
+          xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
+          xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
+          xmlns='http://schemas.xmlsoap.org/wsdl/'>
+
+          <types>
+         <xsd:schema
+             targetNamespace="http://example.org/User"
+             xmlns="http://www.w3.org/2001/XMLSchema">
+             <xsd:complexType name="user">
+             </xsd:complexType>
+          </xsd:schema>
+       </types>
+
+
+        <message name='getusersRequest'>
+          <part name='search' type='xsd:string'/>
+        </message>
+        <message name='getusersResponse'>
+          <part name='user' type='xsd:user'/>
+        </message>
+
+        <portType name='UserPortType'>
+          <operation name='tmp_get_users'>
+            <input message='tns:getusersRequest'/>
+            <output message='tns:getusersResponse'/>
+          </operation>
+        </portType>
+
+        <binding name='UserBinding' type='tns:UserPortType'>
+          <soap:binding style='rpc'
+            transport='http://schemas.xmlsoap.org/soap/http'/>
+          <operation name='tmp_get_users'>
+            <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_get_users'/>
+            <input>
+              <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+                encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+            </input>
+            <output>
+              <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+                encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+            </output>
+          </operation>
+        </binding>
+
+        <service name='UserService'>
+          <port name='UserPort' binding='UserBinding'>
+            <soap:address location='http://jerome.moodle.com/Moodle_HEAD/moodle/webservice/soap/server.php?classpath=user'/>
+          </port>
+        </service>
+        </definitions>
\ No newline at end of file
diff --git a/webservice/soap/server.php b/webservice/soap/server.php
new file mode 100644 (file)
index 0000000..6e9c985
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Main script - SOAP server
+ *
+ * @author Jerome Mouneyrac <jerome@moodle.com>
+ * @version 1.0
+ * @package webservices
+ */
+
+/*
+ * SOAP server
+ */
+require_once(dirname(__FILE__) . '/../../config.php');
+
+//retrieve the api name
+$classpath = optional_param(classpath,null,PARAM_ALPHA);
+require_once(dirname(__FILE__) . '/../../'.$classpath.'/wsapi.php');
+
+/// run the server
+$server = new SoapServer("moodle.wsdl");
+$server->setClass($classpath."_ws_api");
+$server->handle();
+
+?>
\ No newline at end of file
diff --git a/webservice/soap/testclient/index.php b/webservice/soap/testclient/index.php
new file mode 100644 (file)
index 0000000..7ce8807
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * Main script - try a SOAP connection
+ *
+ * @author Jerome Mouneyrac <jerome@moodle.com>
+ * @version 1.0
+ * @package webservices
+ */
+
+/*
+ * SOAP client
+ */
+require_once(dirname(__FILE__) . '/../../../config.php');
+
+//$client = new SoapClient("moodle.wsdl");
+
+$client = new SoapClient("../moodle.wsdl",array(
+    "trace"      => 1,
+    "exceptions" => 0));
+
+try {
+    var_dump($client->tmp_get_users("admin"));
+    printLastRequestResponse($client);
+} catch (SoapFault $exception) {
+    echo $exception;
+}
+
+
+function printLastRequestResponse($client) {
+    print "<pre>\n";
+    print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
+    print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
+    print "</pre>";
+}
+
+?>
\ No newline at end of file