2011-08-10 47 views
11

其他一切正常,我可以通过https使SOAP和RESTful调用不发送问题。但是WSDL总是返回空白(坏请求)。 HTTP很好地返回WSDL。IIS 7.5 Wcf https WSDL总是返回空白(坏请求)

跟踪日志内部异常报告:

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

serviceMetaData标签设置:

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

的web.config部分 绑定:

<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"/> 

任何人有任何的想法就是为什么这可能发生?

+0

你知道吗? –

+1

你能显示WSDL请求的URL吗? –

+0

我低估了这个问题,因为提问者在一周内还没有回答这些问题! –

回答

0

您是否尝试关闭其他端点之一?在我的情况下,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> 
0

我相信您的问题将与您的服务行为部分相关。具体来说,你告诉.net以HTTP方式发布你的WSDL,而不是HTTPS。请尝试以下

 <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" 
       httpsGetEnabled="true" 
       policyVersion="Policy15" 
       httpsGetEnabled="true" /> 
     </behavior> 

注意在serviceMetadata额外的行指httpsGet,而不是HTTP。

我会认为HTTPS是双方的绑定,并在您的应用程序启用因为你可以看到HTTP WSDL,而不是有关无法找到绑定什么的......有些喃喃巨型

0

当你正在进行传输加密,您必须将其添加到您的基地址协议例如:< add baseAddress =“https:// localhost:62701/xml”/>或< add baseAddress =“http:// localhost:62701/json “/>