扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:甘冀平 来源:yesky 2007年11月17日
关键字: 软件
http://localhost/horoservice/wshoro.asmx |
WebServiceUtil /c:proxy /pa:http://localhost/csharp_test/oroscope/wshoro.asmx?SDL /n:horo_service |
csc /target:library /r:System.dll;System.Web.Services.dll;System.Net.dll; System.IO.dll;System.Xml.Serialization.dll DailyHoro.cs |
<%@ Import namespace="System" %> <%@ Import namespace="horo_service" %> <%@ Page Language="C#" %> |
<html> <head> <script language="C#" runat="server"> private void gethoro_Click(object sender, EventArgs e) { file://Get the Selected Item from the DropDownList string sign = zodiac.SelectedItem.Text; file://Create a Instance of the Proxy Class DailyHoro dh = new DailyHoro(); file://Call the "GetHoro" method of the Web Service on the file://Proxy Object. The Proxy object in turn communicates file://to the Web Service. Remember the Proxy cannot do file://anything except act as a bridge between. Your Web file://Service and the client. It cannot replace the Web file://Service. string result =dh.GetHoro(sign); file://Extract the Date from the Result preddate.InnerHtml = "<b> Horoscope for " + sign + " as on " + result.Substring(0,10) + "</b>"; file://Display the Prediction predspace.InnerHtml=result.Substring(11); } </script> <title>Horoscope Service Client</title> </head> |
<body> <center> <form runat="server" > <table border="1" width="60%" cellpadding="1" cellspacing="2"> <tr> <td colspan=2> <b> Select your Zodiac Sign</b></th> </tr> <tr> <td> <asp:DropDownList id="zodiac" runat="server"> <asp:ListItem>aquarius</asp:ListItem> <asp:ListItem>pisces</asp:ListItem> <asp:ListItem>aries</asp:ListItem> <asp:ListItem>taurus</asp:ListItem> <asp:ListItem>gemini</asp:ListItem> <asp:ListItem>cancer</asp:ListItem> <asp:ListItem>leo</asp:ListItem> <asp:ListItem>virgo</asp:ListItem> <asp:ListItem>libra</asp:ListItem> <asp:ListItem>scorpio</asp:ListItem> <asp:ListItem>capricorn</asp:ListItem> <asp:ListItem>sagittarius</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td colspan="2" > <asp:Button onClick="gethoro_Click" Text="Fetch !" runat="server" /></td> </tr> <tr> <td colspan="2"><div id="preddate" runat="server" /> </td> </tr> <tr> <td colspan="2"><div id="predspace" runat="server" /> </td> </tr> </table> </form> </center> </body> </html> |
/* Compilation csc /r:System.dll;System.Web.Services.dll;DailyHoro.dll HoroClient,cs */ using System ; using horo_service ; file://A class which consumes the Web Service public class HoroClient { public static void Main(string[] argv) { Console.WriteLine("Welcome to Horoscope Client"); Console.Write("Enter you Zodiac Sign:"); file://Read the Input from the user string sign = Console.ReadLine(); file://Create a instance of the Proxy Class DailyHoro dh = new DailyHoro(); file://Make a Call on the Web Service Method "GetHoro" and file://pass the Zodiac sign to it string result = dh.GetHoro(sign); Console.WriteLine("Horoscope for "+sign+" on " + result.Substring(0,10)); file://Print the Prediction Console.WriteLine(result.Substring(11)); Console.WriteLine("Press Enter to Exit"); Console.ReadLine(); } } |
csc /r:System.dll;System.Web.Services.dll;DailyHoro.dll HoroClient,cs |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者