reference.jsl

来自「vs 2005 中 用的 vb 示例 程序,测试运行良好,对初学者有一定参考价值」· JSL 代码 · 共 155 行

JSL
155
字号
/*******************************************************************************
 *
 *     This code was generated by a tool.
 *     Runtime Version: 2.0.50215.17
 *
 *     Changes to this file may cause incorrect behavior and will be lost if 
 *     the code is regenerated.
 *
 ******************************************************************************/

// 
// This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50215.17.
// 
package Microsoft.Samples.Windows.Forms.EventBasedAsync.SimpleWebServices;
import System.Diagnostics.*;
import System.Web.Services.*;
import System.ComponentModel.*;
import System.Web.Services.Protocols.*;
import System.*;
import System.Xml.Serialization.*;


/** <remarks/> */
/** @attribute System.Diagnostics.DebuggerStepThroughAttribute()*/
/** @attribute System.ComponentModel.DesignerCategoryAttribute("code")*/
/** @attribute System.Web.Services.WebServiceBindingAttribute(Name="SimpleWebServiceSoap", Namespace="http://localhost/samplewebservices/")*/
public class SimpleWebService extends System.Web.Services.Protocols.SoapHttpClientProtocol {
    
    private System.Threading.SendOrPostCallback GetAnswerOperationCompleted;
    
    private boolean useDefaultCredentialsSetExplicitly;
    
    /** <remarks/> */
    public SimpleWebService() {
		this.set_Url(Microsoft.Samples.Windows.Forms.EventBasedAsync.Properties.Settings.get_Default().get_EventBasedAsyncSampleJSL_SimpleWebServices_SimpleWebService());
        	
		if ((this.IsLocalFileSystemWebService(this.get_Url()) == true)) {
            this.set_UseDefaultCredentials(true);
            this.useDefaultCredentialsSetExplicitly = false;
        }
        else {
            this.useDefaultCredentialsSetExplicitly = true;
        }
    }
    
    /** @property */
    public String get_Url() {
        return super.get_Url();
    }
    /** @property */
    public void set_Url(String value) {
        if ((((this.IsLocalFileSystemWebService(super.get_Url()) == true) 
                    && (this.useDefaultCredentialsSetExplicitly == false)) 
                    && (this.IsLocalFileSystemWebService(value) == false))) {
            super.set_UseDefaultCredentials(false);
        }
        super.set_Url(value);
    }
    
    /** @property */
    public boolean get_UseDefaultCredentials() {
        return super.get_UseDefaultCredentials();
    }
    /** @property */
    public void set_UseDefaultCredentials(boolean value) {
        super.set_UseDefaultCredentials(value);
        this.useDefaultCredentialsSetExplicitly = true;
    }
    
    /** <remarks/> */
    private GetAnswerCompletedEventHandler GetAnswerCompleted;
    
    /** @event */
    public  void add_GetAnswerCompleted(GetAnswerCompletedEventHandler e) {
        this.GetAnswerCompleted = (GetAnswerCompletedEventHandler)System.Delegate.Combine(this.GetAnswerCompleted,e);
    }
    
    /** @event */
    public  void remove_GetAnswerCompleted(GetAnswerCompletedEventHandler e) {
        this.GetAnswerCompleted = (GetAnswerCompletedEventHandler)System.Delegate.Remove(this.GetAnswerCompleted,e);
    }
    
    /** <remarks/> */
    /** @attribute System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/samplewebservices/GetAnswer", RequestNamespace="http://localhost/samplewebservices/", ResponseNamespace="http://localhost/samplewebservices/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)*/
    public String GetAnswer(String question) {
        Object[] results = this.Invoke("GetAnswer", new Object[] {
                    question}
        );
        return ((String)(results[0]));
    }
    
    /** <remarks/> */
    public void GetAnswerAsync(String question) {
        this.GetAnswerAsync(question, null);
    }
    
    /** <remarks/> */
    public void GetAnswerAsync(String question, Object userState) {
        if ((this.GetAnswerOperationCompleted == null)) {
            this.GetAnswerOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetAnswerOperationCompleted);
        }
        this.InvokeAsync("GetAnswer", new Object[] {
                    question}
            , this.GetAnswerOperationCompleted, userState);
    }
    
    private void OnGetAnswerOperationCompleted(Object arg) {
        if ((this.GetAnswerCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.GetAnswerCompleted.Invoke(this, new GetAnswerCompletedEventArgs(invokeArgs.get_Results(), invokeArgs.get_Error(), invokeArgs.get_Cancelled(), invokeArgs.get_UserState()));
        }
    }
    
    /** <remarks/> */
    public void CancelAsync(Object userState) {
        super.CancelAsync(userState);
    }
    
    private boolean IsLocalFileSystemWebService(String url) {
        if (((url == null) 
                    || (url == String.Empty))) {
            return false;
        }
        System.Uri wsUri = new System.Uri(url);
        if ((((wsUri.get_Port() >= 1024) 
                    && (wsUri.get_Port() <= 5000)) 
                    && (System.String.Compare(wsUri.get_Host(), "localHost", true) == 0))) {
            return true;
        }
        return false;
    }
}

/** <remarks/> */
/** @delegate */
public delegate void GetAnswerCompletedEventHandler(Object sender, GetAnswerCompletedEventArgs e);

/** <remarks/> */
public class GetAnswerCompletedEventArgs extends System.ComponentModel.AsyncCompletedEventArgs {
    
    private Object[] results;
    
    GetAnswerCompletedEventArgs(Object[] results, System.Exception exception, boolean cancelled, Object userState) {
        super(exception, cancelled, userState);
        this.results = results;
    }
    
    /** <remarks/> */
    /** @property */
    public String get_Result() {
        this.RaiseExceptionIfNecessary();
        return ((String)(this.results[0]));
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?