10

I am having problems gaining access to a clients web service online.

If I have the wsdl file, can I do "something" in VS2010 with it so I can add it as a reference and start my C# coding?

Thanks Paul

Paul Brown
  • 4,926
  • 9
  • 32
  • 44
  • If there is anything else that needs to be answered to close out this question, please let us know. – xelco52 Aug 21 '12 at 18:01

3 Answers3

27

When you go to "Add Service Reference", the textbox that allows you to enter a URL, can also take a path on your local filesystem to a wsdl.

Additionally, while not the optimal route, you can also use the wsdl.exe/svcutil.exe utility (bundled with VS) to generate a proxy class. Adding a reference is the better way to go, but this is an additional option.

xelco52
  • 5,257
  • 4
  • 40
  • 56
  • 2
    Yup. Thanks for clarifying. I said it was "not the optimal route" and "Adding a reference is the better way to go". Maybe I should have been more forceful. – xelco52 Mar 08 '11 at 03:32
  • 13
    +1 there is no reason to downvote an answer for acknowledging the sledgehammer option exists as an ancillary option. – Chris Marisic Apr 26 '11 at 18:46
3

Adding the Service Reference as a local path worked for me like a charm. I would have voted +1 for xelco52, but my rep is too low...

Only 1 issue; one of my members of the class I've added does not work. I wonder if I need to use the sledgehammer...?

Taersious
  • 751
  • 9
  • 20
  • Follow-up: Visual Studio 2010 with a project set in Framework > 2.0 will not let you add Web Reference. If you save, set in Framework 2.0, save, add Web Reference, save, reset back to original, and save, the Web Reference will remain and function as expected. – Taersious Jul 07 '11 at 19:50
0

If you have the WSDL file, under one of your projects in VS, right-click the References project folder and choose Add Service Reference. Click the Advanced button, and in the new dialog click Add Web Reference. Now, go find the WSDL file, either where you saved it or where you downloaded it, enter its location in the textbox, and click Go. VS will digest the WSDL and produce a class that is the service client, and others as necessary to implement custom types accepted by the service.

It's usually a good idea, if you have downloaded the WSDL, to include it as an item in the project that has the web reference; that allows it to be easily traversed as a reference source, and to be located should you need to recreate the web service classes.

KeithS
  • 70,210
  • 21
  • 112
  • 164
  • ty for your response, whats is the difference between adding it as a service ref or going to advanced and adding it as a web ref? thanks Paul – Paul Brown Mar 04 '11 at 22:43
  • Add Web Reference is a wrapper over wsdl.exe and creates proxies for .NET 1.1 or 2.0 clients. Add Service Reference is a wrapper over svcutil.exe and is used to create .NET 3.0+ clients. – xelco52 Mar 04 '11 at 22:48
  • 1
    -1: so why would you suggest he ever use "Add Web Reference"? – John Saunders Mar 05 '11 at 01:39