This article mainly introduces C # using PHP server-side Web service communication examples, need friends can refer to the following
Note: In this example, the Web service is constructed using a SOAP method, which is used to build the SOAP server through the PHP plug-in nusoap. Code is as follows: Require_once ("lib/nusoap.php"); Call Nusoap $server = new Soap_server (); Create SOAP Service End $server->configurewsdl ("Login_service"); Configure WSDL $namespace = "http://www.abcd9.com"; $server->wsdl->schematargetnamespace = $namespace; Set WSDL namespace for http://www.abcd9.com $server->register (//Registration Web service ' login_verifiy ',//definition name & nbsp Array (' name ' => ' xsd:string ', ' pw ' => ' xsd:string '), //accept parameters & nbsp Array (' Return ' => ' xsd:string '), //back $namespace,//Name space FA LSE,//SOAPAction: Default ' RPC ',//type: RPC or document ' encoded ',// Parameters: encoded (encoded) or literal (text) ' A Web method of login '/description); $POST _data = isset ($GLOBALS [' http_raw_post_data '])? $GLOBALS [' Http_raw_post_data ']: "; $server->service ($POST _data); Deliver the submitted data to the SOAP service function login_verifiy ($user, $PW) {//service execution, which displays the password return ' User: '. $user. ' Password: '. $PW); ?> C # client calls: code as follows: [DllImport ("kernel32")]//Call API function to read INI file. The return value is the length of the string buffer private static extern long GetPrivateProfileString (string section, String key, String Def, StringBuilder ret Val, int size, string filePath); private void Form1_Load (object sender, EventArgs e) { StringBuilder temp = new StringBuilder (256); &N Bsp GetPrivateProfileString ("System", "url", NULL, TEMP, 256, System.IO.Directory.GetCurrentDirectory () + " Config.ini "); //To obtain WebService URL Program.server_url = temp by reading the Config.ini configuration file (structure see additional content). ToString (); The global variable Server_url in Program.cs is used to store webservice URL} private void Button1_Click (object sender, EventArgs e) { &N Bsp Webreference.login_service L = new Webreference.login_service (); String s=l.login_verifiy (username. Text, password. Text); MessageBox.Show (s); attached config.ini content: Code is as follows: [System] url=http://127.0.0.1:100/