WCF学习随笔3--第一个Sample--祭斧_AX
第一次是鼠标问题,单击经常变双击,在Maxthon的标签栏切换的时候关了,Alt+Z也没能挽回.
罗技鼠里也有垃圾,还300+大洋的...
第二次是看别的网页弹出个窗口,点了个"否",Maxthon就关了...
【总结】世界是未知的,不可预测的,变幻莫测的.
做事情要一心一意,备份总是有好处的.
OK, Let's go to the first sample!
以IIS6.0为宿主,ASP.NET为客户端进行演示.
网站属性设置为可运行Script,否则服务不能打开.如安装了ASP.NET1.1,则网站默认为1.1,要改为2.0
Ⅱ.打开VS2008,新建一个WCF项目,命名为:WcfService_AX
Ⅲ.在Solution Explorer窗口中右键项目→Publish
Ⅳ.在弹出窗口中输入Target Location:http://localhost:1212 点击Publish.
Ⅴ.打开IE,输入地址:http://localhost:1212/Service1.svc
如出现下面信息,说明发布成功.
You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe http://*****:1212/Service1.svc?wsdl
This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:
不要惊讶,确实发布成功了,虽然一行代码也没有写过,因为在创建项目时已经自动创建了一个服务.以后再深入讲解.
Ⅱ.在Solution Explorer窗口右键项目→Add Service Reference.
Ⅲ.在Address处输入:http://localhost:1212/Service1.svc 点击"Go".
几秒后就会搜索到服务,点击OK.
Ⅳ.在Default.aspx.cs里输入以下两行代码.
{
//创建一个Service1的代理
ServiceReference1.IService1 service = new ServiceReference1.Service1Client();
//使用代理
Response.Write(service.GetData(1212));
}
Ⅴ.F5运行.
如出现打开页面显示:【You entered: 1212 】,说明服务调用成功!
少帮主的斧头好久不饮血了!