WCF service call returns empty file / page

Viewed 828

The problem: When I'm calling my deployed WCF service, the browser downloads an empty svc file and does not show me the page with the service xml file.

The context: I have to move the webapp hosting the WCF service to a new server. This service was working fine on the old server, that was running IIS. The new server has 2 webservers running. IIS 8.5 and WAMP 2.5, because the server hosts an Php app and Jira.

The setup: The WAMP server listens to the 80 port and then redirects to IIS, to a specific port, if needed. This is an example for the setup.

Wamp config (https-vhosts.confg):

<VirtualHost *:80>    
ServerName site.de
ServerAlias www.site.de 
<Proxy *>
    Require all granted
</Proxy>

ProxyRequests           Off
ProxyPreserveHost       On
ProxyPass               /       http://localhost:9050/
ProxyPassReverse        /       http://localhost:9050/

The service URL: https://www.site.de/folder/service.svc

Service config:

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="someBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="52428899">
      <readerQuotas maxDepth="64" maxStringContentLength="81920" maxArrayLength="163840" maxBytesPerRead="40960" maxNameTableCharCount="163840" />
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>

  <serviceBehaviors>
    <behavior name="LargeServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <useRequestHeadersForMetadataAddress />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />

<services>
  <service name="ExampleServices.ExampleService" behaviorConfiguration="LargeServiceBehavior">
    <endpoint address="http://www.site.de/folder/service.svc" 
    binding="basicHttpBinding"
    bindingConfiguration="someBinding" 
    contract="ExampleServiceModels.IExampleService" />
  </service>
</services>

I have never worked with wamp before. And I don't have much experience with WCF settings also. Any ideas or tips would be highly appreciated.

EDIT Using the wcf test client i get this:

Error: Cannot obtain Metadata from http://www.site.de/folder/ExampleService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://www.site.de/folder/ExampleService.svc Metadata contains a reference that cannot be resolved: 'http://www.site.de/folder/ExampleService.svc'. The requested service, 'http://www.site.de/folder/ExampleService.svc' could not be activated. See the server's diagnostic trace logs for more information.HTTP GET Error URI: http://www.site.de/folder/ExampleService.svc The document at the url http://www.site.de/folder/ExampleService.svc was not recognized as a known document type.The error message from each known type may help you fix the problem:- Report from 'XML Schema' is 'Root element is missing.'.- Report from 'DISCO Document' is 'Root element is missing.'.- Report from 'WSDL Document' is 'There is an error in XML document (0, 0).'. - Root element is missing.

2 Answers

Not sure this answer will help OP after almost 3 years. But it is more intended for @GothamLlianen. But if you want to access a WFC service on a HTTPS connection, you need to specify that binding explicitly.

Add this in the <system.serviceModel> node of the Web.Config

<bindings>
  <webHttpBinding>
    <binding name="HttpsBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </webHttpBinding>
</bindings>

Then add the name, in this case "HttpsBinding" to the endpoint

<endpoint bindingConfiguration="HttpsBinding"

The complete node below for reference

  <system.serviceModel>
    <services>
      <service behaviorConfiguration="ServiceBehaviour" name="MyProject.Api">
        <endpoint bindingConfiguration="HttpsBinding" address="" behaviorConfiguration="web" binding="webHttpBinding" contract="MyProject.IApi" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceAuthorization principalPermissionMode="UseAspNetRoles" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Bare" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <bindings>
      <webHttpBinding>
        <binding name="HttpsBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
  </system.serviceModel>
Related