Jeff

Jeff

  • NA
  • 15
  • 0

WCF Addressing on Localhost

Nov 10 2012 8:43 PM
 
Hi,
I am trying to learn to write WCF. I am runnign in to issues when trying to address the service on my localhost IIS.
I have the service contract and it's implementation:
[ServiceContract]
public interface IMyFirstWCFService
{
    [OperationContract]
    string OperationHello(string myvalue);
}
public class MyFirstWCFService : IMyFirstWCFService
{
    public string OperationHello(string myvalue)
    {
        return "Hello: " + myvalue;
    }
}



The Service.svc file:

<%
@ ServiceHost Language="C#" Debug="true" Service="MyFirstWCFService" CodeBehind="~/App_Code/MyFirstWCFService.cs" %>
And the web.config

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <system.serviceModel>
    <services>
      <service name="MyFirstWCFService" behaviorConfiguration="returnFaults">
        <endpoint contract="IMyFirstWCFService" binding="basicHttpBinding"
        address="http://localhost/WCF/Service.svc"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="returnFaults">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.web>
    <compilation debug="true"/>
  </system.web>
</configuration>

This is hosted in my inetpub/wwwroot/WCF folder. When I surf to http://localhost/WCF/Service.svc I recived a 400 Bad request error however if I change the webconfig to:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.web>
    <compilation debug="true"/>
  </system.web>
</configuration>








Then it all works fine and the standard wcf page with the svcutil string is displyed.

Where am I going wrong in the addressing in the first instance please?


Thanks
Jeff