0

这越来越令人沮丧......我对 Web 服务还是半新的,我真的不明白为什么我不知道如何使用 Microsoft WSE 3.0 在我的 Web 服务上启用 SOAP 的 MTOM 编码。我已将以下内容添加到我的 Web 服务中:

服务器上我的库中的 Web.config 和 app.config:

<configuration>
    <configSections>
        <section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </configSections>
    <system.web>
        <httpRuntime maxRequestLength="134217728" executionTimeout="300"/>
        <webServices>
            <soapExtensionImporterTypes>
                <add type="Microsoft.Web.Services3.Description.WseExtensionImporter, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            </soapExtensionImporterTypes>
            <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </webServices>
        <compilation>
            <assemblies>
                <add assembly="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            </assemblies>
        </compilation>
    </system.web>
    <microsoft.web.services3>
        <messaging>
            <mtom serverMode="always" />
            <maxMessageLength value="134217728" />
        </messaging>
    </microsoft.web.services3>
</configuration>

在客户端,我在 app.config 中添加了相同的内容,添加了客户端模式="On"。

当我尝试上传一个 40MB 的文件时,我收到了常见的错误“超出了最大请求长度”。

有什么解释吗?我是否必须告诉传输使用该配置?我怎么做?谢谢!

4

1 回答 1

2

您可能遇到了 Web 服务器的 maxAllowedContentLength。如果您正在运行 IIS7,请尝试将此代码块添加到您的 web.config。IIS7 在 http 运行时获取请求之前过滤请求。

http://msdn.microsoft.com/en-us/library/ie/ms689462(v=vs.90).aspx

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="134217728" />
        </requestFiltering>
    </security>
</system.webServer>
于 2012-01-24T17:51:01.563 回答