在浏览器中通过URL访问时找不到端点 [英] Endpoint not found when accessing via URL in a browser

查看:189
本文介绍了在浏览器中通过URL访问时找不到端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入服务地址后,我将看到WSDL文件.但是,当我在URL中添加后缀时,出现错误消息:找不到端点".肯定是由于我的服务模型声明有问题,但是几个小时后,我倾向于承认它超出了我的范围.

When I enter the address of my service, I get to see the WSDL file. However, When I add a suffix to the URL, I get the error message: "endpoint not found". It's definitely due to something wrong with my service model declaration but after a few hours, I'm inclined to admit that it's beyond me.

我已确保按照此处讨论的那样正确命名空间.

第一个URL有效.另一个,不要.

The first URL works. The other, don't.

http://---.azurewebsites.net/MyService.svc/
http://---.azurewebsites.net/MyService.svc/Ping
http://---.azurewebsites.net/MyService.svc/Ping/(如建议在​​此处)

http://---.azurewebsites.net/MyService.svc/
http://---.azurewebsites.net/MyService.svc/Ping
http://---.azurewebsites.net/MyService.svc/Ping/ (as suggested here)

行为中,我声明了两种行为-一种是针对端点的行为,另一种是针对服务的行为.

In behaviors I've declared two behaviors - one for the end point and one for the service.

<behaviors>
  <endpointBehaviors>
    <behavior name="PingEndPointBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name ="PingServiceBehavior">
      <serviceMetadata httpGetEnabled="true"
                       httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true"
                       httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

我声明了以下绑定,以便通过浏览器中的URL行进行访问.

I declared the following binding for access via URL line in the browser.

<bindings>
  <webHttpBinding></webHttpBinding>
</bindings>

服务中,我声明了两个端点(我也只对第一个端点进行了测试).

In services I declared two end points (I tested with only the first one, as well).

<service name="MyProject.MyService"
         behaviorConfiguration="PingServiceBehavior">
  <endpoint name="PingEndPoint"
            behaviorConfiguration="PingEndPointBehavior"
            address="Ping"
            binding="webHttpBinding"
            contract="MyProject.IMyService"/>
  <endpoint contract="IMetadataExchange" 
            binding="mexHttpBinding" 
            address="mex" />
</service>

我的配置文件中还包含以下内容.怀疑它的重要性,但是却永远不知道.

I also have the following in my config file. Doubtful of its significance, but one never knows.

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
                           multipleSiteBindingsEnabled="true"/>

推荐答案

我已经解决了该问题.显然,子目录的虚拟路径是累积的,因此公开的服务一直存在,但位于以下地址.

I've resolved the issue. Apparently, the virtual path of sub-directories is cumulative, so the exposed service was there all along but at the following address.

http://---.azurewebsites.net/MyService.svc/Ping/Ping

一个ping级别来自配置文件,另一个来自于装饰该方法的接口的属性中的模板URI.

One ping level comes from the config file while the other from the template URI in the attribute that decorates the interface for the method.

这篇关于在浏览器中通过URL访问时找不到端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆