11
votes

Everything else works fine, I can make SOAP and RESTful calls w/o issue via https. But WSDL always returns blank (bad request). HTTP returns WSDL fine.

Trace log inner exception reports:

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

serviceMetaData tag is set:

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

web.Config sections Binding:

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

You will immediately notice security mode="None"

Via ServiceHostFactory I see the mode to transport as:

        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"));
                }
            }

Services configuration:

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

Endpoint behaviours

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

Service Behaviours

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

Also have

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

Anyone have idea's why this may be occurring?

3
Did you figure this out?Meidan Alon
Can you show the URL of WSDL request?Petar Vučetin
I downvoted this question because the asker has not answered these questions in a week!SASS_Shooter

3 Answers

0
votes

Did you try turning off one of the other endpoints? In my case WCF didn't work until I disabled one of the endpoints. It didn't matter which one I disabled. The others would work.

    <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
votes

I believe your issue is going to be related to your service behaviors section. Specifically you told .net to publish your WSDL in HTTP but not HTTPS. Try the following

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

Note the extra line in the serviceMetadata referring to httpsGet as opposed to http.

I will assume that https is enabled on both the bindings and in your application given that you can see the http WSDL rather than some mumble jumbo about not being able to find bindings or something...

0
votes

When you are doing the Transport encryption you have to add the s to your base address protocol ex: < add baseAddress="https://localhost:62701/xml"/> or < add baseAddress="http://localhost:62701/json"/>