2014-03-03 87 views
4

我在包含兩種不同方法的共享環境上託管了一個WCF服務。一個是返回所需的輸出,而另一個則給出端點未發現的異常,這是我認證用戶的主要方法。在現場找不到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上正常工作。

+0

嘗試使用[本文檔]啓用幫助頁面(http://msdn.microsoft.com/zh-cn/library/ee230442(v = vs.110).aspx)。如果有任何差異,請檢查實時和本地IIS上的身份驗證設置。 – pepo

+0

但我有共享主機方案,所以如何檢查現場服務器上的驗證設置? –

+0

您是否試圖將'UriTemplate =「Login?InstId = {inst}&UserId = {user}&pwd = {pwd}」'更改爲其他類似於'UriTemplate =「helloworld?InstId = {inst}&UserId = {user}&pwd = {} PWD「'。也許有些東西阻止了電話或在你不知情的情況下修改它。 – pepo

回答

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應用程序項目,並沒有任何問題。

+0

不要讓它不工作....我在嘗試您的建議時遇到此錯誤 無法在服務Service1實施的合同列表中找到合同名稱'IMetadataExchange'。將ServiceMetadataBehavior添加到配置文件或直接添加到ServiceHost以啓用對此合同的支持。 –

+0

您確定'http:// www.ekotri.com/Service1.svc'上的服務是您在問題中提及的實現** Iservice.cs **的服務嗎?當我訪問'http://www.ekotri.com/Service1.svc?wsdl'時,沒有** Authenticate **方法。或者我錯過了什麼?此外,無論我嘗試我得到**端點沒有找到**的網址。我認爲我們正在調試錯誤的服務。 – pepo

+0

http:// www.ekotri.com/ Service1.svc/Data?Id〓2 試試這個......它的工作,它在同一個服務類中......但不是驗證方法.. –

1

試着改變你的接口,這樣

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

你在使用的時候你試圖打你的登錄方法網址是什麼?

根據你的服務文件,您所使用的網址範本

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

此URL返回「假」,這是預期。

+0

是的,它返回true和false,因爲我在4天前解決了錯誤。因此你正在獲得所需的輸出。 –

+0

@ shakil08it051更新您的問題以表明您已修復或自行回答以解決此問題 – iamkrillin