Recently I wrote a php soap server that can call the PHP client, but cannot call the c # client. After reading the manual, I have not accessed it for a long time, finally, I tried NuSOAP.
An open-source project on SF.net has good results, and Eacy implements the required functions.
C # web Services (server) are very easy to implement, and C # client calls are also very convenient.
The web server of PHP generally generates a. wsdl file, which is a service provided by an Xml file description.
Let's take a look at my first PHP web service.
<? Php
/**
* ProcessSimpleType method
* @ Param string $ who name of the person we'll say hello
* @ Return string $ helloText the hello string
*/
Function ProcessSimpleType ($ who ){
Return "Hello $ who, welcome to http://www.my400800.cn ";";
}
?>
Remember to download nusoaphttp: // www.bkjia.com/uploadfile/2011/0825/20110825031745407.zip
<? Php
Require_once ("lib/nusoap. php ");
$ Namespace = "http://www.my400800.cn ";
// Create a new soap server
$ Server = new soap_server ();
// Configure our WSDL
$ Server-> configureWSDL ("SimpleService ");
// Set our namespace
$ Server-> wsdl-> schemaTargetNamespace = $ namespace;
// Register our WebMethod
$ Server-> register (
// Method name:
'Processsimpletype ',
// Parameter list:
Array ('name' => 'xsd: string '),
// Return value (s ):
Array ('Return '=> 'xsd: string '),
// Namespace:
$ Namespace,
// Soapaction: (use default)
False,
// Style. rpc or document
'Rpc ',
// Use: encoded or literal
'Encoded ',
// Description: documentation for the method
'A simple Hello World web method ');
// Get our posted data if the service is being consumed
// Otherwise leave this data blank.
$ POST_DATA = isset ($ GLOBALS ['HTTP _ RAW_POST_DATA '])? $ GLOBALS ['HTTP _ RAW_POST_DATA ']: '';
// Pass our posted data (or nothing) to the soap service
$ Server-> service ($ POST_DATA );
Exit ();
?>
You can use it after writing it.
Open. net and add reference
Click "wsdl" next to view the provided services, as shown in figure
C # Call Code
Private void button#click (object sender, EventArgs e ){
SimpleService svc = new SimpleService ();
String s = svc. ProcessSimpleType ("400 phone VIP user ");
MessageBox. Show (s );
}
Result