4
votes

I want to run WCF Service from my VS2010 When i run WCF Service using below configuration.

<system.serviceModel>
<services>
  <service name="WcfSample.Service1" behaviorConfiguration="servicebehaviour1">
    <endpoint  address ="http://localhost:8080/service1/Service1.svc" contract="WcfSample.IService1" binding="wsHttpBinding"></endpoint>
    <endpoint address="" binding="mexHttpBinding" contract ="IMetadataExchange"></endpoint>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="servicebehaviour1">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="false"/>
      <!-- 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>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />-->

i am getting exception as below

No protocol binding matches the given address 'http://localhost:8080/service1/Service1.svc'. Protocol bindings are configured at the Site level in IIS or WAS configuration.

If i want to run my WCF at my given address wat should i do.

1
is that work for you ?? dont forget to upvote and mark it as accepted if it works for you..Pranay Rana

1 Answers

3
votes

Hosting of WCF service doesnt take the address you define in endpoints of config file

<endpoint 
      address="http://localhost:8080/service1/Service1.svce"

So the above one you defiend is not correct one instead of this you need to do as below

you address of service is the web server and the virtual directory plus the SVC file name like as below

http://servername/vrirualdirectoryname/svcfiename.svc/

you can define relative addresses like as below :

<service name="WcfSample.Service1">
   <endpoint name="" 
             address="ServiceAddress" 
             binding="wsHttpBinding"   
             contract="WcfSample.IService1" />
</service>

so finally you service adress from which you consume service is

http://servername/vrirualdirectoryname/svcfiename.svc/ServiceAddress

so like this you can do rather than specifying address direcly.

Note :

Above code is asuinming that service is going to be hosted on IIS server.