建设项目环境影响网站,七台河新闻联播视频,周口网站制作哪家好,网站制作费用明细环境#xff1a; vs版本#xff1a;vs2013 windows版本#xff1a;win7 IIS版本#xff1a;IIS7.0 #xff08;如果觉得对您有用#xff0c;请点击右下角【推荐】一下#xff0c;让更多人看到#xff0c;谢谢#xff09; 配置环境#xff1a; 主要针对于IIS 首先 vs版本vs2013 windows版本win7 IIS版本IIS7.0 如果觉得对您有用请点击右下角【推荐】一下让更多人看到谢谢 配置环境 主要针对于IIS ·首先有很多人的机器上都没有打开IIS服务 控制面板-程序和功能-打开或关闭windows功能(左侧较慢稍等)-Internet信息服务(默认打开的功能不能完全满足之后的需要可以全部打开或者网上查询一下需要打开哪些) ·接着在管理工具中打开Internet 信息服务(IIS)管理器 ·最后在网页上输入http://127.0.0.1后能看到IIS的主页就ok了。这里隐藏了一个问题就是先安装了framework后安装IIS会有一个问题稍后解决 防火墙配置如不配置在其他机器上访问不到发布在你机器上的服务接口或者其他网站 网上有说直接关了防火墙就好比人家惹到你你非得整死他一样。。。好惨 打开防火墙点击左侧菜单里面的“高级设置”会看到有“入站规则”和“出站规则”添加一个入站规则端口就好了这样你在下面的流程中配置的那个端口在其他位置访问你机器上的这个端口的时候就不会被拦住了...何必置人于死地呢 实现过程之编写WebService 我使用的是vs2013过程如下 1、创建空解决方案 2、创建空Web应用程序工程这里面没有web服务工程... 3、创建Web服务asmx 这是IDE会给你初始化一个开发框架你只需要在里面加上你需要公开的方法就可以了[WebService]特性的使用就是用来修饰将要公布出来的服务接口。具体原理这里不讲 代码如下 1 using System;2 using System.Collections.Generic;3 using System.Linq;4 using System.Web;5 using System.Web.Services;6 7 namespace WebService8 {9 /// summary
10 /// WebService1 的摘要说明
11 /// /summary
12 [WebService(Namespace http://MrHouJL/WebServices)]
13 [WebServiceBinding(ConformsTo WsiProfiles.BasicProfile1_1)]
14 [System.ComponentModel.ToolboxItem(false)]
15 // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务请取消注释以下行。
16 [System.Web.Script.Services.ScriptService]
17 public class WebService1 : System.Web.Services.WebService
18 {
19
20 [WebMethod]
21 public string HelloWorld(string str)
22 {
23 return Hello World str;
24 }
25 [WebMethod]
26 public string HelloWorld1()
27 {
28 return Hello World 1;
29 }
30 [WebMethod]
31 public string HelloWorld2()
32 {
33 return Hello World 2;
34 }
35 [WebMethod]
36 public string HelloWorld3()
37 {
38 return Hello World 3;
39 }
40 [WebMethod(Description 求和的方法)]
41 public double addition(double i, double j)
42 {
43 return i j;
44 }
45 [WebMethod(Description 求差的方法)]
46 public double subtract(double i, double j)
47 {
48 return i - j;
49 }
50 [WebMethod(Description 求积的方法)]
51 public double multiplication(double i, double j)
52 {
53 return i * j;
54 }
55 [WebMethod(Description 求商的方法)]
56 public double division(double i, double j)
57 {
58 if (j ! 0)
59 return i / j;
60 else
61 return 0;
62 }
63 }
64 } View Code 功能编写完毕接下来就是发布在刚刚准备好的IIS环境上面了。 1、右键点击工程发布选择一个文件夹物理路径。 2、打开IIS管理器 3、右击“网站”添加网站配置“网站名称”“物理路径”“IP”“端口”OK 4、注意这里面的身份验证要允许匿名目录浏览要启用双击点击右侧启用为了之后可以浏览WebService目录 5、运行网站你在浏览器中输入之前输入的IP端口号就能访问到目录了如有问题留言或者度娘。 实现过程之访问WebService 在这里主要是介绍使用后台访问 首先在工程里面右键点击引用添加服务引用输入IP端口点击“转到”应该就能看到之前的所写的服务接口了。起个名就添加进去了。 添加webform界面前台代码如下 1 % Page LanguageC# AutoEventWireuptrue CodeBehindWebForm1.aspx.cs InheritsWebService.WebForm1 %2 3 !DOCTYPE html4 5 html xmlnshttp://www.w3.org/1999/xhtml6 head runatserver7 meta http-equivContent-Type contenttext/html; charsetutf-8/8 title/title9 /head
10 body
11 form idform1 runatserver
12 div
13
14 /div
15 asp:TextBox IDTextBox1 runatserver Height15px Width50px/asp:TextBox
16 nbsp;asp:DropDownList IDDropDownList1 runatserver
17 asp:ListItem/asp:ListItem
18 asp:ListItem-/asp:ListItem
19 asp:ListItem*/asp:ListItem
20 asp:ListItem//asp:ListItem
21 /asp:DropDownList
22 nbsp;asp:TextBox IDTextBox2 runatserver Height15px Width50px/asp:TextBox
23 nbsp;asp:Button IDButton1 runatserver OnClickButton1_Click Text /
24 nbsp;asp:TextBox IDTextBox3 runatserver Height15px Width50px/asp:TextBox
25 /form
26 /body
27 /html View Code 后台代码如下 1 using System;2 using System.Collections.Generic;3 using System.Linq;4 using System.Web;5 using System.Web.UI;6 using System.Web.UI.WebControls;7 8 namespace WebService9 {
10 public partial class WebForm1 : System.Web.UI.Page
11 {
12 protected void Page_Load(object sender, EventArgs e)
13 {
14
15 }
16
17 protected void Button1_Click(object sender, EventArgs e)
18 {
19 string oper DropDownList1.Text;
20 double a Convert.ToDouble(TextBox1.Text);
21 double b Convert.ToDouble(TextBox2.Text);
22 ServiceReference1.WebService1SoapClient ws new ServiceReference1.WebService1SoapClient();
23 switch (oper)
24 {
25 case : TextBox3.Text ws.addition(a, b).ToString(); break;
26 case -: TextBox3.Text ws.subtract(a, b).ToString(); break;
27 case *: TextBox3.Text ws.multiplication(a, b).ToString(); break;
28 case /: TextBox3.Text ws.division(a, b).ToString(); break;
29 default:
30 break;
31 }
32 Response.Write(ws.HelloWorld(TextBox3.Text));
33 }
34 }
35 } View Code 建议各位小主还是自己写写较好。 遇到的问题 HTTP 错误 500.21 - Internal Server Error处理程序“NickLeeCallbackHandler”在其模块列表中有一个错误模块“ManagedPipelineHandler” 原因在安装Framework v4.0之后再启用IIS导致Framework没有完全安装 解决开始-所有程序-附件-鼠标右键点击“命令提示符”-以管理员身份运行-%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i 如果还不行可检查IIS的应用程序池是否使用集成模式如果不是则改成集成模式 至此整个webservice入门就告一段落了大家仅作参考如有问题快来指正...转载于:https://www.cnblogs.com/HJL-Blog/p/4210565.html