<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>WebService</title><link>http://blog.blueshop.com.tw/swtnwr/category/1974.aspx</link><description>WebService</description><managingEditor>馬小玲</managingEditor><dc:language>zh-CHT</dc:language><generator>.Text Version 0.95.2004.101</generator><item><dc:creator>馬小玲</dc:creator><title>WebService基礎</title><link>http://blog.blueshop.com.tw/swtnwr/archive/2007/05/18/50933.aspx</link><pubDate>Fri, 18 May 2007 00:04:00 GMT</pubDate><guid>http://blog.blueshop.com.tw/swtnwr/archive/2007/05/18/50933.aspx</guid><wfw:comment>http://blog.blueshop.com.tw/swtnwr/comments/50933.aspx</wfw:comment><comments>http://blog.blueshop.com.tw/swtnwr/archive/2007/05/18/50933.aspx#Feedback</comments><slash:comments>9</slash:comments><wfw:commentRss>http://blog.blueshop.com.tw/swtnwr/comments/commentRss/50933.aspx</wfw:commentRss><trackback:ping>http://blog.blueshop.com.tw/swtnwr/services/trackbacks/50933.aspx</trackback:ping><description>&lt;P&gt;我直接講要怎麼用好了(講原理、觀念我也不懂= =")&lt;/P&gt;
&lt;P&gt;1.開vs2005&amp;nbsp; -&amp;nbsp; 建立一個新的網站&amp;nbsp; -&amp;nbsp; 選Asp.net Web服務&lt;/P&gt;
&lt;P&gt;2.在AppCode裡面Service.cs中&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;TEXTAREA class=c# name=code rows=6 cols=50&gt;using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
    public Service () {

        //如果使用設計的元件，請取消註解下行程式碼 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    
}&lt;/TEXTAREA&gt;&lt;/P&gt;
&lt;P&gt;HelloWorld是它預設的一個方法而已，在這裡就可以靈活運用了，可以寫要用的類別在這裡。&lt;/P&gt;
&lt;P&gt;3.寫完後存檔&amp;nbsp; ok啦&lt;/P&gt;
&lt;P&gt;之後再開一個新的網站&amp;nbsp; -&amp;nbsp; 建立一個原始標準的Asp.net網站&lt;/P&gt;
&lt;P&gt;4.點選上方選單中的網站&amp;nbsp; -&amp;nbsp; 加入Web參考&lt;/P&gt;
&lt;P&gt;5.在URL上打剛剛一開始建的WebService的路徑，如(&lt;A href="http://192.168.1.176/WebServiceSample/Service.asmx"&gt;http://192.168.1.176/WebServiceSample/Service.asmx&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;6.右邊中間Web參考名稱打上你想命名的名稱，假設打&lt;FONT color=#ff0000&gt;localhost&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#000000&gt;按加入參考&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;7.加進去後new起來就可以用啦&lt;/P&gt;
&lt;P&gt;&lt;TEXTAREA class=c# style="WIDTH: 422px; HEIGHT: 107px" name=code rows=6 cols=50&gt; localhost.Service x = new localhost.Service();
        Label1.Text = x.HelloWorld();&lt;/TEXTAREA&gt;&lt;/P&gt;
&lt;P&gt;這樣以後任何專案要用到共同的類別，就很方便啦 ，不用每次類別一新增，就要包一次dll檔，然後copy覆蓋= ="&lt;/P&gt;&lt;img src ="http://blog.blueshop.com.tw/swtnwr/aggbug/50933.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>