C # uses a PHP server-side Web service communication instance

Source: Internet
Author: User
Tags config ini int size soap php server read ini file wsdl

  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/ 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.