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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
| <?php
include("../config.inc.php"); // contains $username and $password
class WsseAuthHeader extends SoapHeader {
private $wss_ns = "";
public function __construct($user, $pass, $ns = null) {
if ($ns) {
$this->wss_ns = $ns;
}
$auth = new stdClass();
$auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
$auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
$username_token = new stdClass();
$username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns);
$security_sv = new SoapVar(
new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns),
SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns);
parent::__construct($this->wss_ns, 'Security', $security_sv, true);
}
}
class ppsrSoapClient extends SoapClient{
private $wsdl;
private $wss_ns;
private $ppsr_ns;
private $params;
private $environment;
private $username;
private $password;
public function __construct($environment,$username,$password)
{
$this->wsdl = "schemas.ppsr.gov.au.2011.04.services.wsdl";
$this->wss_ns = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
$this->ppsr_ns = "http://schemas.ppsr.gov.au/2011/04/services";
$this->environment = $environment;
$this->username = $username;
$this->password = $password;
$this->params = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'targetenvironment' => $this->environment
);
parent::__construct($this->wsdl, $this->params);
// save us manually calling this each time.
$this->setSoapHeaders();
}
private function setSoapHeaders(){
$headers = array();
$headers[1] = new WsseAuthHeader($this->username, $this->password, $this->wss_ns);
$headers[2] = new SoapHeader($this->ppsr_ns,'TargetEnvironment',$this->environment,true);
$this->__setSoapHeaders($headers);
}
public function getUsername(){
return $this->username;
}
}
//Put the service parameters here
try{
$client = new ppsrSoapClient('Discovery',$username,$password);
try {
$result = $client->Ping(array("PingRequest"=>array("CustomersRequestMessageId"=>date("Ymdhisu").__LINE__)));
/*
$vars = array(
"CustomersRequestMessageId"=>date("Ymdhisu").__LINE__,
"Username"=>$client->getUsername(),
"NewPassword"=>"Newpassword1!" // no spaces, 7-15 characters, 1 x uppercase, 1 x number, 1 x special char, different from last 8 passwords
);
$result = $client->ChangeB2GPassword(array("ChangeB2GPasswordRequest"=>$vars));
*/
echo "<pre>";
print_r($result);
echo "</pre>";
} catch (Exception $e) {
echo "<h1>Exception</h1>";
echo $e->getMessage();
echo "<h1>Debugging Info</h1>";
echo "<p>REQUEST HEADERS:\n<pre>" .$client->__getLastRequestHeaders() . "</pre>\n</p>";
echo "<p>REQUEST:\n<pre>" .$client->__getLastRequest(). "</pre>\n</p>";
echo "<p>RESPONSE HEADERS:\n<pre>" .$client->__getLastResponseHeaders() . "</pre>\n</p>";
echo "<p>RESPONSE:\n<pre>" . $client->__getLastResponse() . "</pre>\n</p>";
}
} catch (Exception $e) {
echo $e->getMessage();
} |