wcf - IIS 7.5 Wcf https WSDL 总是返回空白(错误请求)

标签 wcf iis ssl https wsdl

其他一切正常,我可以通过 https 进行无问题的 SOAP 和 RESTful 调用。但是 WSDL 总是返回空白(错误的请求)。 HTTP 返回 WSDL 正常。

跟踪日志内部异常报告:

The body of the message cannot be read because it is empty.

serviceMetaData 标签已设置:

<serviceMetadata
httpGetEnabled="true"
policyVersion="Policy15"
httpsGetEnabled="true" />

web.Config 部分 绑定(bind):

    <bindings>
        <basicHttpBinding>
            <binding name="soapBinding">
                <security mode="None">
                </security>
            </binding>
        </basicHttpBinding>
        <webHttpBinding>
            <binding name="webBinding">
                <security mode="None">
                </security>
            </binding>
        </webHttpBinding>
    </bindings>

您会立即注意到安全模式="无"

通过 ServiceHostFactory,我看到传输模式为:

        ServiceHost serviceHost = new ServiceHost(service.GetType(), baseAddresses);

        if (ExposeSSL(baseAddresses[0]))
        {
            foreach (var endpoint in serviceHost.Description.Endpoints)
            {
                if (endpoint.Binding is WebHttpBinding)
                {
                    ((WebHttpBinding)endpoint.Binding).Security.Mode = WebHttpSecurityMode.Transport;
                    endpoint.Address = new EndpointAddress(baseAddresses[0].ToString().Replace("http", "https"));
                }
                if (endpoint.Binding is BasicHttpBinding)
                {
                    ((BasicHttpBinding)endpoint.Binding).Security.Mode = BasicHttpSecurityMode.Transport;
                    endpoint.Address = new EndpointAddress(baseAddresses[0].ToString().Replace("http", "https"));
                }
            }

服务配置:

        <service name="xxxx.Wcf.AdminJsonService" behaviorConfiguration="DefaultBehaviour">
            <host>
                <baseAddresses>
                    <!-- note, choose an available port-->
                    <add baseAddress="http://localhost:62701/json"/>
                </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="jsonBehavior" bindingNamespace="https://www.xxxx/WebService4/AdminJsonService" contract="xxxx.Wcf.IAdminJsonService"/>
        </service>

        <service name="xxxx.Wcf.AdminXmlService" behaviorConfiguration="DefaultBehaviour">
            <host>
                <baseAddresses>
                    <!-- note, choose an available port-->
                    <add baseAddress="http://localhost:62701/xml"/>
                </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="poxBehavior" bindingNamespace="https://www.xxx/WebService4/AdminXmlService" contract="xxxx.Wcf.IAdminXmlService"/>
        </service>

        <service name="xxxx.Wcf.AdminSoapService" behaviorConfiguration="DefaultBehaviour">
            <!-- Service Endpoints -->
            <endpoint binding="basicHttpBinding" behaviorConfiguration="soapBehavior" bindingNamespace="https://www.example.com/WebService4/AdminSoapService" contract="xxxx.Wcf.IAdminSoapService"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>

端点行为

            <!-- SOAP -->
            <behavior name="soapBehavior">
            </behavior>
            <!-- JSON -->
            <behavior name="jsonBehavior">
                <webHttp/>
            </behavior>
            <!-- POX -->
            <behavior name="poxBehavior">
                <webHttp/>
            </behavior>

服务行为

            <behavior name="ErrorBehaviour">
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
            <behavior name="DefaultBehaviour">
                <NiceErrorHandler/>
                <!-- 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"/>

                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata
                    httpGetEnabled="true"
                    policyVersion="Policy15"
                    httpsGetEnabled="true" />
            </behavior>

还有

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

有人知道为什么会发生这种情况吗?

最佳答案

您是否尝试关闭其他端点之一?在我的例子中,WCF 在我禁用其中一个端点之前无法工作。我禁用哪一个并不重要。其他人会工作。

    <services>
      <service name="GTW.TrendToolService" behaviorConfiguration="MyServiceBehavior">
        <!--<endpoint name="rest" address="" binding="webHttpBinding" contract="TT.ITrendtoolService" behaviorConfiguration="restBehavior"/>-->
        <endpoint name="json" address="json" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="GTW.IAqvService" />
        <endpoint name="xml" address="xml" binding="webHttpBinding" behaviorConfiguration="restBehavior" contract="GTW.IAqvService" />
        <!--<endpoint name="mex" address="mex" binding="mexHttpBinding" contract="GTW.IAqvService" />
        <endpoint name="soap" address="soap" binding="basicHttpBinding" contract="GTW.IAqvService" />-->
      </service>
    </services>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="restBehavior">
      <webHttp />
    </behavior>
    <behavior name="jsonBehavior">
      <enableWebScript />
    </behavior>
  </endpointBehaviors>
</behaviors>

关于wcf - IIS 7.5 Wcf https WSDL 总是返回空白(错误请求),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7016762/

相关文章:

windows - 当由 Windows 服务生成的进程调用时,CreateMutex() 失败并显示 ERROR_ACCESS_DENIED

jsp - 如何在 JSP(在 Java EE 应用程序中)中使用 SSL?

ios - 是否可以在 iOS 中使用安全框架生成证书签名请求 (.csr)?

c# - WCF 和 MSMQ 故障处理

c# - WCF 是否在同一个线程中执行单例 WCF 服务中的操作?

sql-server - LogParser:SQL 表列 "X"数据类型与 SELECT 子句项 "cs-username"(类型 STRING)不兼容

iis - 尝试列出应用程序池或站点时,IIS管理器卡住

ssl - 如何通过 ssl 运行 docpad?

ios - 通过RESTful WCF服务从iPhone应用程序访问SQL数据库

c# - 如何禁用服务器上的 DNS 身份检查