.NET 4 WCF SOAP服务Http POST返回404 NOT Found

Huz*_*pal 8 wcf soap wcf-binding

我有WCF托管的SOAP服务,我可以在发出HTTP GET请求时从浏览器和我的SOAP客户端点击,但是,在执行任何HTTP POST请求时,响应是404 Not Found.

我的Web.config看起来像:

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    <bindings>
        <wsHttpBinding>
            <binding>
                <security mode="Transport">
                    <transport clientCredentialType="Certificate" />
                </security>
                <readerQuotas maxDepth="15" maxStringContentLength="524288" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            </binding>
        </wsHttpBinding>
        <basicHttpBinding>
            <binding>
                <readerQuotas maxDepth="15" maxStringContentLength="524288" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            </binding>
        </basicHttpBinding>
    </bindings>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

我的服务在标记中使用.svc文件定义为:

<%@ ServiceHost Language="C#" Debug="true" Service="Boca.WebServices.Billing.QBService" CodeBehind="QBService.svc.cs" %>
Run Code Online (Sandbox Code Playgroud)

同样,我可以使用HTTP GET使用浏览器和SOAP客户端,但不能使用HTTP POST:

我究竟做错了什么?我应该不使用.svc标记,只是在Web.config中定义我的服务?

更新:

当我在本地主机:8181端口上使用IIS Express从VS 2010中"开始调试"我的WCF项目时,HTTP POSTS到服务工作.只有当服务通过IIS托管时,才会拒绝或找不到服务的HTTP POST.

Huz*_*pal 10

我已经解决了这个问题.毕竟,它不是IIS问题,而是我没有配置<basicHttpBinding>with <security>节点的问题.我还没有完全阅读有关绑定及其工作方式的内容,因此我认为添加<wsHttpBinding>旁边的内容<basicHttpBinding>会为WCF添加SSL支持.

这样做并<wsHttpBinding>使用<security>节点配置默认值肯定允许我安全地获取SOAP元数据,即使它在内部仍在使用<basicHttpBinding>,但是不支持POST.

我更新了我的配置,以便 transport clientCredentialType设置为None并解决了问题:

<bindings>
    <basicHttpBinding>
        <binding name="QBService_BasicHttpBinding">
            <security mode="Transport">
                <transport clientCredentialType="None" />
            </security>
            <readerQuotas maxDepth="15" maxStringContentLength="524288" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
    </basicHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)