[英]MaxReceivedMessageSize Error when Calling Batch Service from Application but not from SoapUI
I have a very annoying issue when sending a request to a web service. 将请求发送到Web服务时,我遇到一个非常烦人的问题。
One of the parameters of the request message is Batch
, which can be set to either Y
or N
. 请求消息的参数之一是
Batch
,可以将其设置为Y
或N
When I set this to N
there is no issue, and I get a response containing details for a single order. 当我将其设置为
N
,没有问题,并且得到包含单个订单详细信息的响应。
However, when I set Batch
to Y
, I see this error: 但是,当我将
Batch
设置为Y
,我看到此错误:
Additional information: The maximum message size quota for incoming messages (65536) has been exceeded.
附加信息:已超过传入消息的最大消息大小配额(65536)。 To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。
To resolve this, I tried setting the MaxReceivedMessageSize
before calling the service: 为了解决这个问题,我尝试在调用服务之前设置
MaxReceivedMessageSize
:
public Provider.GetMessageResponse GetOrders(bool acceptBatch)
{
var httpBinding = new BasicHttpBinding();
httpBinding.MaxReceivedMessageSize = 2097152;
httpBinding.MaxBufferSize = 2097152;
var request = BuildRequest(acceptBatch);
var client = new Provider.PullServiceClient();
var response = client.PullGetMessage(SecurityToken, request);
return response;
}
However, I still see the error message (even though I can see that httpBinding.MaxReceivedMessageSize
has indeed been increased after running that code), and the service (not hosted by me) tells me that the messages have been collected (which does make sense, as it seems as if the messages are only being blocked once they reach my system). 但是,我仍然看到错误消息(尽管我可以看到运行该代码后确实增加了
httpBinding.MaxReceivedMessageSize
),并且该服务(不是由我托管)告诉我消息已被收集(确实有意义) ,似乎这些消息只有在到达我的系统后才被阻止)。
Furthermore, when I execute the exact same request from the SoapUI
application using xml, I do receive a batch response without any issues, and I can see a long list of all available orders. 此外,当我使用xml从
SoapUI
应用程序执行完全相同的请求时,我确实收到没有任何问题的批处理响应,并且可以看到一长串所有可用订单。
So does this MaxReceivedMessageSize
property only apply to my application and not the whole system? 那么,该
MaxReceivedMessageSize
属性仅适用于我的应用程序而不适用于整个系统吗? If that is the case, why does the code above not resolve this? 如果是这样,为什么上面的代码不能解决这个问题?
After looking at what overloaded constructors there were for Provider.PullServiceClient
, I managed to resolve this issue by including the following parameters: 在查看了
Provider.PullServiceClient
重载构造函数之后,我设法通过包含以下参数来解决此问题:
var binding = new BasicHttpBinding() { MaxReceivedMessageSize = 2097152, MaxBufferSize = 2097152 };
var endpoint = new EndpointAddress("http://test.providerporal.co.za/testservice/pullservice.svc");
var client = new Provider.PullServiceClient(binding, endpoint);
So I guess this limit is somehow related to my application, but the HttpBinding
needed to be bound to request itself. 所以我猜想这个限制与我的应用程序有关,但是需要绑定
HttpBinding
来请求它自己。 Hopefully this helps someone else. 希望这可以帮助其他人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.