C # using the PHP server-side Web Service Communication Instance _php tutorial

Source: Internet
Author: User
Tags php server read ini file
Note: In this example, the build Web service uses SOAP to build the SOAP server through the PHP plugin nusoap.
Copy CodeThe code is as follows:
Require_once ("lib/nusoap.php"); Call Nusoap

$server = new Soap_server (); Creating a SOAP service side
$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 (//Registration Web Service
' Login_verifiy ',//definition name
Array (' name ' = ' xsd:string ', ' pw ' = ' xsd:string '),//Accept Parameters
Array (' return ' = ' xsd:string '),//return
$namespace,//namespace
False,//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); Passing submitted data to the SOAP service

function Login_verifiy ($user, $PW) {//Service execution content, this example shows the password of the account entered
Return ' User: ' $user. ' Password: '. $PW);
}
?>

C # Client Invocation:
Copy the Code code as follows:
[DllImport ("kernel32")]//Call API function 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 retVal, int size, String filePath);

private void Form1_Load (object sender, EventArgs e)
{
StringBuilder temp = new StringBuilder (256);
GetPrivateProfileString ("System", "url", NULL, temp, System.IO.Directory.GetCurrentDirectory, () + "\\config.ini") ;

Get the WebService URL by reading the Config.ini configuration file (see Structure for additional content)
Program.server_url = temp. ToString (); Global variable Server_url in Program.cs to store 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);
}
Attached Config.ini content:
Copy the Code code as follows:
[System]
Url=http://127.0.0.1:100/

http://www.bkjia.com/PHPjc/750858.html www.bkjia.com true http://www.bkjia.com/PHPjc/750858.html techarticle Note: In this example, the build Web service uses SOAP to build the SOAP server through the PHP plugin nusoap. Copy the code code as follows:? Require_once ("lib/nusoap.php"); Call Nusoap $serve ...

  • 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.