WCF - endpoint not found

Discussion in 'ASP.NET WebServices' started by stumac, Mar 24, 2014.

  1. Spent a day on this so far. Tried 4 different tutorials and all failed upon deployment.
    Pretty sure it's the web.config file. Or something I'm missing on DASP

    Learning WCF using VS2010.
    So set up a WCF Service Application as per tutorial.
    So following the most basic of functionality.............outputting a string in JSON.

    Works perfectly well locally when tested from VS2010.
    Get
    {"GetDataResult":"You entered: SomeNumberorOther"}

    But when I deploy it to DASP, I get "Endpoint not found."

    Files as follows;
    cs file
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.Web;
    using System.Text;

    namespace shopBeacon2
    {
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {

    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "getData/{value}")]
    string GetData(string value);

    [OperationContract]
    CompositeType GetDataUsingDataContract(CompositeType composite);

    // TODO: Add your service operations here
    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class CompositeType
    {
    bool boolValue = true;
    string stringValue = "Hello ";

    [DataMember]
    public bool BoolValue
    {
    get { return boolValue; }
    set { boolValue = value; }
    }

    [DataMember]
    public string StringValue
    {
    get { return stringValue; }
    set { stringValue = value; }
    }
    }
    }
    *******************************************************
    svc file
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.Web;
    using System.Text;

    namespace shopBeacon2
    {
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class Service1 : IService1
    {
    public string GetData(string value)
    {
    return string.Format("You entered: {0}", value);
    }

    public CompositeType GetDataUsingDataContract(CompositeType composite)
    {
    if (composite == null)
    {
    throw new ArgumentNullException("composite");
    }
    if (composite.BoolValue)
    {
    composite.StringValue += "Suffix";
    }
    return composite;
    }
    }
    }
    *******************************************************************
    web.config
    <?xml version="1.0"?>
    <configuration>

    <system.web>
    <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.serviceModel>
    <services>
    <service name="shopBeacon2.Service1" behaviorConfiguration="shopBeacon2.Service1Behavior">
    <endpoint address="../Service1.svc"
    binding="webHttpBinding"
    contract="shopBeacon2.IService1"
    behaviorConfiguration="webBehaviour" />
    </service>
    </services>
    <behaviors>
    <serviceBehaviors>
    <behavior name="shopBeacon2.Service1Behavior">
    <!-- 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="webBehaviour">
    <webHttp/>
    </behavior>
    </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>

    </configuration>
    *****************************************************************

    Anybodies help in my retaining my sanity would be most appreciated.

    Cheers,

    Stu
     
  2. mjp likes this.
  3. mjp

    mjp

    Thanks for posting the solution, you're right, it will help someone else.
     

Share This Page