Hi, I am getting the below error while trying to test my WCF service. I am using WCF first time so not so much aware what can be done in that situation. Can anybody help me please?
Error is:
Error: Cannot obtain Metadata from http://localhost:2174/Service1.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN
documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error
URI: http://localhost:2174/Service1.svc Metadata contains a reference that cannot be
resolved: 'http://localhost:2174/Service1.svc'. There was no endpoint listening at http://localhost:2174/Service1.svc
that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present,for more details. The remote server returned an error: (404) Not Found.HTTP GET Error URI: http://localhost:2174/Service1.svc There was an error downloading 'http://localhost:2174/Service1.svc'.
The request failed with HTTP status 404: Not Found.
I am having below files:
Web.config
="1.0"
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="MyWCFService.Stock" behaviorConfiguration="MyWCFService.StockServiceBehaviour">
<endpoint address="" binding="wsHttpBinding" contract="MyWCFService.IStock" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyWCFService.StockServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Interface:
[ServiceContract]
public interface IStock
{
[OperationContract]
Stocks GetStocks(String Symbol);
}
[DataContract]
public class Stocks
{
[DataMember]
public string Symbol { get; set; }
[DataMember]
public DateTime Date { get; set; }
[DataMember]
public string Company { get; set; }
[DataMember]
public decimal Close { get; set; }
}
SVC Class:
public class Stock : IStock
{
#region IStock Members
public Stocks GetStocks(string Symbol)
{
Stocks sts = null;
switch (Symbol.ToUpper())
{
case "GOOG":
sts = new Stocks
{
Symbol = Symbol,
Date = DateTime.Now,
Company = "Google Inc.",
Close = 495
};
break;
case "MSFT":
sts = new Stocks
{
Symbol = Symbol,
Date = DateTime.Now,
Company = "Microsoft Corporation",
Close = 25
};
break;
case "YHOO":
sts = new Stocks
{
Symbol = Symbol,
Date = DateTime.Now,
Company = "Yahoo! Inc.",
Close = 17
};
break;
}
return sts;
}
#endregion
}