Home >Backend Development >PHP Tutorial >C# Web Service communication example using PHP server_PHP tutorial
Note: In this example, the SOAP method is used to build the Web Service, and the SOAP server is built through the php plug-in NuSoap.
$server = new soap_server(); //Create soap server
$server->configureWSDL("login_service"); //Configure WSDL
$namespace = "http://www.abcd9 .com";
$server->wsdl->schemaTargetNamespace = $namespace; //Set the wsdl namespace to http://www.abcd9.com
$server->register( // Register Web service
'login_verifiy', //Define name
array('name'=>'xsd:string','pw'=>'xsd:string'), //Accept parameters
array('return'=>'xsd:string'), //Return
. or document
'encoded', // Parameters: encoded or literal
'A web method of login' //Description
);
$POST_DATA = isset($GLOBALS ['HTTP_RAW_POST_DATA'])? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
function login_verifiy($user,$pw) { //Service execution content, in this example, the entered account password is displayed
return 'user:'.$user.' password:'.$pw);
}?>
C# client call:
Copy code
//Get the webservice url by reading the config.ini configuration file (see additional content for the structure)
Program.server_url = temp.ToString(); //The global variable server_url in Program.cs is used to store the webservice url
}
private void button1_Click(object sender, EventArgs e)
{
WebReference.login_service l = new WebReference.login_service();
string s=l.login_verifiy(username.Text, password.Text);
MessageBox.Show(s);
www.bkjia.com