mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Soap Test/Beispiel Client
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
|
||||
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
* Karl Burkhart <burkhart@technikum-wien.at>.
|
||||
*/
|
||||
header("Cache-Control: no-cache");
|
||||
header("Cache-Control: post-check=0, pre-check=0",false);
|
||||
header("Expires Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Pragma: no-cache");
|
||||
|
||||
|
||||
require_once('../config/vilesci.config.inc.php');
|
||||
|
||||
$SOAPServer = new SoapServer(APP_ROOT."soap/test.wsdl.php?".microtime());
|
||||
$SOAPServer->addFunction("myTest");
|
||||
$SOAPServer->handle();
|
||||
|
||||
// WSDL Chache auf aus
|
||||
ini_set("soap.wsdl_cache_enabled", "0");
|
||||
|
||||
|
||||
function myTest($foo)
|
||||
{
|
||||
if($foo=='foo')
|
||||
return 'OK';
|
||||
else
|
||||
return new SoapFault("Server", 'bar');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
require_once('../config/vilesci.config.inc.php');
|
||||
header("Content-type: text/plain");
|
||||
echo "<?xml version='1.0' encoding='utf-8' ?>";
|
||||
?>
|
||||
|
||||
<wsdl:definitions name="Test"
|
||||
targetNamespace="http://www.technikum-wien.at/soap/"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:tns="http://www.technikum-wien.at/soap/"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
|
||||
|
||||
<wsdl:message name="myTestRequest">
|
||||
<wsdl:part name="foo" type="xsd:string" minOccurs="0"></wsdl:part>
|
||||
</wsdl:message>
|
||||
|
||||
|
||||
<wsdl:message name="myTestResponse">
|
||||
<wsdl:part name="message" type="xsd:string"></wsdl:part>
|
||||
</wsdl:message>
|
||||
|
||||
<wsdl:portType name="ConfigPortType" >
|
||||
<wsdl:operation name="myTest">
|
||||
<wsdl:input message="tns:myTestRequest"></wsdl:input>
|
||||
<wsdl:output message="tns:myTestResponse"></wsdl:output>
|
||||
</wsdl:operation>
|
||||
</wsdl:portType>
|
||||
|
||||
<wsdl:binding name="ConfigBinding" type="tns:ConfigPortType">
|
||||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
|
||||
<wsdl:operation name="myTest">
|
||||
<soap:operation soapAction="<?php echo APP_ROOT."soap/myTest";?>" />
|
||||
<wsdl:input>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
</wsdl:binding>
|
||||
|
||||
<wsdl:service name="Test">
|
||||
<wsdl:port name="ConfigWebservicePort" binding="tns:ConfigBinding">
|
||||
<soap:address location="<?php echo APP_ROOT."soap/test.soap.php";?>"/>
|
||||
</wsdl:port>
|
||||
</wsdl:service>
|
||||
</wsdl:definitions>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
require_once('../config/vilesci.config.inc.php');
|
||||
require_once('../include/functions.inc.php');
|
||||
|
||||
$uid = get_uid();
|
||||
if(!check_lektor($uid))
|
||||
die('Sie haben keine Berechtigung für diese Seite.');
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<script type="text/javascript" src="../include/js/jquery.js"></script>
|
||||
<script type="text/javascript" src="../include/js/jqXMLUtils.js"></script>
|
||||
<script type="text/javascript" src="../include/js/jqSOAPClient.js"></script>
|
||||
|
||||
<title>Test-Client</title>
|
||||
|
||||
<script type="text/javascript">
|
||||
function gettimestamp()
|
||||
{
|
||||
var now = new Date();
|
||||
var ret = now.getHours()*60*60*60;
|
||||
ret = ret + now.getMinutes()*60*60;
|
||||
ret = ret + now.getSeconds()*60;
|
||||
ret = ret + now.getMilliseconds();
|
||||
return ret;
|
||||
}
|
||||
|
||||
function sendSoap()
|
||||
{
|
||||
var soapBody = new SOAPObject("myTest");
|
||||
soapBody.appendChild(new SOAPObject("foo")).val('foo');
|
||||
var sr = new SOAPRequest("myTest",soapBody);
|
||||
|
||||
SOAPClient.Proxy="<?php echo APP_ROOT;?>soap/test.soap.php?"+gettimestamp();
|
||||
SOAPClient.SendRequest(sr, clb_response);
|
||||
}
|
||||
function clb_response(respObj)
|
||||
{
|
||||
try
|
||||
{
|
||||
var msg = respObj.Body[0].myTestResponse[0].message[0].Text;
|
||||
alert(msg);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
var fehler = respObj.Body[0].Fault[0].faultstring[0].Text;
|
||||
alert('Fehler: '+fehler);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form action="test_client.php" method="post">
|
||||
<input type="submit" value="Test PHP" name="submit">
|
||||
<input type="button" onclick="sendSoap();" value="Test JS">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_REQUEST['submit']))
|
||||
{
|
||||
$url = APP_ROOT."soap/test.wsdl.php?".microtime(true);
|
||||
$client = new SoapClient($url);
|
||||
|
||||
echo 'URL: '.$url;
|
||||
echo '<br><br>';
|
||||
try
|
||||
{
|
||||
$response = $client->myTest('foo');
|
||||
var_dump($response);
|
||||
}
|
||||
catch(SoapFault $fault)
|
||||
{
|
||||
echo "SOAP Fault: (faultcode: ".$fault->faultcode.", faultstring: ".$fault->faultstring.")", E_USER_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user