Hi all! I have been given a task to parse a SOAP service and database it. The *vendor* has given me an example of working code in VB.NET - and that's it. That's all the documentation there is. I have been trying to convert it to a working version in PHP but I have had absolutely no luck. I am hoping someone can point me in the right direction. Below is the VB.NET example I was given.
Private Sub GetData()
‘ Proxy is an arbitrary name I used to point to the Web Reference URL.
‘ You may call it something else in your code.
Dim soapHeader As Proxy.UserCredentials = New Proxy.UserCredentials
soapHeader.Email = "YourEmailAddress@Domain.com"
soapHeader.Password = "password"
Dim ws As Proxy.Service = New Proxy.Service
ws.UserCredentialsValue = soapHeader
Dim forDate As DateTime = "1/1/2011"
Dim result As String = ws.GetIncidentData(forDate)
End Sub
Here is the PHP service code I created:
<?php
try{
$options = array(
// Stuff for development.
'trace' => true,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'login' => 'email@address.com',
'password' => 'secret',
);
$client = new SoapClient($wsdl_url, $options);
$auth = new UserCredentials($e, $p);
$authvalues=new SoapVar($auth,SOAP_ENC_OBJECT);
$header=new SoapHeader($wsdl_url,
"UserCredentials",
$authvalues,
false,
$wsdl_url);
$client->__setSoapHeaders($header);
$x = $client->__soapCall("GetIncidentData", array("forDate"=>"1/1/2011"), null, $header, $return_headers);
var_dump($header);
}catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
And here is the 'UserCredentials ' class code:
<?php
class UserCredentials {
// private $email;
// private $password;
public function __construct($email,$password) {
$this->Email=$email;
$this->Password=$password;
}
}
?>
This returns "object(stdClass)#6 (1) { ["GetIncidentDataResult"]=> string(23) "Missing User Credential" } "
Thanks so much for any help. It will be greatly appreciated.