【问题标题】:WCF web service binding configuration not being applied未应用 WCF Web 服务绑定配置
【发布时间】:2010-11-02 04:28:13
【问题描述】:

我有一个名为“Palladium”的 WCF Web 服务,它是在 VS2008 解决方案中作为项目创建的。
我有一个 ASP.Net Web 应用程序,它在名为“Palladium.svc”的页面上托管此服务。
当我将表单数据发布到 Web 服务时,我的服务会接收到该数据并可以对其进行处理。

现在我将图像发布到服务并且帖子大小超过了 WCF 的默认 ma​​xReceivedMessageSize 属性。为了解决这个问题,我在 ASP.Net Web 应用程序的 web.config 文件的端点上添加了一个绑定配置。

我的问题是绑定配置似乎没有应用。

服务是从 iPhone 应用程序发布的,当帖子大小低于 65k 时,服务可以正常工作。一旦帖子大小超过此值,我就会收到 400(错误请求)错误。
出于测试目的,我在 ASP.Net Web 应用程序中创建了一个 test.aspx 文件,该文件将一些表单值和图像发布到 Web 服务。同样,当帖子大小低于默认的 65k 大小时,服务可以正常工作。超过 65k,我收到 400 错误。

测试页面发布到与以下 URITemplate /job-photo/{photoId}/{palladiumId}/{jobId} 匹配的 URL

如果有人能帮我调试这个问题,将不胜感激。

测试页的标记:

        <html xmlns="http://www.w3.org/1999/xhtml" >
        <head runat="server">
            <title></title>
        </head>
        <body>
            <form id="form1" action="http://localhost/cds/resources/services/palladium.svc/job-photo/1/235DE168-5D1C-46A4-89F2-FD17C6B9F415/567" method="post" enctype="multipart/form-data">
            <div>
                <input type="text" name="user" value="joe bloggs" />

                <input type="file" name="photo" />
                <input type="submit" name="btnsubmit" value="submit" />
            </div>
            </form>
        </body>
        </html>

来自 web.config 的服务信息:

     <system.serviceModel>
       <bindings>
         <wsHttpBinding>
           <binding name="large_message_binding" maxBufferPoolSize="5242880" maxReceivedMessageSize="5242880">
             <readerQuotas maxStringContentLength="5242880" maxArrayLength="5242880" maxBytesPerRead="5242880" />
           </binding>
         </wsHttpBinding>
       </bindings>

       <behaviors>
       <serviceBehaviors>
        <behavior name="CDS.UI.Resources.Services.PalladiumBehavior">
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
       </serviceBehaviors>
      </behaviors>

      <services>
       <service behaviorConfiguration="CDS.UI.Resources.Services.PalladiumBehavior"
        name="CDS.UI.Resources.Services.Palladium">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="large_message_binding" contract="CDS.PalladiumService.IPalladium">

         <identity>
          <dns value="localhost" />
         </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
       </service>
      </services>

     </system.serviceModel>

来自 Palladium.svc

的标记
    <%@ ServiceHost Language="C#" Debug="true" Service="CDS.PalladiumService.Palladium" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

【问题讨论】:

    标签: wcf asp.net-3.5 wcf-binding


    【解决方案1】:

    我的理解是

    Service="CDS.PalladiumService.Palladium"
    

    应该引用底层类型。

    这里的 name 属性也应该如此:

    <service behaviorConfiguration="CDS.UI.Resources.Services.PalladiumBehavior"
        name="CDS.UI.Resources.Services.Palladium">
    

    如果您将它们分配给底层服务类的实际类型,是否可以解决您的问题?

    【讨论】:

    • 感谢 Leigh 的建议 - “Palladium”实际上是服务类的类型。只要帖子大小不超过 65k,该服务就可以正常工作。
    • 您好 Nick,即使您从 web.config 中删除服务配置,该服务也将正常工作。我的观点是,如果两个元素不相同,我相信配置与服务的匹配不会发生。
    • 感谢 Leigh,对配置的更改有所帮助。进行更改后,服务似乎使用了配置-尽管现在我遇到了完全不同的错误。我已经 created a new question here 解决了我现在收到的问题 - 你也许可以为我提供一些启示!
    • 希望我能在 3 天前找到这篇文章,解决了我的问题。我想补充一点,它们显然也区分大小写。所以要小心!
    猜你喜欢
    • 2015-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-26
    • 1970-01-01
    • 1970-01-01
    • 2012-06-19
    • 1970-01-01
    相关资源
    最近更新 更多