que se enfrentaron durante horas con este hasta que finalmente he utilizado este ejemplo y funcionó vaya primero: http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide
sé enlace únicas respuestas no son buenos y otros han utilizado este enlace CP a solve this type of problem here at Stackoverflow por lo aquí están los pasos básicos si el artículo nunca se pone:
PASO 1
En primer lugar lanzamiento de Visual Studio 2010. Haga clic en Archivo-> Nuevo-> Proyecto. Crear una nueva "Aplicación de servicio WCF".
PASO 2
Una vez creado el proyecto, se puede ver en la solución que Al servicio WCF predeterminado y archivo de interfaz ya se han creado (Service1.cs & IService.cs). Elimine estos dos archivos y crearemos nuestra propia interfaz y archivo de servicio WCF.
PASO 3
Ahora haga clic derecho en la solución y crear un nuevo archivo de servicio WCF. He dado nombre al archivo de servicio como "RestServiceImpl.svc".
PASO 4
Como he explicado al principio del artículo que vamos a estar escribiendo una API que puede devolver datos en XML y formato JSON, aquí es la interfaz para eso. En IRestServiceImpl, agregue el siguiente código
En el código anterior, puede ver dos métodos diferentes de IRestService que son XMLData y JSONData. XMLData devuelve el resultado en XML mientras que JSONData en JSON.
[ServiceContract]
public interface IRestServiceImpl
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "xml/{id}")]
string XMLData(string id);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "json/{id}")]
string JSONData(string id);
}
STEP 5
Abiertas las RestServiceImpl.svc.cs de archivos y escribir el siguiente código de allí:
public class RestServiceImpl : IRestServiceImpl
{
public string XMLData(string id)
{
return "You requested product " + id;
}
public string JSONData(string id)
{
return "You requested product " + id;
}
}
PASO 6
Web.Config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">
<!--
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.
-->
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
PASO 7
En IIS:
¿Es esto en un servidor remoto orlocalhost? Si es remoto, ¿ha verificado que todo funciona localmente primero? –