Leser: 26
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
<?php
require_once("soapapi-inc.php");
// connection settings
define("SOAPAPI_PROTO", "http");
define("SOAPAPI_HOST", "172.16.8.15");
define("SOAPAPI_PORT", "448");
define("SOAPAPI_FORMAT", "%s://%s:%d/SOAP");
define("SOAPAPI_WSDL_FILE", "../soapapi.wsdl");
// defining some useful constants.
define("REQUIRED_API_VERSION", "2.6.0");
define("VAP_GLOBAL", "Global");
define("EQUIPMENT_ID", "EQPT_1");
define("COUNTRY_CODE", "CANADA");
// clearing WSDL cache in the case the WSDL
// file would have changed.
SoapApi::ClearWSDLCache();
try {
// creating target URL
$url = sprintf(SOAPAPI_FORMAT, SOAPAPI_PROTO, SOAPAPI_HOST, SOAPAPI_PORT);
//echo "connecting to " . SOAPAPI_HOST . " using " . SOAPAPI_PROTO . "\n";
if (strcmp("http", SOAPAPI_PROTO) == 0) {
$c = new SoapApi(SOAPAPI_WSDL_FILE, array( 'location' => $url ,
'proxy_host' => SOAPAPI_HOST,
'proxy_port' => SOAPAPI_PORT
)
);
} else if (strcmp("https", SOAPAPI_PROTO) == 0) {
// creating a new SoapApi object. A fault will be raised if unsucessul.
$c = new SoapApi(SOAPAPI_WSDL_FILE, array( 'location' => $url,
'local_cert' => SOAPAPI_CLIENT_CERT,
'passphrase' => SOAPAPI_CLIENT_CERT_PASSPHRASE
)
);
} else {
echo "unknown protocol <" . SOAPAPI_PROTO . ">\n";
exit(1);
}
//echo "Retrieving SOAP API version...\n";
$rc = $c->soapGetSOAPVersion();
if (strcmp($rc->version, REQUIRED_API_VERSION) != 0) {
printf("Incorrect SOAP API version found: <%s> - expecting <%s>\n",
$rc->version,
REQUIRED_API_VERSION
);
exit(1);
}
printf("<H3>AddUserAccount</H3>");
$rc = $c->soapAddUserAccount("Test01", "123456", 1, 1);
printf("<br>");
printf("<H3>UpdateVirtualSCLocalUser</H3>");
$rc = $c->soapUpdateVirtualSCLocalUser("Internetzugang","Test01","123456",60,0,1);
printf("<br>");
exit;
} catch (SoapFault $fault) {
// displaying fault.
printf("<H1>Fehler im Skript!</H1><br>");
printf("string: <%s><br>", $fault->faultstring);
printf("code: <%s><br>", $fault->faultcode);
printf("actor: <%s><br>", $fault->error_message_prefix);
printf("detail: <%s><br>", $fault->userinfo);
// terminating and returning an error.
exit(1);
}
?>
1
2
3
4
5
6
7
function soapAddUserAccount($username, $password, $activeState, $accessControlledState)
{
// Add a new user account.
$rc = $this->AddUserAccount(array("username" => $username, "password" => $password, "activeState" => $activeState, "accessControlledState" => $accessControlledState));
return $rc;
}
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
#!/usr/bin/perl use strict; use warnings; use SOAP::Lite; # connection settings my %conf=(); $conf{SOAP_PROTO}='http'; $conf{SOAP_HOST}='172.16.8.15'; $conf{SOAP_PORT}='448'; $conf{SOAP_FORMAT}='%s://%s:%d/SOAP'; $conf{SOAP_WSDL_FILE}='../soapapi.wsdl'; # defining some useful constants. $conf{REQUIRED_API_VERSION}="2.6.0"; $conf{VAP_GLOBAL}="Global"; $conf{EQUIPMENT_ID}="EQPT_1"; $conf{COUNTRY_CODE}="CANADA"; # values $conf{USER}="Test01"; $conf{PASS}="123456"; if ($conf{SOAP_PROTO}=~/^https?$/) { my $url = sprintf($conf{SOAP_FORMAT}, $conf{SOAP_PROTO}, $conf{SOAP_HOST}, $conf{SOAP_PORT}); my $soap = SOAP::Lite->uri($conf{SOAP_WSDL_FILE})->proxy($url); my $rc = $soap->GetSOAPVersion(); test_error($rc); if ($rc->result!~/\Q$conf{REQUIRED_API_VERSION}/) { die sprintf( "Incorrect SOAP API version found: <%s> - expecting <%s>\n", $rc->version, $conf{REQUIRED_API_VERSION} ); } print("AddUserAccount\n"); $rc = $soap->AddUserAccount("username" => $conf{USER}, "password" => $conf{PASS}, "activeState" => 1, "accessControlledState" => 1); test_error($rc); print("UpdateVirtualSCLocalUser\n"); $rc = $soap->UpdateVirtualSCLocalUser("Internetzugang",$conf{USER},$conf{PASS},60,0,1); test_error($rc); } else { printf("%s not supported\n",$conf{SOAP_PROTO}); } sub test_error { my $rc=shift; die(sprintf("ERROR(%s) %s\n",$rc->faultcode,$rc->faultstring)) if($rc->fault); }
1 2
if ($rc->result!~/\Q$conf{REQUIRED_API_VERSION}/) { die("Incorrect SOAP API version found: <%s> - expecting <%s>\n", $rc->version, $conf{REQUIRED_API_VERSION} ); }
1 2
if ($rc->result!~/\Q$conf{REQUIRED_API_VERSION}/) { die sprintf( "Incorrect SOAP API version found: <%s> - expecting <%s>\n", $rc->version, $conf{REQUIRED_API_VERSION} ); }
1
2
3
4
5
6
7
function soapGetSOAPVersion()
{
// Get SOAP version.
$rc = $this->GetSOAPVersion(array());
return $rc;
}