4

Disclaimer: My experience/knowledge of web services is very limited.

There is an existing web service WSDL that I have reverse engineered with wsdl.exe to create a C# proxy class.

Using Visual Studio 2008 I created a default web service template.

How do I reference the generated proxy class so that it will work in the web service?

For example -> calling http://localhost/webservice/service.asmx?WSDL will return the details from the proxy class.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
John M
  • 14,338
  • 29
  • 91
  • 143
  • 1
    Are you trying to write an application which calls the web service defined by the WSDL you have, or are you trying to write a web service which provides the interface defined in the WSDL, so that something else can call your service? – Saxon Druce Jul 07 '10 at 02:55
  • @Saxon - I'm trying to only do what the current web service does but with fixed paths (URL,file) which are currently wrong. – John M Jul 07 '10 at 02:58
  • It what way are the existing paths wrong? Can you give an example of what a path on the existing service looks like, and what you would like the path to look like? – Saxon Druce Jul 07 '10 at 03:04
  • @Saxon - The paths refer to an address like http://localhost/webservice1 when they should be referring to http://localhost/webserviceNEW1 – John M Jul 07 '10 at 12:20
  • Please take a look at [How to use a WSDL File to create a WCF Proxy?](http://stackoverflow.com/questions/945620/how-to-use-a-wsdl-file-to-create-a-wcf-proxy) thread. – KV Prajapati Jul 07 '10 at 03:10

1 Answers1

3

First of all, you should not be using ASMX web services. Microsoft now considers them to be "legacy technology", and suggests that all new development of web service clients or services be done using WCF. Don't start off at a disadvantage.

Secondly, the normal way to make use of a WSDL is to use the "Add Web Reference" command in Visual Studio ("Add Service Reference" if you were using WCF). This generates the proxy classes for you and adds them to your project.

I'm not sure from your question that this is what you want, since you first talk about the WSDL, but then talk about a "default web service template". What do you mean to do with the "default web service template"?


Try using the svcutil.exe program (not WSDL.EXE) as follows:

svcutil YourWsdl.WSDL /language:C# /d:subdirectory

This should produce a number of files in the subdirectory. Take a look at the .cs files, one of which will contain an interface which is the service contract. That is the interface that your service must implement. Look at your "default" WCF service application and you'll see that it does the same thing - produces an interface that is implemented by the service.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • following your advice I have create a WCF service project and then added the web reference. What other basic steps are needed to utilize the newly added web reference? – John M Jul 07 '10 at 02:51
  • @John: I'm still not clear on what you're trying to do. Are you trying to create a web service that can call another web service? – John Saunders Jul 07 '10 at 03:11
  • I am trying to recreate an existing web service that I don't have the source code for. The web service receives XML messages and then saves them into a folder on the receiving folder. I'm primarily just trying to figure out what elements are needed to create a web service. – John M Jul 07 '10 at 11:54
  • 1
    @John: Ok, that's the confusion. A WSDL is usually used to create a Web Service _client_, not to create a service. – John Saunders Jul 07 '10 at 17:39