Click here to Skip to main content
15,895,799 members
Articles / Programming Languages / C#

WebService Authentication with UsernameToken in WSE 3.0

Rate me:
Please Sign up or sign in to vote.
4.75/5 (20 votes)
12 Jul 20075 min read 282K   3.8K   78  
Passing a username and password as plain text
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;

// 
// This source code was auto-generated by wsdl, Version=2.0.50727.42.
// 


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="ServiceSoap", Namespace="http://tempuri.org/")]
public partial class Service : Microsoft.Web.Services3.WebServicesClientProtocol {
    
    private System.Threading.SendOrPostCallback HelloMyFriendOperationCompleted;
    
    /// <remarks/>
    public Service() {
        this.Url = "http://localhost:1515/WebService/Service.asmx";
    }
    
    /// <remarks/>
    public event HelloMyFriendCompletedEventHandler HelloMyFriendCompleted;
    
    /// <remarks/>
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/HelloMyFriend", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public string HelloMyFriend() {
        object[] results = this.Invoke("HelloMyFriend", new object[0]);
        return ((string)(results[0]));
    }
    
    /// <remarks/>
    public System.IAsyncResult BeginHelloMyFriend(System.AsyncCallback callback, object asyncState) {
        return this.BeginInvoke("HelloMyFriend", new object[0], callback, asyncState);
    }
    
    /// <remarks/>
    public string EndHelloMyFriend(System.IAsyncResult asyncResult) {
        object[] results = this.EndInvoke(asyncResult);
        return ((string)(results[0]));
    }
    
    /// <remarks/>
    public void HelloMyFriendAsync() {
        this.HelloMyFriendAsync(null);
    }
    
    /// <remarks/>
    public void HelloMyFriendAsync(object userState) {
        if ((this.HelloMyFriendOperationCompleted == null)) {
            this.HelloMyFriendOperationCompleted = new System.Threading.SendOrPostCallback(this.OnHelloMyFriendOperationCompleted);
        }
        this.InvokeAsync("HelloMyFriend", new object[0], this.HelloMyFriendOperationCompleted, userState);
    }
    
    private void OnHelloMyFriendOperationCompleted(object arg) {
        if ((this.HelloMyFriendCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.HelloMyFriendCompleted(this, new HelloMyFriendCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }
    
    /// <remarks/>
    public new void CancelAsync(object userState) {
        base.CancelAsync(userState);
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
public delegate void HelloMyFriendCompletedEventHandler(object sender, HelloMyFriendCompletedEventArgs e);

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class HelloMyFriendCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
    
    private object[] results;
    
    internal HelloMyFriendCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
            base(exception, cancelled, userState) {
        this.results = results;
    }
    
    /// <remarks/>
    public string Result {
        get {
            this.RaiseExceptionIfNecessary();
            return ((string)(this.results[0]));
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions