简体   繁体   English

从应用程序而不是从SoapUI调用批处理服务时出现MaxReceivedMessageSize错误

[英]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 ,可以将其设置为YN 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.

相关问题 从vb.net调用WCF时如何增加MaxReceivedMessageSize - how to increase MaxReceivedMessageSize when calling a WCF from vb.net 如何增加从ssrs报表调用WCF的maxReceivedMessageSize? - How to increase the maxReceivedMessageSize calling a WCF from ssrs report? 从SoapUI调用Web方法时,模拟失败 - Impersonation fails when calling web method from SoapUI 从Windows服务调用WCF服务时出现证书错误 - Certificate error when calling WCF service from Windows Service 从 Web 表单调用 Weather Web 服务时出现意外错误 - Unexpected error when calling Weather Web Service from a Web Form 从净应用程序调用php Web服务 - Calling php web service from net application 从.net Windows应用程序调用Web服务 - Calling a web service from a .net windows application 从另一个WCF服务调用时,WCF Web服务IIS6 401未授权错误。 从asmx / WinForms调用可以 - WCF web service IIS6 401 unauthorized error when calling from another WCF service. Calling from asmx/WinForms is OK 使用adfs 2.0被动身份验证从Web应用程序调用时,带有webhttpbinding的WCF服务调用不起作用 - wcf service call with webhttpbinding not working when calling from web application when using adfs 2.0 passive authentication WCF在maxreceivedmessagesize错误时获取数据 - WCF Get data when maxreceivedmessagesize error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM