Link to home
Start Free TrialLog in
Avatar of x1877
x1877Flag for United States of America

asked on

Error while running svcutil.exe

I am getting the following error while running the svcutil.exe. Infact the service is running with NetTcpBinding.

C:\Jacob\WCF\Client\Client\Client>svcutil.exe /language:cs /config:app.config ne
t.tcp://localhost:8000/ServiceModelSamples/service
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
Copyright (c) Microsoft Corporation.  All rights reserved.

Attempting to download metadata from 'net.tcp://localhost:8000/ServiceModelSampl
es/service' using WS-Metadata Exchange. This URL does not support DISCO.
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
Copyright (c) Microsoft Corporation.  All rights reserved.

Error: Cannot obtain Metadata from net.tcp://localhost:8000/ServiceModelSamples/
service

If this is a Windows (R) Communication Foundation service to which you have acce
ss, please check that you have enabled metadata publishing at the specified addr
ess.  For help enabling metadata publishing, please refer to the MSDN documentat
ion at http://go.microsoft.com/fwlink/?LinkId=65455.


WS-Metadata Exchange Error
    URI: net.tcp://localhost:8000/ServiceModelSamples/service

    Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:
8000/ServiceModelSamples/service'.

    There was no endpoint listening at net.tcp://localhost:8000/ServiceModelSamp
les/service that could accept the message. This is often caused by an incorrect
address or SOAP action. See InnerException, if present, for more details.

If you would like more help, type "svcutil /?"
**********************************

Here is the code i wrote in Host application

    class Program
    {
        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("net.tcp://localhost:8000/ServiceModelSamples/Service");
            ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);
            try
            {
                // Add a service endpoint
                serviceHost.AddServiceEndpoint((typeof(ICalculator)) ,new  NetTcpBinding ()   ,  "CalculatorService");
                // Enable metadata exchange
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                //smb.HttpGetUrl = new Uri("http://localhost:8000/ServiceModelSamples/Service"); ;
                serviceHost.Description.Behaviors.Add(smb);
                serviceHost.Open();
                Console.WriteLine("The service is ready.");
                Console.WriteLine("Press <ENTER> to terminate service.");
                Console.WriteLine();
                Console.ReadLine();

                // Close the ServiceHostBase to shutdown the service.
                serviceHost.Close();
            }
            catch (CommunicationException ce)
            {
                Console.WriteLine("An exception occured: {0}", ce.Message);
                serviceHost.Abort();
            }
        }
    }

Can you tell me where i am going wrong?
ASKER CERTIFIED SOLUTION
Avatar of surajguptha
surajguptha
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of x1877

ASKER

I am a beginer in the subject. I have tried the wcf samples from msdn. Now i am just trying to change the binding to NetTcpBinding from WSHttpBindingBase. What all i need to change if i change the binding from  WSHttpBindingBase to NetTcpBinding ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of x1877

ASKER

Thats going to be my next try, i mean keeping the binding info in config file.

Regarding my question,  I dont know why i am getting the error. i feel i need to change something on   "//Enable metadata exchange" part to generate the proxy using svcutil.exe
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of p_davis
p_davis

as surajguptha has said you will need to add a new mexHttpbinding endpoint to expose this service for the svcutil to use.

the service will have to have the service behavior getHttpenabled

the easiest way , imho, is to download the sdk from microsoft and use the configruation editor
Avatar of x1877

ASKER

Thanks for all your support.
Finally got it running. I was making mistake at 2 places.
1.                 smb.HttpGetEnabled = true; This was not there
2.                 smb.HttpGetUrl = new Uri("http://localhost:8001/ServiceModelSamples/Service");
This one was using port 8000 like  smb.HttpGetUrl = new Uri("http://localhost:8000/ServiceModelSamples/Service");
which was already used by baseAddress on the top.



Avatar of x1877

ASKER

sorry p_davis: I could not try configruation editor