I would like to call C# service with using PHP, anyone know how to do it? Thanks
Create an SOAP XML document that matches up with the WSDL and send it via HTTP POST. See here for an example.
You send this:
POST /webservices/tempconvert.asmx HTTP/1.1
Host: www.w3schools.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CelsiusToFahrenheit xmlns="http://tempuri.org/">
<Celsius>string</Celsius>
</CelsiusToFahrenheit>
</soap12:Body>
</soap12:Envelope>
And get this back:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CelsiusToFahrenheitResponse xmlns="http://tempuri.org/">
<CelsiusToFahrenheitResult>string</CelsiusToFahrenheitResult>
</CelsiusToFahrenheitResponse>
</soap12:Body>
</soap12:Envelope>
I've never done it in PHP->C#, I've used C# to call PHP webservices and I've always used the Zend Framework wrapper for native PHP classes. You should check out the Zend_Soap_Client which, if it's like the Zend_Soap_Server, is just a wrapper with some value added stuff around the PHP SOAP classes.
And, I should say, all it does is wrap up what @Josh said into a nice class and does some things automatically for you.
There's no thing called a "C# Web Service". What you mean is an XML Web Service based on SOAP remote calls and WSDL for description.
Indeed all SOAP services are supposed to be inter compatible, be it .Net, PHP or Java. But in practice, minor problems make it harder.
There are many different SOAP libraries for PHP, but for connection to an ASP.NET XML Web Service from PHP, but nuSOAP gave the best results for me. It's basicly a set of PHP-classes to consume SOAP-based web services. The simplest client code seems like this:
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/phphack/helloworld.php');
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));
// Display the result
print_r($result);
?>
See http://www.scottnichol.com/nusoapintro.htm for more examples.