views:

26

answers:

1

Hello everyone,

I am using VSTS 2010 + C# + .Net 4.0 + IIS 7.5 + Windows 7. I am following MSDN sample here without any modifications, http://msdn.microsoft.com/en-us/library/ms733766.aspx

When I open the service.svc file (in IIS manager, right click the svc file and select browse) in IIS, there is an error like this, any ideas what is wrong?

in the service list CalculatorService not find the protocol name "IMetadataExchange". Add ServiceMetadataBehavior to the configuration file or directly add to the ServiceHost

Here is the web.config I am using,

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <!-- This section is optional with the default configuration
        model introduced in .NET Framework 4 -->
      <service name="Microsoft.ServiceModel.Samples.CalculatorService">

        <!-- This endpoint is exposed at the base address provided by host:                                        http://localhost/servicemodelsamples/service.svc  -->
        <endpoint address=""
                  binding="wsHttpBinding"
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />

        <!-- The mex endpoint is exposed at http://localhost/servicemodelsamples/service.svc/mex -->
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

</configuration>

thanks in advance, George

+1  A: 

Hello,

Can you please give some details about they way you have configured ur service.

http://msdn.microsoft.com/en-us/library/ms734765.aspx

This link has the steps. Point 5 and 6 should be of ur interest.

pavan

Try adding this to behavior to Config file:

<behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

and change the service element to ADD this behavior :

<service 
          name="Microsoft.ServiceModel.Samples.CalculatorService"
          behaviorConfiguration="CalculatorServiceBehavior">

regards,

PAvan

rauts
Thanks rauts! The link you gave out is about how to do self-hosting. I am doing IIS hosting. I have posted my web.config in my original post, any ideas what is wrong? If you need any further information do analyze, please let me know. Thanks in advance!
George2
Thanks rauts! The format is not looking good. Appreciate if you could post your proposed web.config in your reply by editting your post to update?
George2
I have edited the answer. Should be clear now.
rauts
Thanks, your solution works! It proves MSDN is wrong? :-)
George2
If you read the 3rd comment on the very same MSDN article, you will find the solution :)
rauts