none
WCF Tutorial issues -- Broken?? RRS feed

  • Question

  • Hi,

       I needed to learn a bit about WCF and this tutorial (http://msdn.microsoft.com/en-us/library/ms734712%28v=vs.110%29.aspx) seemed like an excellent choice.  Unfortunately, it doesn't seem to work and seems to have a number of mistakes, so I was hoping for some help.

    I'm using VS2013 on Windows 7 for this.

    In the first section of the tutorial, when you are creating the GettingStartedLib, there is no mention of what should go into the App.config file.  And what's in there is throwing warnings about the name attribute and the contract attribute -- they are both listed as invalid.  I made no changes to this file, so if you just create the project using the instructions in the first part of the tutorial, that's what you get.  Now, what is below is an example of what's in the app.config file, but I did change the servicename, and the original one came up as invalid.  Same thing with the contract name (also listed as invalid.

    <system.serviceModel>
        <services>
          <service name="GettingStartedLib.Service1">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8733/Design_Time_Addresses/GettingStartedLib/Service1/" />
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address supplied above -->
            <endpoint address="" binding="basicHttpBinding" contract="GettingStartedLib.Service1"

    Part 2 of the tutorial seemed fine, but part three has some issues, and they're important ones.

    There are TWO versions of the .cs files, and they don't match.

    The top one, gives you this line:

    // Step 1 Create a URI to serve as the base address. Uri baseAddress = new Uri("http://localhost:8000/GettingStarted/");

    But the bottom version of that file says this:

    // Step 1 of the address configuration procedure: Create a URI to serve as the base address. Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/Service");

    So.... which is it??

    When the GettingStartedHost is run, it does not error -- but the little popup tells me that the service was immediately stopped

    but that's only supposed to happen if you hit enter in the console window, which I did not do.

    Next up is the GettingStartedClient. That one tells you to run the GettingStartedHost, then

    add a reference WHILE IT'S RUNNING to the GettingStartedClient. Problem is, all those options

    are greyed out, so there's no way to do that.

    I'd really like to get this working, but repeated searches are of no help.

    Any ideas?

    Thanks.

    Tuesday, August 5, 2014 8:23 PM

Answers

  • I was, finally, able to get this tutorial to work, but ONLY because I found other tutorials on the net and was able to use them to figure out and correct the multiple errors that caused this tutorial to fail out of the box.

    I do thank you folks for trying to help though.

    Wednesday, August 20, 2014 5:59 PM

All replies

  • Hi,

    For the Part 1:
    After we creat the GettingStartedLib, we just need to build the project without doing any modify to the App.config file. We can also test it by click the F5, then the WCF Test Client will appear to help us check if the service code works well as following:

    Then for your config file:
       <endpoint address="" binding="basicHttpBinding" contract="GettingStartedLib.Service1"

    It should be as following:
       <endpoint address="" binding="basicHttpBinding" contract="GettingStartedLib.IService1"

    For the Part 3:
    Yes, in the two examples the baseAddress are different. But we can use any baseAddress as we want like the following:
    http://localhost:8000/..........................

    Then for the question about client, since the service is hosted in a Console application, we need to let the service host Console applicatio keep running all the time. But the client is also a Console application, then in order to let the service host Console application to run, we need to open a new Visual Studio to create the client Console application. Then both of the service host Console application and the Client Console application can run together.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, August 6, 2014 3:22 AM
    Moderator
  • Thanks for your reply, but I'm afraid it doesn't solve the problem.

    Wednesday, August 6, 2014 12:24 PM
  • Hi,

    From the error information, it seems that it has something wrong with the Metadata. For using the WCF Test Client, please try to make sure that you have defined the mex endpoint or have set the httpGetEnabled as true as following:

    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

    .............. <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>


    If the above can not help, please try to post your whole config file here.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 7, 2014 2:55 AM
    Moderator
  • I'm afraid those values were already in there.  Now this is the app.config file for the GettingStartedLib that we're talking about, right?  Because that was what I was running.

    It's worth noting that I followed the directions in the tutorial to create this project -- and that it doesn't actually work.  Or at least, I couldn't get it to work.  Anyway, here's the entire app.config file for the GettingStartedLib

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>

      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service name="GettingStartedLib.Service1">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8733/Design_Time_Addresses/GettingStartedLib/Service1/" />
                <!--<add baseAddress = "http://localhost:8000/ServiceModelSamples/Service" />-->
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address supplied above -->
            <endpoint address="" binding="basicHttpBinding" contract="GettingStartedLib.Service1">
              <!--
                  Upon deployment, the following identity element should be removed or replaced to reflect the
                  identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
                  automatically.
              -->
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <!-- Metadata Endpoints -->
            <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
            <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information,
              set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <!-- 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="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

    </configuration>

    Thursday, August 7, 2014 6:02 PM
  • Hi,

    Please try to modify this following config file:
    <endpoint address="" binding="basicHttpBinding" contract="GettingStartedLib.Service1"

    As following:
    <endpoint address="" binding="basicHttpBinding" contract="GettingStartedLib.IService1"

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 14, 2014 10:24 AM
    Moderator
  • Still no go.  I actually restarted this project from the beginning, and it just doesn't work.  I ran the very first project, and it still comes up with the exact same error every single time.

    There's a popup that says "WCF Service Host cannot find any service metadata.  This may cause the client application to run improperly.  Please check if metadata is enabled.  Do you want to exit?"

    Then if you go into the WCF Service host itself and click on the service, you get this:

    "The service cannot be started. This service has no endpoint defined. Please add at least one endpoint for the service in config file and try again."

    Don't know why it's happening, but I really need to get this stuff to work to learn it, and I simply can't get this tutorial to work. 

    Friday, August 15, 2014 7:04 PM
  • I was, finally, able to get this tutorial to work, but ONLY because I found other tutorials on the net and was able to use them to figure out and correct the multiple errors that caused this tutorial to fail out of the box.

    I do thank you folks for trying to help though.

    Wednesday, August 20, 2014 5:59 PM
  • I have the same issue, Can you let me know what other tutorials helped you to fix all these errors.
    Wednesday, March 2, 2016 10:56 PM