我可以帮助您进行翻译,这篇文章是关于it技术的,涉及到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 对用户详细信息进行身份验证,这部分工作正常。我的 Web Config 如下:
<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上运行良好。
UriTemplate = "Login?InstId={inst}&UserId={user}&pwd={pwd}"
更改为其他内容,例如UriTemplate = "helloworld?InstId={inst}&UserId={user}&pwd={pwd}"
吗?也许有些东西正在阻止调用或在你不知情的情况下修改它。 - pepo