mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
web service MDL-12886 alpha SOAP server/client
This commit is contained in:
parent
72aa74ce7c
commit
6eb82b7963
3 changed files with 117 additions and 0 deletions
56
webservice/soap/moodle.wsdl
Normal file
56
webservice/soap/moodle.wsdl
Normal file
|
@ -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>
|
24
webservice/soap/server.php
Normal file
24
webservice/soap/server.php
Normal file
|
@ -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();
|
||||
|
||||
?>
|
37
webservice/soap/testclient/index.php
Normal file
37
webservice/soap/testclient/index.php
Normal file
|
@ -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>";
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue