locked
WCF Data service $metadata 404 (Not Found) when deploying client app RRS feed

  • Question

  • Dear Gurus

    I have developed simple WCF Data service with visual studio 2015 the service uses EF that connects to two tables in SQL server 2008 it was just straight Data service with no code in it only the generated code 

    using System;
    using System.Collections.Generic;
    using System.Data.Services;
    using System.Data.Services.Common;
    using System.Linq;
    using System.ServiceModel.Web;
    using System.Web;
    
    namespace MIKMODataServiceSite
    {
        public class MIKMOWCFDataService : DataService< MIKMOEntities >
        {
            // This method is called only once to initialize service-wide policies.
            public static void InitializeService(DataServiceConfiguration config)
            {
                // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
                // Examples:
                config.SetEntitySetAccessRule("*", EntitySetRights.All);
                //config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
                config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            }
        }
    }

    and below the web.config 

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <system.web>
        <compilation debug="true" targetFramework="4.5.2" />
        <httpRuntime targetFramework="4.5.2" />
      </system.web>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
        </compilers>
      </system.codedom>
      <connectionStrings>
        <add name="MIKMOEntities" connectionString="metadata=res://*/MIKMODataService.csdl|res://*/MIKMODataService.ssdl|res://*/MIKMODataService.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=MIKMO;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="v13.0" />
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <behaviors>
          <serviceBehaviors>
            <behavior name="Metadata">
              <serviceMetadata httpGetEnabled="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>

    and hosted it on my local IIS and things were more than perfect then i developed a client app with SAPUI5 framework and again it was so smooth with zero errors until i hosted my client app on the local IIS i started to get the following error $metadata 404 (Not Found) 

    While developing i didnt get that error and i was developing the client app with Eclipse that uses Apache tomcat to run the SAPUI5 app 

    Kindly assist is there is anything to be done in WCF data service app or is it IIS issue 

    Thanks for your consideration 

    Thursday, October 20, 2016 10:25 AM

All replies

  • Hi Hitman472,

    >>i hosted my client app on the local IIS i started to get the following error $metadata 404 (Not Found).

    According your description, it works well before you host your client app on the local IIS. it seems that the code of service and client is OK, I assume that it is a IIS issue.

    Please check the following similar issue with yours. IIS needs to have rights to the C:\Windows\Temp folder.  Without this it can't generate the meta data needed.

    http://stackoverflow.com/questions/4119964/wcf-metadata-reference-cannot-be-resolved

    In addition, As it is a IIS issue, you could also post your issue on IIS forum for support.

    https://forums.iis.net/1041.aspx/1?General

    Best regards,

    Cole Wu


    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.

    Friday, October 21, 2016 6:04 AM
    Moderator