我正在使用我无法控制的服务器使用WCF Web服务。不返回任何数据的方法在HTTP中完全可以使用HTTP代码204,但是我有处理响应的WCF自身的问题(所有其他返回400的方法都可以正常工作)。WCF HTTP 204响应
这里是我的方法声明:
[OperationContract]
[WebInvoke(UriTemplate = "methodpath/V1",
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
void Operation1(
[MessageParameter(Name = "username")]
string userName,
[MessageParameter(Name = "password")]
string password);
错误调用该方法后,我得到: 的CommunicationException:错误在反序列化的回复消息的身体操作“Operation1”。 OperationFormatter无法反序列化消息中的任何信息,因为消息是空的(IsEmpty = true)。
也尝试过使用IsOneWay = true: InvalidOperationException:单向操作返回一个非空消息,其中Action =''。
这里是原始的HTTP响应:
HTTP/1.1 204 No Content
Set-Cookie: ...
Content-Length: 0
Connection: Close
Date: Mon, 21 Mar 2011 18:41:37 GMT
异常堆栈跟踪:
服务器堆栈跟踪:
at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DemultiplexingClientMessageFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.CompositeClientFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
将不胜感激的人谁拥有一个想法如何强制WCF优雅地接受回应。
你能给出完整的堆栈跟踪吗?你知道肥皂服务的语言/框架吗? – 2011-03-21 19:55:13
用堆栈跟踪更新了问题。据我所知,后端正在使用兼容jax-rs的rest框架 – 2011-03-22 10:05:19
,它会抛出相同的异常,即使我通过http调试器将204无内容更改为200 OK,所以我认为这不是问题,而是WCF期望的响应正文或者其他东西 – 2011-03-22 10:43:19