/
soap_test.php
79 lines (60 loc) · 1.8 KB
/
soap_test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<html>
<head>
<title>PHP SOAP Test</title>
<style type="text/css">
body, html {font-family: Helvetica, Verdana, Arial; margin:10px; padding:0px; font-size:12px;}
div.xml {height:200px;width:100%;overflow:auto;border:solid 1px #999;}
</style>
</head>
<body>
<?php
$wsdl = "https://www.regonline.com/api/default.asmx?wsdl";
$client = new SoapClient($wsdl,
array(
"trace" => 1, // enable trace to view what is happening
"exceptions" => 0, // disable exceptions
"cache_wsdl" => 0) // disable any caching on the wsdl, encase you alter the wsdl server
);
// Login
$result = $client->Login(array("username" => "<USERNAME>", "password" =>"<PASSWORD>"));
// Get the API Token
$apiToken = $result->LoginResult->Data->APIToken;
// Setup the SOAP Header
$authHeader = new AuthHeader();
$authHeader->APIToken = $apiToken;
$header[] = new SoapHeader('http://www.regonline.com/api',
'TokenHeader',
$authHeader, false
);
$client->__setSoapHeaders($header);
// Makes the call to GetEvents
$events = $client->GetEvents(array("filter" => 'Title.Contains("Testing")', "orderBy" => ""));
// TODO: Do something with the results
// Class for passing the APIToken
class AuthHeader
{
var $APIToken;
function __construct()
{
}
}
?>
<h2>PHP SOAP Test</h2>
<p>
This is a sample demonstration of calling the RegOnline API using the PHP SoapClient. It first calls the Login method to get the API Token
and then passes the token to the GetEvents method via a SOAP Header.
</p>
<h3>REQUEST</h3>
<div class="xml">
<?php
echo htmlentities($client->__getLastRequest());
?>
</div>
<h3>RESPONSE</h3>
<div class="xml">
<?php
echo htmlentities($client->__getLastResponse());
?>
</div>
</body>
</html>