0

Like in this Question

I cant go on because of metadata. It still doesnt work for me. I changed the localhost number

address="http://localhost:54786/AdventureWorksService/mex"

the rest I left how it was but it did not work... tryed it in APP.CONFIG or WEB.CONFIG... I tryed even with adding <system.serviceModel>...</system.serviceModel>

I still get the metadata error. Please help me with detailed solution if possible.

Here is the web.config

 <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime tar

getFramework="4.5" />
  </system.web>
  <connectionStrings>
    <add name="AdventureWorks2012Entities" connectionString="metadata=res://*/AdventureWorksModel.csdl|res://*/AdventureWorksModel.ssdl|res://*/AdventureWorksModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(localdb)\Projects;initial catalog=AdventureWorks2012;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <directoryBrowse enabled="true" showFlags="Date,Time,Extension,Size" />
  </system.webServer>
</configuration>

And here is the app.config

    <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
        </startup>

  <!--<system.serviceModel>-->
  <services>
    <service name="AdventureWorksService"
             behaviorConfiguration="metadataSupport">
      <endpoint
          address="http://localhost:54786/AdventureWorksService/mex"
          binding="mexHttpBinding"
          contract="IMetadataExchange"
          />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="metadataSupport">
        <serviceMetadata/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <!--</system.serviceModel>-->

</configuration>
Community
  • 1
  • 1
Johnny
  • 195
  • 1
  • 10

1 Answers1

1

Some missing information in the question, but I'll give it a guess.

You do not expose metadata, which in turn prevents you from adding a service reference. Doublecheck that you have the httpGetEnabled="true" in the configuration (web.config) for application that hosts the service. If you are using HTTPS, then switch the element with httpsGetEnabled="true". You can combine the two if needed.

<serviceBehaviors>
    <behavior name="">
        <serviceMetadata httpGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
</serviceBehaviors>

EDIT: You would get a clear message stating this if you try to open the given service url in your browser.

EDIT2:

You need to include a service behavior, and the service endpoint with a contract. The name attribute refers to the service implementation. The namespace for the service, including the service name but without the .svc file extension. The contract attribute refers to the contract interface which that is also created when you choose new wcf service.

<system.serviceModel>
    <services>
      <service 
          name="MyApp.Services.MyService"
          behaviorConfiguration="MyServiceBehavior">
       <endpoint address=""
          binding="wsHttpBinding"
          contract="MyApp.Services.IMyService" />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" /> <!-- Set this to true to return exception details to the calling client. -->
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Try adding this configuration and edit the appropriate attributes, and then open the service in a web browser. The client should automatically get the app.config updated when you add the service through the Add Service Reference in Visual Studio.

scheien
  • 2,457
  • 1
  • 19
  • 22
  • @Johnny: You are missing the definitions for the service in the `web.config` – scheien May 30 '14 at 14:49
  • I am a total noob at WCF and XAML... So please show me where I am missing exactly what!? – Johnny May 30 '14 at 17:28
  • Could you do the walkthrough and see if you get to the same point? I takes 5 minutes to get to this pint. And than put in the full XML of the Web.config and also it which project you mean... becouse I cant figure out where to insert what – Johnny Jun 23 '14 at 08:59
  • The last config snippet should be in web.config at your server (or project that has the wcf service). The client config will be updated accordingly when you add a service reference. – scheien Jun 23 '14 at 10:39