We help IT Professionals succeed at work.

Error while running svcutil.exe

x1877
x1877 asked
on
3,703 Views
Last Modified: 2013-12-17
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?
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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 ?
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
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

Author

Commented:
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.



Author

Commented:
sorry p_davis: I could not try configruation editor

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.