簡體   English   中英

從Web服務調用腳本

[英]Calling a script from a web service

如何在Web服務中調用此腳本? 我已經建立了鏈接,我只需要指向正確方向的代碼即可,因為我之前從未對Web服務做過任何事情。

namespace WebServiceTranslator
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        private Dictionary<string, string> _dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); 

            protected void Page_Load(object sender, EventArgs e)
            {
                using (var reader = new StreamReader(File.OpenRead(@"C:/dictionary.csv")))
                {
                    while (!reader.EndOfStream)
                    {
                        string[] tokens = reader.ReadLine().Split(';');
                        _dictionary[tokens[0]] = tokens[1];
                    }
                }
            }


            public string Translate(string input)
            {
                string output;
                if (_dictionary.TryGetValue(input, out output))
                    return output;
                throw new Exception("There is no meaning for this");
            }


    }
}

您應該研究基本的Web服務操作方法。

簡而言之,您的Web服務最終將在“ URL”上運行。 從代碼創建對Web服務的服務引用時,您將引用此URL作為服務地址。 然后,您可以調用Web服務上公開的方法(即,通過一種方法調用應在Web服務中公開的代碼。)

http://support.microsoft.com/kb/301273

您的Web服務公開方法,並以單獨/遠程的形式創建對該Web服務的引用,並通過該引用調用其方法。

右鍵單擊您的項目,然后選擇“添加服務引用”,以創建對Web服務的引用。 您指定有關Web服務位置的詳細信息,並獲得對該Web服務的引用。

Dim myWebService as new WebserviceReferenceAdded
myWebService.<method>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM