2

I have the very simplest Console based host for a simple WCF service. The app config for the service is:

<system.serviceModel>
    <services>
      <service name="MagicEightBallServiceLib.MagicEightBallService"
               behaviorConfiguration="EightBallServiceMEXBehavior">
        <endpoint address=""
                  binding = "basicHttpBinding"
                  contract = "MagicEightBallServiceLib.IEightBall" />
        <!-- Enable the MEX endpoint-->
      <endpoint address="mex"
                binding ="mexHttpBinding"
                contract ="IMetadataExchange" />
      <!--Need to add this so MEX knows the address of our service -->
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8080/MagicEightBallService"/>
        </baseAddresses>
      </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="EightBallServiceMEXBehavior">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

The host program shows its running perfectly: ** Console Based WCF Host *

***** Host Info ******
Address: http://localhost:8080/MagicEightBallService
Binding: BasicHttpBinding
Contract: IEightBall

Address: http://localhost:8080/MagicEightBallService/mex
Binding: MetadataExchangeHttpBinding
Contract: IMetadataExchange

**************************************************
The service is ready

When I attempt to browse to or generate a proxy I get: HTTP Error 404.0 - Not Found

I can't figure out what's wrong. You can't get any simpler than this!

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Sam Gentile
  • 1,259
  • 7
  • 22
  • 28

2 Answers2

0

I have faced the same problem when reading Troelsen's book and could not find any answer online. Anyway it seems that the problem is in the project type for MagicEightBallLib. Troelsen suggests that you create a Visual C# -> Windows -> Class Library project, but he does not explain what modifications you need to make for it to work. If you instead use the Visual C# -> WCF -> WCF Service Library project, it will automatically start the WcfTestClient.exe, and add new tab in project's Preferences called "WCF Options". I tried to compare the differences between .csproj files for both types of projects but there is just too many. So the solution is to just start with the WCF Service Library project type instead of Class Library, and adjust names of interfaces and classes so they fit what is in the book.

If anyone knows which particular parts of the .csproj file are responsible for enabling this, I'd very much like to hear about it.

Hope this helps.

Piotr
  • 572
  • 5
  • 22
0

Instead of using localhost:8080 use 127.0.0.1:8080. That's how I got the example to work on my windows 10 machine.