gpt4 book ai didi

.net - WCF 返回未实时找到端点

转载 作者:行者123 更新时间:2023-12-02 14:29:36 25 4
gpt4 key购买 nike

我在共享环境中托管了一个 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 工作正常,但身份验证给出端点未找到错误。不过它在本地 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>

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

关于.net - WCF 返回未实时找到端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22155568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com