.net 在live上未找到WCF返回终结点

.net 在live上未找到WCF返回终结点,.net,json,wcf,web-config,endpoint,.net,Json,Wcf,Web Config,Endpoint,我在共享环境中托管了一个WCF服务,其中包含两种不同的方法。一个是返回所需的输出,而另一个是提供EndpointNotFoundException,这是我对用户进行身份验证的主要方法 此处描述了该场景: 我的Iservice.cs如下所示 [OperationContract] [WebInvoke(Method="GET", UriTemplate = "Data?Id={id}", ResponseFormat=WebMessageFormat.Json)] string GetData(s

我在共享环境中托管了一个WCF服务,其中包含两种不同的方法。一个是返回所需的输出,而另一个是提供EndpointNotFoundException,这是我对用户进行身份验证的主要方法

此处描述了该场景:

我的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验证用户的详细信息,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给出了endpoint not found错误。但它在本地IIS上运行良好。

请尝试以下配置:

<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>


我已经在VisualStudio的默认WCF应用程序项目上测试了它,没有任何问题

试着像这样改变你的界面

[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"/>

当您尝试点击登录方法时,您使用的是什么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">
如果我使用该模板url并插入一些伪值


此url返回预期的“False”。

尝试使用启用帮助页面。另外,如果存在任何差异,请检查live和本地IIS上的身份验证设置。但是我有共享的托管计划,那么如何检查live server上的身份验证设置??您是否尝试将
UriTemplate=“Login?instd={inst}&UserId={user}&pwd={pwd}”
更改为类似
UriTemplate=“helloworld?instd={inst}&UserId={user}&pwd={pwd}“
。可能是有什么东西在你不知道的情况下阻止或修改了呼叫。是的,我确实更改了authenticate关键字和类似的东西,但它没有发生。。。不知道我被卡在哪里???你是否试图将地址“”留空?对我来说是这样的不,兄弟,它不起作用。。。。我在尝试您的建议时遇到此错误。在服务Service1实现的合同列表中找不到合同名称“imeadataexchange”。将ServiceMetadataBehavior添加到配置文件或直接添加到ServiceHost以启用对此协定的支持。您确定
http://www.ekotri.com/Service1.svc
该服务是否实现了您在问题中提到的Iservice.cs?当我访问
http://www.ekotri.com/Service1.svc?wsdl
没有身份验证方法。还是我遗漏了什么?另外,无论我尝试什么url,都找不到端点。我认为我们调试了错误的服务。http://www.ekotri.com/Service1.svc/Data?Id〓2试试这个。。。它的工作,这是在同一服务级别。。。但不是身份验证方法…是否已从rest端点绑定中删除listenUri属性?另外,您是否可以在restfulBehavior中启用webhttp的帮助页面,如
?并粘贴服务类的定义。是的,它返回true和false,因为我在4天前解决了错误。因此,您将获得所需的输出。@shakil08it051更新您的问题以表明您已修复该问题,或自行回答以结束此问题
http://www.ekotri.com/Service1.svc/Login?InstId={inst}&UserId={user}&pwd={pwd}