2012-06-19 101 views
1

我有一個應用程序正在對我在本地IIS服務器上託管的某些WCF服務進行調用。 IIS服務器運行ASP.NET 4.0 classic,服務使用.NET 4.0開發。客戶端使用NetCFSvcUtil實用程序運行帶有自動生成的服務客戶端的Windows Compact Framework 3.5。與WCF服務通信收益率沒有實現異常

當我嘗試調用我的應用程序提供給客戶的方法之一,我收到以下異常:

ProtoccolException: The remote server returned an unexpected response: (501) Not Implemented.

任何人都可以點我的方向,以爲什麼我米收到此錯誤?我打電話的所有方法都提供了一個實現。

堆棧跟蹤:

System.ServiceModel.ProtocolException was unhandled 
    Message="The remote server returned an unexpected response: (501) Not Implemented." 
    StackTrace: 
     at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException) 
     at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
     at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
     at System.ServiceModel.Channels.RequestChannel.Request(Message message) 
     at ClientProject.Microsoft.Tools.ServiceModel.CFClientBase`1.getReply(Message msg) 
     at ClientProject.Microsoft.Tools.ServiceModel.CFClientBase`1.Invoke[TREQUEST,TRESPONSE](CFInvokeInfo info, TestMethodRequest request) 
     at ClientProject.TestService.MQClient.TestMethod(TestMethodRequest request) 
     at ClientProject.TestService.MQClient.TestMethod(TestInfo testInfo) 
     at ClientProject.Form.Button1_Click(Object sender, EventArgs e) 
     at System.Windows.Forms.Control.OnClick(EventArgs e) 
     at System.Windows.Forms.Button.OnClick(EventArgs e) 
     at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam) 
     at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam) 
     at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain) 
     at System.Windows.Forms.Application.Run(Form fm) 
     at ClientProject.Form.Main() 
    InnerException: System.Net.WebException 
     Message="The remote server returned an error: (501) Not Implemented." 
     StackTrace: 
      at System.Net.HttpWebRequest.finishGetResponse() 
      at System.Net.HttpWebRequest.GetResponse() 
      at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
      at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
      at System.ServiceModel.Channels.RequestChannel.Request(Message message) 
      at ClientProject.Microsoft.Tools.ServiceModel.CFClientBase`1.getReply(Message msg) 
      at ClientProject.Microsoft.Tools.ServiceModel.CFClientBase`1.Invoke[TREQUEST,TRESPONSE](CFInvokeInfo info, TestMethodRequest request) 
      at ClientProject.TestService.MQClient.TestMethod(TestMethodRequest request) 
      at ClientProject.TestService.MQClient.TestMethod(TestInfo testInfo) 
      at ClientProject.Form.Button1_Click(Object sender, EventArgs e) 
      at System.Windows.Forms.Control.OnClick(EventArgs e) 
      at System.Windows.Forms.Button.OnClick(EventArgs e) 
      at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam) 
      at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam) 
      at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain) 
      at System.Windows.Forms.Application.Run(Form fm) 
      at ClientProject.Form.Main() 
     InnerException: 

運行在我身上WCF Test Client得到以下內最例外:

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service. 


An error occurred while receiving the HTTP response to http://wv113.domain.local/Development/TestService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. 

Server stack trace: 
    at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) 
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    at IMQClient.TestMethod(TestInfo testInfo) 
    at MQClient.TestMethod(TestInfo testInfo) 

Inner Exception: 
The underlying connection was closed: An unexpected error occurred on a receive. 
    at System.Net.HttpWebRequest.GetResponse() 
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 

Inner Exception: 
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. 
    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
    at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
    at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) 

Inner Exception: 
An existing connection was forcibly closed by the remote host 
    at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) 
    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 

更新:一切都在我的服務器配置正確。這些問題實際上是由於我的本地開發機器錯過了其中一個服務的Message Queue組件。另一個服務拋出異常,因爲給我的配置文件中有一個配置文件在其中有錯誤的設置。學過的知識?檢查日誌文件!

+0

我建議打開服務器上的跟蹤作爲第一步。 http://msdn.microsoft.com/en-us/library/ms733025.aspx。 – cadrell0

+1

代碼在哪裏?導航到終點,確保您的方法在那裏,並確保它已在服務中實現。確保拼寫正確.. – Tony

+0

@Tony:已經驗證端點是正確的。如果我故意拼錯端點地址,我會在初始端點綁定中收到異常。 –

回答

2

這意味着您嘗試執行的方法未在WCF服務器端實現。這是你寫的東西嗎?的方法的

實施例,將拋出此異常:

public void UnimplementedMethod() 
{ 
    throw new NotImplementedException(); 
} 

這通常是該方法的默認的標記,其通過實現從類繼承的接口自動生成。

編輯:

要確保該方法是在網絡服務端轉到Visual Studio命令提示符,然後鍵入wcftestclient實現。應用程序啓動後,將服務引用添加到要測試的wcf,並從那裏執行該方法,以確保其按預期運行。

+0

是的,正如我在我的問題中所述,我確保所有方法都得到正確實施。 –

+0

你能告訴我們堆棧跟蹤嗎? – Dimitri

+0

另外你確定你有最近的構建部署和訪問? – Dimitri