我已经使用 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。
要解决您的问题:
- 右键单击 FirstService.svc
- 点击“查看标记”
- 确保服务属性与 web.config 中的服务名称属性匹配。
关于wcf - wsHttpBinding 恢复为基本的 httpBinding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4589895/