服务引用webService出错!

在vs2010+asp.net中,新建了WebService.asmx项,但添加引用时提示“从此地址下载元地出错,请确认办您输入了有效地。”请前辈指导,应该如何解决?小弟先感谢了!




(如果图片显示不全,请点击这个图片:https://i-blog.csdnimg.cn/blog_migrate/c2f448639c786ead0d25029b17b80ae8.jpeg)

详细提示错误如下:

 

 

下载“http://localhost:39495/WebService.asmx”时出错。
请求失败,错误信息为:
--
<html>
    <head>
        <title>分析器错误</title>
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
        </style>
    </head>

    <body bgcolor="white">

            <span><H1>“/”应用程序中的服务器错误。<hr width=100% size=1 color=silver></H1>

            <h2> <i>分析器错误</i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> 说明: </b>在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。
            <br><br>

            <b> 分析器错误消息: </b>未能创建类型“Viewer.WebService”。<br><br>

            <b>源错误:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code><pre>

<font color=red>行 1:  <%@ WebService Language="C#" CodeBehind="WebService.asmx.cs" Class="Viewer.WebService" %>
</font></pre></code>

                  </td>
               </tr>
            </table>

            <br>

            <b> 源文件: </b> /WebService.asmx<b>    行: </b> 1
            <br><br>

            <hr width=100% size=1 color=silver>

            <b>版本信息:</b> Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.272

            </font>

    </body>
</html>
<!-- 
[HttpParseException]: 未能创建类型“Viewer.WebService”。
   在 System.Web.UI.SimpleWebHandlerParser.GetType(String typeName)
   在 System.Web.UI.SimpleWebHandlerParser.GetTypeToCache(Assembly builtAssembly)
   在 System.Web.Compilation.SimpleHandlerBuildProvider.GetGeneratedType(CompilerResults results)
   在 System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results)
   在 System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results)
   在 System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
   在 System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   在 System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   在 System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
   在 System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath)
   在 System.Web.UI.WebServiceParser.GetCompiledType(String inputFile, HttpContext context)
   在 System.Web.Services.Protocols.WebServiceHandlerFactory.GetCompiledType(String url, HttpContext context)
   在 System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
   在 System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
   在 System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   在 System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
--.
元数据包含无法解析的引用:“http://localhost:39495/WebService.asmx”。
接收对 http://localhost:39495/WebService.asmx 的 HTTP 响应时发生错误。这可能是由于服务终结点绑定未使用 HTTP 协议造成的。这还可能是由于服务器中止了 HTTP 请求上下文(可能由于服务关闭)所致。有关详细信息,请参见服务器日志。
基础连接已经关闭: 接收时发生错误。
无法从传输连接中读取数据: 远程主机强迫关闭了一个现有的连接。。
远程主机强迫关闭了一个现有的连接。

如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。

还有一个可能就是创建的时候这个webservice叫service1,然后你重命名了,但是有个地方的名字并没有改为你现在的这个名字WebService,你在当前项目里面搜索service1,你会发现WebService.asmx文件里面有个Class=*****.service1,把这个地方的service1改为WebService就可以了


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值