2

ローカル IIS サーバーでホストしている一部の WCF サービスに対して呼び出しを行うアプリケーションがあります。IIS サーバーは ASP.NET 4.0 クラシックを実行しており、サービスは .NET 4.0 を使用して開発されています。クライアントは、NetCFSvcUtilユーティリティを使用して自動生成されたサービス クライアントで Windows Compact Framework 3.5 を実行しています。

アプリケーションでクライアントが使用できるメソッドの 1 つを呼び出そうとすると、次の例外が発生します。

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)

更新: サーバー上ですべてが適切に構成されました。この問題は、実際には、私のローカル開発マシンにサービスの 1 つのメッセージ キュー コンポーネントがないことが原因でした。私に提供された構成ファイルの1つに間違った設定が含まれていたため、他のサービスが例外をスローしていました。学んだ教訓?ログファイルをチェックしてください!

4

1 に答える 1

3

これは、実行しようとしているメソッドが WCF サーバー側に実装されていないことを意味します。これはあなたが書いたものですか?

この例外をスローするメソッドの例:

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

これは通常、クラスが継承するインターフェイスを実装することによって自動的に生成されるメソッドの既定のマークアップです。

編集:

メソッドが Web サービス側に実装されていることを確認するには、Visual Studio コマンド プロンプトに移動し、wcftestclient と入力します。アプリが起動したら、テストする wcf にサービス参照を追加し、そこからメソッドを実行して、期待どおりに機能していることを確認します。

于 2012-06-19T19:28:29.963 に答える