简体   繁体   中英

How to use proxy class generated by WSDL in web service?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM