VB.NET to PHP SOAP conversion help needed

Hi all! I have been given a taks 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 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.

[code]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 = "[email protected]"
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[/code]

Here is the PHP service code I created:

[code]<?php

try{

$options = array(
// Stuff for development.
‘trace’ => true,
‘exceptions’ => true,
‘cache_wsdl’ => WSDL_CACHE_NONE,
‘login’ => ‘[email protected]’,
‘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”;
}
?>[/code]

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.

Sponsor our Newsletter | Privacy Policy | Terms of Service