Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

XML
<?xml version="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">
          <!-- 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="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);
}

C#
[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:

CSS
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
    }
Posted

1 solution

Hi ...

SQL
This Means Your Service is Not Running .

Run the Service .... Update the Proxy and Try Again!!!


Thank you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900