【问题标题】:WCF returning Endpoint not found on liveWCF 返回端点未在现场找到
【发布时间】:2014-03-03 19:30:37
【问题描述】:

我在共享环境中托管了一个 WCF 服务,其中包含两种不同的方法。一个是返回所需的输出,另一个是端点未找到异常,这是我验证用户的主要方法。

这里描述了场景:

我的 Iservice.cs 如下

[OperationContract]
[WebInvoke(Method="GET", UriTemplate = "Data?Id={id}", ResponseFormat=WebMessageFormat.Json)]
string GetData(string id);

[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "Login?InstId={inst}&UserId={user}&pwd={pwd}", ResponseFormat = WebMessageFormat.Json)]
string Authenticate(string inst, string user, string pwd);

然后通过 DAL 验证用户详细信息,这工作正常。我的网络配置如下:

  <system.serviceModel>
    <!--<serviceHostingEnvironment multipleSiteBindingsEnabled="True" aspNetCompatibilityEnabled="True">
    </serviceHostingEnvironment>-->
    <serviceHostingEnvironment multipleSiteBindingsEnabled="True">
    </serviceHostingEnvironment>
    <services>
      <service name="WCFDemo.Service1">
        <endpoint address="http://www.ekotri.com/Service1.svc" behaviorConfiguration="restfulBehavior"
                  binding="webHttpBinding" listenUri="/" bindingConfiguration="" contract="WCFDemo.IService1">
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://www.ekotri.com" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="restfulBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="restfulBehavior">
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

GetData 工作正常,但 Authenticate 给出端点未找到错误。但它在本地 IIS 上运行良好。

【问题讨论】:

  • 尝试使用this documentation启用帮助页面。如果有任何差异,请检查实时和本地 IIS 上的身份验证设置。
  • 但是我有共享主机计划,那么如何检查实时服务器上的身份验证设置??
  • 您是否尝试将UriTemplate = "Login?InstId={inst}&amp;UserId={user}&amp;pwd={pwd}" 更改为UriTemplate = "helloworld?InstId={inst}&amp;UserId={user}&amp;pwd={pwd}" 之类的其他名称。也许有什么东西在你不知情的情况下阻止或修改它。
  • 是的,我确实更改了身份验证关键字和类似的东西,但它没有发生......不知道我卡在哪里????
  • 您是否尝试将 address="" 留空?对我来说是这样的

标签: .net json wcf web-config endpoint


【解决方案1】:

试试这个配置:

<system.serviceModel>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="True" aspNetCompatibilityEnabled="True">
</serviceHostingEnvironment>-->
<serviceHostingEnvironment multipleSiteBindingsEnabled="True">
</serviceHostingEnvironment>
<services>
  <service name="WCFDemo.Service1">
    <endpoint address="rest" behaviorConfiguration="restfulBehavior"
              binding="webHttpBinding" contract="WCFDemo.IService1">
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://www.ekotri.com/Service1.svc" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="restfulBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="restfulBehavior">
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

我已经在 Visual Studio 的默认 WCF 应用程序项目上对其进行了测试,没有任何问题。

【讨论】:

  • 不,兄弟它不起作用....我在尝试您的建议时遇到此错误 在服务 Service1 实施的合同列表中找不到合同名称“IMetadataExchange”。将 ServiceMetadataBehavior 添加到配置文件或直接添加到 ServiceHost 以启用对此合同的支持。
  • 您确定http://www.ekotri.com/Service1.svc 的服务是您在问题中提到的实现Iservice.cs 的服务吗?当我访问 http://www.ekotri.com/Service1.svc?wsdl 时,没有 Authenticate 方法。还是我错过了什么?此外,无论我尝试什么 url,我都会得到 endpoint not found。我认为我们正在调试错误的服务。
  • http://www.ekotri.com/Service1.svc/Data?Id〓2 试试这个......它的工作,它在同一个服务类......但不是身份验证方法...
  • 您是否已从其余端点绑定中删除了 listenUri 属性?另外,您能否在 restfulBehavior 中启用 webhttp 的帮助页面,例如 &lt;webHttp helpEnabled="true" /&gt;?并粘贴您的服务类的定义。
【解决方案2】:

试着像这样改变你的界面

[OperationContract]
 [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "Login/{inst}/{user}/{pwd}",
    BodyStyle = WebMessageBodyStyle.Bare)]
string Authenticate(string inst, string user, string pwd);

把这个配置,

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="customBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="asmx" name="WCFDemo.Service1">
    <endpoint address="basic" binding="basicHttpBinding" name="httpEndPoint" contract="WCFDemo.IService1"/>
    <endpoint address="json" binding="webHttpBinding" behaviorConfiguration="webBehavior" name="webEndPoint" contract="WebApplication1.IService"/>
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
  </service>
</services>
<behaviors>
    <endpointBehaviors>
        <behavior name="webBehavior">
            <webHttp />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
    <behavior name="asmx">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

【讨论】:

    【解决方案3】:

    当您尝试点击登录方法时,您使用的是什么 url?

    根据你的服务文件,你使用的url模板是

    Login?InstId={inst}&UserId={user}&pwd={pwd}
    

    在您的配置文件中,您将其绑定到特定的域/url 路径

    <endpoint address="http://www.ekotri.com/Service1.svc" behaviorConfiguration="restfulBehavior"
                      binding="webHttpBinding" listenUri="/" bindingConfiguration="" contract="WCFDemo.IService1">
    

    根据这两条信息,预期的访问路径是

    http://www.ekotri.com/Service1.svc/Login?InstId={inst}&UserId={user}&pwd={pwd}
    

    如果我使用那个模板 url 并插入一些假值..

    Service Action URL

    此网址返回预期的“False”。

    【讨论】:

    • 是的,它返回真假,因为我在 4 天前解决了错误。因此你得到了想要的输出。
    • @shakil08it051 更新您的问题以表明您已修复或自行回答以结束此问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-30
    • 2012-06-30
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多