wcf - wsHttpBinding 恢复为基本的 httpBinding

标签 wcf

我已经使用 wsHttpBinding 创建了一个服务,但是每次我下载该服务时,它都会在客户端的配置中创建 basichttpbinding。有什么想法吗? 谢谢

<system.serviceModel>
    <serviceHostingEnvironment/>
    <bindings>

      <wsHttpBinding>
        <binding name="WSHttpBinding" sendTimeout="00:10:00" receiveTimeout="00:59:00" bypassProxyOnLocal="false"
         transactionFlow="false" hostNameComparisonMode="StrongWildcard"
         maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"
         messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"
         allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="50000000"
           maxArrayLength="50000000" maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
          <reliableSession inactivityTimeout="00:59:00" />
          <security mode="Message">
            <!--<transport clientCredentialType="Windows" proxyCredentialType="None"
       realm="" />-->
            <message clientCredentialType="UserName" negotiateServiceCredential="true"
             algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="AdviserPayServiceBehaviour" name="AdviserPay.Services.FirstService.FirstService">
        <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding" contract="AdviserPay.Services.FirstService.IFirstService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="AdviserPayServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceAuthorization principalPermissionMode="None" impersonateCallerForAllOperations="false" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom"
              membershipProviderName="AdviserPayCustomMembershipProvider" />
          </serviceCredentials>
          <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false"
            serviceAuthorizationAuditLevel="None" messageAuthenticationAuditLevel="SuccessOrFailure" />
          <serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

最佳答案

.svc 标记文件中的服务名称可能与 web.config 中指定的名称不匹配。

当 WCF 启动服务时,框架会检查 .svc 文件中的服务名称,然后在 web.config 中查找与该名称匹配的配置。如果没有找到,则使用默认配置 - BasicHttpBinding。

要解决您的问题:

  1. 右键单击 FirstService.svc
  2. 点击“查看标记”
  3. 确保服务属性与 web.config 中的服务名称属性匹配。

关于wcf - wsHttpBinding 恢复为基本的 httpBinding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4589895/

相关文章:

wcf - RestartManager 导致辅助角色重新启动

c# - 使用 ASMX 并模拟方法

c# - 稳步减慢从 javascript 到 WCF 服务的 ajax 调用

windows - tcp 错误代码 10060 调用 WCF 服务

.net - 如何避免引发 AddressAlreadyInUseException?

c# - 对 WCF 服务进行单元测试

wcf - Azure端点-不同的部署

.net - RIA服务与WCF服务:有什么区别

hosting - 创建 WCF 数据服务以在服务主机中使用

c# - 在 C# 中在服务器和客户端之间传递自定义复杂对象