#眉標=Windows Mobile、Web Services、MCSF #副標=Windows Mobile開發系列(11) #大標=行動裝置應用程式資料交換 #作者=文/圖 沈炳宏 ============= 程式1 [WebMethod] public string TestAuth() { return "歡迎 " + System.Threading.Thread. CurrentPrincipal.Identity.Name; } ================ ============= 程式2 private void button1_Click( object sender, System.EventArgs e) { RUNPCWebService ws = new RUNPCWebService (); NetworkCredential nc = new NetworkCredential( UsernameTextBox.Text, PasswordTextBox.Text); ws.Credentials = creds; ResponseLabel.Text = ws.TestAuth (); ================ ============= 程式3 public class AuthHeader : SoapHeader { public string Username; public string Password; } public class SOAPheaderService : System.Web.Services.WebService { public AuthHeader AuthToken; [WebMethod] [SoapHeader("AuthToken", Direction=SoapHeaderDirection.In)] public bool Authenticate() { if (AuthToken.Username == "runpc" & AuthToken.Password == "test") return true; else return false; } ================ ============= 程式4