Visual studio 2012 创建web service

来源:互联网 发布:知乎马上上和丁芙妮 编辑:程序博客网 时间:2024/06/07 11:34



创建步骤



1. File -> New -> Web Site -> ASP.NET Empty Web Site


创建完成之后, 只有Web.config 和Web.Debug.config 两个文件





2. 添加 "Web Service"
选中当前Project --> 右键单击Add --> New Item, 选择Web Service





3. 点击之后 产生WebService.cs 和WebService.asmx两个文件


4. 因为Visual studio 2012 , 安装有 IIS Express 的Web 服务器, 直接按 "F5" 键执行结果。



5. 直接点击 HelloWorld 进去



点击Invoke 就可以执行这个Web Service 的方法了。


其他:
    Visual Stuido 内置的IIS服务器只能使用 localhost 这样的访问, 类似http://localhost:52183/webservice/WebService.asmx?op=HelloWorld
如果要在其他机器上也能访问到的话, 可以到当前机器登录用户的 \Documents\IISExpress\config 目录下修改  applicationhost.config 文件
            <site name="WebSite1" id="1" serverAutoStart="true">
                <application path="/">
                    <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation=":8080:localhost" />
                </bindings>
            </site>
加上IP 信息
 <binding protocol="http" bindingInformation=":8080:IP" />
0 0
原创粉丝点击