Search code examples
c#wcfwcf-binding

Why am I getting WCF error?


Am getting this error when I browse to a .svc page in IIS [ie. http://localhost/PTSNew/PTNewService.svc].Could you please advise on how to resolve this error?And also, is the url given in baseAddress attribute incorrect?Thanks.

*

Service 'PTSNew.PriceTestingService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

*

Heres my interface and app.config xml:

namespace PTSNew 
{ 
    // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in App.config.

        public class PriceTestingService : IPriceTesting, IDisposable
}

namespace PTSNew 
{ 
    // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in App.config.

    [ServiceContract] 
    public interface IPriceTesting 
}

<system.serviceModel> 
    <bindings> 
      <basicHttpBinding> 
        <binding name="ProviderBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
                 receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" 
                 bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
                 maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" 
                 messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
          <security mode="Transport"> 
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
            <message clientCredentialType="UserName" algorithmSuite="Default" /> 
          </security> 
        </binding> 
      </basicHttpBinding> 
      </bindings> 
    <services> 
      <service name="PTSNew.PriceTestingService" behaviorConfiguration="PTSNew.Service1Behavior"> 
        <host> 
          <baseAddresses> 
            <add baseAddress = "http://localhost:8731/Design_Time_Addresses/PTSNew/PriceTestingService/" /> 
          </baseAddresses> 
        </host> 
        <!-- Service Endpoints --> 
        <!-- Unless fully qualified, address is relative to base address supplied above --> 
        <endpoint address ="" binding="basicHttpBinding" contract="PTSNew.IPriceTesting"> 
          <!-- 
              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. 
          --> 
          <identity> 
            <dns value="localhost"/> 
          </identity> 
        </endpoint> 
        <!-- Metadata Endpoints --> 
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
      </service> 
    </services> 
    <behaviors> 
      <serviceBehaviors> 
        <behavior name="PTSNew.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> 
    </behaviors> 
  </system.serviceModel>

Solution

  • seems that you have forgotten to write contract attribute for the service element

    please go to the http://www.codeproject.com/KB/WCF/first_WCF_Service.aspx to see an example