我有一组在单个ServiceContract中定义的操作,现在其中两个已经切换到直接接收和返回MessageContracts,其中包含一个流体,如MSDN文档中所述。我已经测试了这个并且似乎工作正常然而现在我在同一个ServiceContract中调用我的其他操作时采用简单的RPC样式参数和返回类型我得到以下异常。
System.ServiceModel.ProtocolException occurred
Message=The remote server returned an unexpected response: (400) Bad Request.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
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)
...
InnerException: System.Net.WebException
Message=The remote server returned an error: (400) Bad Request.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
InnerException:
如果我理解发生了什么,我认为问题是我已经为服务器和客户端在两个方向上设置了TransferMode,以便于基于MessageContract的操作,但这必须打破我的非基于MessageContract的操作我在介绍流媒体之前就开始工作了。
那么也许我只有这两个选项:
这听起来准确吗?还有其他选择吗?我已经研究了是否有一种方法来指定每个OperationContract的TransferMode,但我找不到任何方法来执行此操作,因为它是绑定的设置,我不知道有任何方法为每个OperationContract指定单独的绑定
我需要展示的一系列服务是什么样的最佳选择?