.NET WCF Soap Service由于请求大小而未返回任何响应

时间:2018-11-06 11:14:31

标签: .net wcf soap

我有一个WCF Soap Service,我试图从SoapUI和Java程序调用它。我正在从Java端读取Excel文件,并将其发送到.NET端。

Excel文件具有37列,最多可以包含100行。我一一读取所有行,并将它们添加到列表中。在列表的一项中,在单行中有每个单元格的键值对象的列表。

这是我的问题。该服务在行数有限的情况下效果很好。我查看了我可以成功发送的最大内容长度,即65536。如果我发送的内容长度大于65536的请求,则服务将不返回任何内容。

如果我从Java项目发送请求,则会收到此错误:

  

无法发送消息。嵌套的异常是org.apache.cxf.transport.http.HTTPException:与...进行通信时,HTTP响应为“ 400:错误请求”。

.NET项目的web.config文件中,我对请求大小没有任何限制。

Web.Config

<system.web>
  <compilation targetFramework="4.0" debug="true"/>
  <httpRuntime/>
</system.web>

我从SoapUI发出的请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pas="http://schemas.datacontract.org/2004/07/..." xmlns:pas1="http://schemas.datacontract.org/2004/07/..." xmlns:arr="http://schemas.microsoft.com/2003/10/...">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:ListSegments>
         <!--Optional:-->
         <tem:request>
            <!--Optional:-->
            <pas:UserName>tst</pas:UserName>
            <!--Optional:-->
            <pas1:DetailList>
               <!--Zero or more repetitions:-->
               <arr:ArrayOfKeyValueOfstringstring>
                  <!--Zero or more repetitions:-->
                  <arr:KeyValueOfstringstring>
                     <arr:Key>No</arr:Key>
                     <arr:Value>1</arr:Value>
                  </arr:KeyValueOfstringstring>
                  ....
               </arr:ArrayOfKeyValueOfstringstring>
               <arr:ArrayOfKeyValueOfstringstring>
                  <!--Zero or more repetitions:-->
                  <arr:KeyValueOfstringstring>
                     <arr:Key>No</arr:Key>
                     <arr:Value>2</arr:Value>
                  </arr:KeyValueOfstringstring>
                  ....
               </arr:ArrayOfKeyValueOfstringstring>
               ....
            </pas1:DetailList>
          <tem:request>
       <tem:ListSegments>
    <soapenv:Body>
</soapenv:Envelope>

1 个答案:

答案 0 :(得分:1)

有限制的默认值。其中之一是maxAllowedContentLength,其默认值应为30000000,大约为28.6MB。所以可能不是您正在经历的。

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="500000000"/>
        </requestFiltering>
    </security>
</system.webServer>

可能是maxReceivedMessageSize,它们通常在web.config的绑定部分中设置,而您似乎没有。也许它们是在代码中设置的?

<basicHttpBinding>
  <binding maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
       maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
  </binding>
</basicHttpBinding>

也许在较高的“级别”中有一个配置文件设置了默认值。取决于设置(如果它在IIS中运行),它可以是machine.config文件或另一个Web.config。

相关问题