Access WCF service through HTTP

I wrote a very simple WCF project in Visual Studio:

IBookStore:

using System.Collections.Generic; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; namespace BookStore { [ServiceContract] public interface IBookStore { [OperationContract] [WebGet] List<Book> GetBooksList(); [OperationContract] [WebGet(UriTemplate = "GetBook/{id}")] // The value of UriTemplate defines the name that the // client should use to turn to the function Book GetBookById(int id); [OperationContract] [WebInvoke(UriTemplate = "AddBook/{name}", Method = "PUT")] void AddBook(string name); [OperationContract] [WebInvoke(UriTemplate = "UpdateBook/{id}/{name}", Method = "POST")] void UpdateBook(int id, string name); [OperationContract] [WebInvoke(UriTemplate = "DeleteBook/{id}", Method = "DELETE")] void DeleteBook(int id); } [DataContract] public class Book { int id; string name; [DataMember] public int ID { get { return id; } set { id = value; } } [DataMember] public string Name { get { return name; } set { name = value; } } } } 

BookStoreImpl:

 using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Activation; namespace BookStore { [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] public class BookStoreImpl : IBookStore { public void AddBook(string name) { using (var db = new BookStoreContext()) { Book book = new BookStore.Book { Name = name }; db.Books.Add(book); db.SaveChanges(); } } public void DeleteBook(int id) { try { using (var db = new BookStoreContext()) { Book book = db.Books.Find(id); db.Books.Remove(book); db.SaveChanges(); } } catch { throw new FaultException("Something went wrong"); } } public Book GetBookById(int id) { using (var db = new BookStoreContext()) { return db.Books.Find(id); } } public List<Book> GetBooksList() { List<Book> allBooks = new List<Book>(); try { using (var db = new BookStoreContext()) { IEnumerator<Book> booksEnum = db.Books.GetEnumerator(); booksEnum.Reset(); while (booksEnum.MoveNext()) { allBooks.Add(booksEnum.Current); } } } catch { throw new FaultException("Something went wrong"); } return allBooks; } public void UpdateBook(int id, string name) { try { using (var db = new BookStoreContext()) { Book book = db.Books.Find(id); book.Name = name; db.SaveChanges(); } } catch { throw new FaultException("Something went wrong"); } } } } 

My WebConfig file:

 <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <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" /> <httpModules> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> </httpModules> </system.web> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="MyServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="WebBehavior"> <webHttp /> </behavior> </endpointBehaviors> </behaviors> <services> <service behaviorConfiguration="MyServiceBehavior" name="BookStore.BookStoreImpl"> <endpoint address="http://localhost:8080/bookservice/" binding="wsHttpBinding" contract="BookStore.IBookStore" /> <endpoint address="" behaviorConfiguration="WebBehavior" binding="webHttpBinding" contract="BookStore.IBookStore"> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> </system.serviceModel> <!-- <system.serviceModel> <services> <service name="BookStore.BookStoreImpl"> <endpoint address="http://localhost:8080/bookservice" behaviorConfiguration="restfulBehavior" binding="webHttpBinding" bindingConfiguration="" contract="BookStore.IBookStore" /> <host> <baseAddresses> <add baseAddress="http://localhost:8080/bookservice" /> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="restfulBehavior"> <webHttp /> </behavior> </endpointBehaviors> </behaviors> <protocolMapping> <add binding="basicHttpsBinding" scheme="https" /> </protocolMapping> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel> --> <system.webServer> <modules runAllManagedModulesForAllRequests="true"> <remove name="ApplicationInsightsWebTracking" /> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> </modules> <!-- To browse web app root directory during debugging, set the value below to true. Set to false before deployment to avoid disclosing web app folder information. --> <directoryBrowse enabled="true" /> <validation validateIntegratedModeConfiguration="false" /> </system.webServer> <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> 

I also created a database, attached it to the project with the .mdf file, compiled and launched the project, and I can see the timer working in the right corner of the screen after the project starts. Then I will open my browser, enter in the address field: http: // localhost: 8080 / bookservice / GetBooksList and press enter, and instead I will get an error page. It doesn't seem like my requests ever get to the server in the first place. Can someone help me understand why?

Here's the error: enter image description here

EDIT: I noticed that if I set a breakpoint somewhere and started, I see the following error in the “WCF Test Client” window that appears: “Error : Unable to get metadata from http: // localhost: 59250 / BookStoreImpl.svc If this is the Windows (R) Communication Foundation service that you have access to, please check that you have enabled metadata publishing at the specified address. To help enable metadata publishing, refer to the MSDN documentation at http://go.microsoft.com/ ? fwlink / LinkId = 65455.WS The Metadata- the URI exchange error: http: // localhost: 59250 / BookStoreImpl.svc Metadata contains a reference that can not be resh at: ' http: // localhost: 59250 / BookStoreImpl.svc ' requested service. ' http: // localhost: 59250 / BookStoreImpl.svc ' can not be activated See server logs for diagnostic diagnostics more information.HTTP GET Error URI.. : http: // localhost: 59250 / BookStoreImpl.svc An error occurred while loading ' http: // localhost: 59250 / BookStoreImpl.svc '. Request error with error message: - There is no protocol binding to the specified address' http: // localhost : 8080 / bookservice / '. Protocol communications are configured at the Site level in the IIS or WAS configuration. body {font-family: "Verdana"; font-weight: normal; font-size: .7em; color: black;} p {font-family: "Verdana"; font-weight: normal; color: black; margin-top: -5px} b {font-family: "Verdana"; font-weight: bold; color: black; margin-top: -5px} H1 {font-family: "Verdana"; font-weight: normal; font- size: 18pt; color: red} H2 {font-family: "Verdana"; font-weight: normal; font-size: 14pt; color: maroon} pre {font-family: "Consolas", "Lucida Console", Monospace; font-size: 11pt; margin: 0; padding: 0.5em; line-height: 14pt} .marker {font-weight: bold; color: black, text-decoration: none;}. version {color: gray;}. error {margin-bottom: 10px;}. expandable {text-decoration: underline; font style: bold; Dark-blue colour; Cursor: hand; } @media screen and (max-width: 639px) {pre {width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }} @media screen and (max-width: 479px) {pre {width: 280px; }}

Server error in application "/".

No protocol binding matches the specified address http: // localhost: 8080 / bookservice / . Protocol associations are configured at the site level in the IIS or WAS configuration.

Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for more information about the error and its occurrence in the code.

Exception Details: System.InvalidOperationException: The protocol binding does not match the specified address http: // localhost: 8080 / bookservice / ". Protocol communications are configured at the site level in IIS or WAS configuration.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack trace:

<code> [InvalidOperationException: protocol binding does not match the specified address http: // localhost: 8080 / bookservice / ". Protocol connections are configured at the site level in IIS or WAS configuration.] System.ServiceModel.Activation.HostedAspNetEnvironment.GetBaseUri (String transportScheme, Uri listenUri) +109963 System.ServiceModel.Channels.TransportChannelListener.OnOpening () +13058405 System.ServiceModel. Channels.CommunicationObject.Open (TimeSpan timeout) +265 System.ServiceModel.Channels.DatagramChannelDemuxerenerOlenerOlenerOlenerOlenerOlenerOlenerOlenerOlenerOlener 2.OnOuterListenerOpen( ChannelDemuxerFilter, IChannelListener, - TimeSpan) +445 System.ServiceModel.Channels.SingletonChannelListener 3.OnOpen (TimeSpan timeout) +78 System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) +308 System.ServiceModel.Dispatcher.ChannelDispatcher. OnOpen ( Aime out a TimeSpan) +61 [InvalidOperationException The: ChannelDispatcher AT ' http: // localhost: 8080 / bookservice / '. to the contract '' SecurityNegotiationContract '' can not open your IChannelListener] System.ServiceModel.Dispatcher.ChannelD ispatcher.OnOpen (time TimeSpan) +134 System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) +308 System.ServiceModel.ServiceHostBase.OnOpen (TimeSpan timeout) +136 System.ServiceModel.Channels.CommunicationObject.Open (Time ) +308 System.ServiceModel.Security.NegotiationTokenAuthenticator 1.OnOpen(TimeSpan timeout) +137 System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan timeout) +23 System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen(TimeSpan timeout) +513 System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) +86 System.ServiceModel.Channels.SecurityChannelListener 1.OnOpen(TimeSpan timeout) +137 System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan timeout) +23 System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen(TimeSpan timeout) +513 System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) +21 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout) +86 System.ServiceModel.Channels.SecurityChannelListener 1.OnOpen (TimeSpan timeout) +240 System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) +308 System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen (TimeSpanval ChannelDispatcher at ' http: // localhost: 8080 / bookservice / ' with the contract '' IssueAndRenewSession '' cannot open its IChannelListener.] System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen (TimeSpan timeout) +134 System.ServiceModel.Channels .CommunicationObject.Open (TimeSpan timeout) +308 System.ServiceModel.ServiceHostBase.OnOpen (TimeSpan timeout) +136 System.ServiceModel.Channels.CommunicationObject.O pen (TimeSpan timeout) +308 System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen (TimeSpan timeout) +129 System.ServiceModel.Security.WrapperSecurityCommunicationObject. OnOpen (TimeSpan timeout) +21 System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) +308 System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open (TimeSpan timeout) +23 System.ServiceModelSecurity.Security.Security.Security. (TimeSpan time-out) +759 System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen (TimeSpan time-out) +21 System.ServiceModel.Channels.Communicat ionObject.Open (TimeSpan timeout) +308 System.ServiceModel.SecuritySetcurity.ecurity.Security.Setcurity (TimeSpan timeout) +130 System.ServiceModel.Channels.SecurityChannelListener 1.OnOpen(TimeSpan timeout) +240 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +61[InvalidOperationException: The ChannelDispatcher at 'http://localhost:8080/bookservice/' with contract(s) '"IBookStore"' is unable to open its IChannelListener.] System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +134 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +136 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +110 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +641[ServiceActivationException: The service '/BookStoreImpl.svc' cannot be activated due to an exception during compilation. The exception message is: The ChannelDispatcher at 'http://localhost:8080/bookservice/' with contract(s) '"IBookStore"' is unable to open its IChannelListener..] System.Runtime.AsyncResult.End(IAsyncResult result) +481507 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +174 System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +351314 System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +9791593</pre></code> </td> </tr> </table> <br> <hr width=100% size=1 color=silver> <b>Version Information:</b>ÿMicrosoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0 </font> </body></html><!-- [InvalidOperationException]: No protocol binding matches the given address 'http://localhost:8080/bookservice/'. Protocol bindings are configured at the Site level in IIS or WAS configuration. at System.ServiceModel.Activation.HostedAspNetEnvironment.GetBaseUri(String transportScheme, Uri listenUri) at System.ServiceModel.Channels.TransportChannelListener.OnOpening() at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.DatagramChannelDemuxer 1.OnOpen(TimeSpan timeout) +240 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +61[InvalidOperationException: The ChannelDispatcher at 'http://localhost:8080/bookservice/' with contract(s) '"IBookStore"' is unable to open its IChannelListener.] System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +134 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +136 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +110 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +641[ServiceActivationException: The service '/BookStoreImpl.svc' cannot be activated due to an exception during compilation. The exception message is: The ChannelDispatcher at 'http://localhost:8080/bookservice/' with contract(s) '"IBookStore"' is unable to open its IChannelListener..] System.Runtime.AsyncResult.End(IAsyncResult result) +481507 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +174 System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +351314 System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +9791593</pre></code> </td> </tr> </table> <br> <hr width=100% size=1 color=silver> <b>Version Information:</b>ÿMicrosoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0 </font> </body></html><!-- [InvalidOperationException]: No protocol binding matches the given address 'http://localhost:8080/bookservice/'. Protocol bindings are configured at the Site level in IIS or WAS configuration. at System.ServiceModel.Activation.HostedAspNetEnvironment.GetBaseUri(String transportScheme, Uri listenUri) at System.ServiceModel.Channels.TransportChannelListener.OnOpening() at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.DatagramChannelDemuxer 1.OnOpen(TimeSpan timeout) +240 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +61[InvalidOperationException: The ChannelDispatcher at 'http://localhost:8080/bookservice/' with contract(s) '"IBookStore"' is unable to open its IChannelListener.] System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +134 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +136 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308 System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +110 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +641[ServiceActivationException: The service '/BookStoreImpl.svc' cannot be activated due to an exception during compilation. The exception message is: The ChannelDispatcher at 'http://localhost:8080/bookservice/' with contract(s) '"IBookStore"' is unable to open its IChannelListener..] System.Runtime.AsyncResult.End(IAsyncResult result) +481507 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +174 System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +351314 System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +9791593</pre></code> </td> </tr> </table> <br> <hr width=100% size=1 color=silver> <b>Version Information:</b>ÿMicrosoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0 </font> </body></html><!-- [InvalidOperationException]: No protocol binding matches the given address 'http://localhost:8080/bookservice/'. Protocol bindings are configured at the Site level in IIS or WAS configuration. at System.ServiceModel.Activation.HostedAspNetEnvironment.GetBaseUri(String transportScheme, Uri listenUri) at System.ServiceModel.Channels.TransportChannelListener.OnOpening() at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.DatagramChannelDemuxer 2.OnOuterListenerOpen (ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout) on the system. ServiceModel.Channels.SingletonChannelListener 3.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)[InvalidOperationException]: The ChannelDispatcher at 'http://localhost:8080/bookservice/' with contract(s) '"SecurityNegotiationContract"' is unable to open its IChannelListener. at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Security.NegotiationTokenAuthenticator 3.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)[InvalidOperationException]: The ChannelDispatcher at 'http://localhost:8080/bookservice/' with contract(s) '"SecurityNegotiationContract"' is unable to open its IChannelListener. at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Security.NegotiationTokenAuthenticator 1.OnOpen (TimeSpan timeout) in System.ServiceModel.Security.WrapperSecurityCommunicationObO.OnOpen (TimeSpan timeout) in System.ServiceModel.Channels.Open TimeSpan out) in System.ServiceModel.Security. CommunicationObjectSecurityTokenAuthenticator.Open (TimeSpan timeout) in the System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen (TimeSpan timeout) in the System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpenSmm.munication.mell.mem.mmn. Open (TimeSpan timeout) in System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open (Ti, meSpan timeout) in System.ServiceModel.Channels.SecurityChannelListener1.OnOpen (TimeSpan timeout) in System.ServiceModel.Channels.mun TimeSpan timeout) in System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen (TimeSpan timeout) [InvalidOperationException]: ChannelDispatcher at 'http: // localhost: 8080 / bookservice /' with contract '' IssueAndRenewSession '' cannot open its IChannel Listener. in System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen (TimeSpan timeout) in System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) in System.ServiceModel.ServiceHostBase.OnOpen (TimeSpanModel) in System.Serode .Channels.CommunicationObject.Open (TimeSpan timeout) in System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen (TimeSpan timeout) in System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen (timeMent.ern.source .CommunicationObject.Open (TimeSpan timeout) in the System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open (TimeSpan timeout) in the System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen (TimeSpanSeviceControlService.Security.SecurityMecurity.Service.Security.Service.Security.Service.SecurityMecurity.Service.Security.Sevice.Security.Sevice.Security.SeviceMecurity.Service.Security.Sevice.Security.Sevice.Security.Sevice .OnOpen (TimeSpan timeout) in System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) System.ServiceModel.Security.SecurityListenerSettingsLifetimeMa nager.Open (TimeSpan timeout) in System.ServiceModel.Channels.SecurityChannelListener 1.OnOpen (TimeSpan timeout in System.ServiceModel.Channels.CommunicationObject.Open time (timeout) System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen (TimeSpan timeout) [InvalidOperationException]: ChannelDispatcher at ' http: // localhost: 8080 / bookservice / ' with contract '' IBookStore '' cannot open its IChannelListener. in System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen (TimeSpan timeout) in System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) in System.ServiceModel.ServiceHostBase.OnOpen (TimeSpanModel) in System.Serode .Channels.CommunicationObject.Open (TimeSpan timeout) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService (serviceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) in System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable (String normalizedVirtualPath, EventTraceActivity eventTraceActivity) [ServiceActivationException]: service ' /BookStoreImpl.svc 'cannot be activated due to an exception at compile time. Exception message: ChannelDispatcher in ' http: // localhost: 8080 / bookservice / ' with contract '' IBookStore '' cannot open its IChannelListener. in System.Runtime.AsyncResult.End [TAsyncResult] (result of IAsyncResult) in System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End (result of IAsyncResult) in System.ServiceModel.Activation.ServiceHttpMultule.estpMultulepulemodulepulemodulepulemodulepulemodulepulemodulepulemodulepulemodulepulemodulepulemodulemodulepulemodulepulemodule AsyncEventExecutionStep.OnAsyncEventCompletion (IAsyncResult ar) → -. "
+7
c # rest service wcf
source share
2 answers

It sounds like a problem with your WCF hosting.

The WCF service must be running inside some host. This can be a console application, an ASP.NET application, a Windows service, etc.

Before attempting to access the URL http: // localhost: 8080 / bookservice / , did you deploy your service as an IIS application with the specified address?

Most likely, you just run the application under debugging in Visual Studio. In this case, you should check that the project URL is configured correctly. Open the project properties, the tab "Web". What is the address in the Project Url edit box?

enter image description here

By default, VS puts localhost: there some random port, for example: http: // localhost: 38577 / . And in your case, the port is most likely 59250, which is evident from the error

Error: Unable to get metadata from http: // localhost: 59250 / BookStoreImpl.svc

If so, and you want to stick with your Web.config, change this value to http: // localhost: 8080 / bookservice / , click Create Virtual Directory and restart the debugging session, then try GetBooksList method GetBooksList .

+6
source

You can make this change to make sure basic binding works.

 <service behaviorConfiguration="MyServiceBehavior" name="BookStore.BookStoreImpl"> <endpoint address="" behaviorConfiguration="WebBehavior" binding="basicHttpBinding" bindingConfiguration="HttpBinding" contract="BookStore.IBookStore"> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> 
+1
source

All Articles