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.
Copy Code code as follows:
?
Require_once ("lib/nusoap.php"); Call Nusoap
$server = new Soap_server (); To create a SOAP service side
$server->configurewsdl ("Login_service"); Configuring WSDL
$namespace = "http://www.abcd9.com";
$server->wsdl->schematargetnamespace = $namespace; Set WSDL namespace to http://www.abcd9.com
$server->register (//Registration of Web services
' Login_verifiy ',//definition name
Array (' name ' => ' xsd:string ', ' pw ' => ' xsd:string '),//Accept Parameters
Array (' Return ' => ' xsd:string '),//back
$namespace,//namespaces
False,//SOAPAction: Default
' RPC ',//type: RPC or document
' encoded ',//parameter: encoded (encoded) or literal (text)
' A Web method ' login '/description
);
$POST _data = isset ($GLOBALS [' http_raw_post_data '])? $GLOBALS [' Http_raw_post_data ']: ';
$server->service ($POST _data); Delivery of submitted data to the SOAP service
function Login_verifiy ($user, $PW) {//service execution, in this example, displays the password for the account entered
Return ' User: '. $user. ' Password: '. $PW);
}
?>
C # Client Invocation:
Copy Code 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 retVal, int size, String filePath);
private void Form1_Load (object sender, EventArgs e)
{
StringBuilder temp = new StringBuilder (256);
GetPrivateProfileString ("System", "url", NULL, TEMP, 256, System.IO.Directory.GetCurrentDirectory () + "\\config.ini") ;
Get WebService URL by reading config.ini configuration file (structure see additional content)
Program.server_url = temp. ToString (); Global variable Server_url in Program.cs to store WebService URLs
}
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 Code code as follows:
[System]
Url=http://127.0.0.1:100/