Hello
I have the following error creating and simple service with WCF REST (just for Simplifying the code, I don't create an interface)
[ServiceContract]
public class Regiones
{
RegionesServiceEntities db = new RegionesServiceEntities();
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/Ciudad/{NombreCiudad}")]
public string Ciudades(int id)
{
var query = from t in db.Ciudad
where t.CiudadID == id
select new { t.NombreCiudad };
var mObjeCiudad = query.SingleOrDefault();
return mObjeCiudad.ToString();
}
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/Departamento/{NombreDepartamento}")]
public string Departamento(int id)
{
var query = from t in db.Departamento
where t.DepartamentoID == id
select new { t.NombreDepartamento };
var mObjDepto = query.SingleOrDefault();
return mObjDepto.ToString();
}
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/Pais/{NombrePais}")]
public string Paises(int id)
{
var query = from t in db.Pais
where t.PaisID == id
select new { t.NombrePais};
var mObjPais = query.SingleOrDefault();
return mObjPais.ToString();
}
}
and the web.config was organized like this...
="1.0"="utf-8"
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="coRegionesService.Regiones">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="webHttpBindingWithJsonP" contract="coRegionesService.IRegiones" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<connectionStrings>
<add name="RegionesServiceEntities" connectionString="metadata=res://*/RegionesModel.csdl|res://*/RegionesModel.ssdl|res://*/RegionesModel.msl;provider=System.Data.SqlClient;provider connection string="data source=Express/database;initial catalog=RegionesService;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
and the error that shows me is this
The operation 'Cities' contract 'Regions' has a UriTemplate that expects a parameter called 'NameCity', but there is no parameter entry with that name in the operation.
any help??
What I have tried:
[WebInvoke(Method = "GET", UriTemplate = "ciudades/{NombreCiudad}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public string Ciudades(int id)
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "departamento/{NombreDepartamento}", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public string Departamento(int id)
{