[英]WCF returning Endpoint not found on live
我在共享環境上托管了一個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上工作正常。
試試這個配置:
<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應用程序項目上進行了測試,沒有任何問題。
嘗試更改這樣的界面
[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"/>
當您嘗試點擊登錄方法時,您使用的是什么網址?
根據您的服務文件,您使用的網址模板是
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並插入一些假值..
此url返回“False”,這是預期的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.