Page 1 of 1

SOAP communication with WCF Service

Posted: Wed Jun 02, 2010 1:30 am
by toretotech
Hey all!

I followed the WCF tutorials on the beginners guide. I successfully managed to get a service up and running on IIS 7 and it functions perfectly with the WCF test client tool.
However, I am trying to comunicate to the service through PHP using SOAP without any success.

Here is what I have so far:

I have two functions defined on the service:

public class Service : IService
{
//just for testing
List<Customer> customers = new List<Customer>();

public List<Customer> getCustomer()
{
return customers;
}

public int addCustomer(Customer customer)
{
customers.Add(customer);
return customers.Count;
}
}


In php, I can see these if I do a dump of the getFunctions():

Code: Select all


$client = $client = new SoapClient("ServiceURL", array('soap_version' => SOAP_1_1, 'trace' => 0,'exceptions' => 1));

var_dump($client->__getFunctions());
 

This is where the problems start:

 

  $custObject = new myCustomer();
  $custObject->name = "Jane Smith";
  $custObject->id = 3;
 
  // ==============================
  // = Making Soap Function Calls =
  // ==============================
  
  $retVal = $client->addCustomer($custObject);

  echo "Returned from Add: ";
  var_dump($retVal->addCustomerResponse);
  echo "</br>";
  
  $retVal = $client->getCustomer();
		
  echo "Returned from Get: ";
		print_r($retVal->getCustomerResponse);
  echo "</br>";

These var_dumps don't give me the appropriate data. They end up returning NULL instead. I know it's not the service because I get the right results on the test WCF client.

Am I accessing these functions incorrectly?

Also, I was told to use basicHttpBinding with SOAP. Is this a bad thing? Can wsHttpBinding be used instead?

Thanks in advance!