Jump to content

.NET to PHP SOAP conversion help


kiddynomite

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.