views:

1671

answers:

4

This is maybe a really simple question, but I couldn't locate an answer:

For a client I need to HOST a webservice. The client has sent me a wsdl file that the webservice should 'implement'. How do I go about that? I've generated any number of client-rpoxies but this is the other way around. I can use both ASP.NET 2.0 webservices or Windows Communication Foundation.

+5  A: 

wsdl.exe /server.

Generates an abstract class for an XML Web service based on the contracts. The default is to generate client proxy classes. When using the /parameters option, this value is a element that contains "server".

You can do a similar thing with svcutil.exe for WCF- something like:

svcutil.exe thewsdl.wsdl /language:c# /out:ITheInterface.cs (I've not tested this).

Edit- John Saunders makes a good point in his answer to favour the WCF approach- I recommend this too.

RichardOD
Is it really that simple? I've used wsdl.exe numerous times but didn't know about the /server switch. I'll test and report
edosoft
Yeap. WSDL first development is a valid approach- see this article: http://blogs.msdn.com/dotnetinterop/archive/2008/09/24/wsdl-first-development-with-wcf.aspx
RichardOD
A: 

You can use the wsdl utility from microsoft to generate the server interfaces and implement them

Here is a short description of the WSDL utility.

wsdl.exe - Utility to generate code for xml web service clients and xml web services using ASP.NET from WSDL contract files, XSD schemas and .discomap discovery documents. This tool can be used in conjunction with disco.exe.

Pradeep
A: 

You can do plenty with that WSDL (wissd'le) file.

From doing the WS Class manually to use the Auto Generated class from wsdl.exe

let's imagine that, for your example, you have this WDSL (tooked from WebServiceX.Net)


to create a C# auto generated proxy you go to your command prompt and write:

wsdl /language:cs /protocol:soap /out:C:\myProxyScripts http://www.webservicex.net/TranslateService.asmx?wsdl

Note: inside your C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin folder you will find wsdl.exe or just do a dir /s inside your C:\Program Files\

if you want in Visual Basic, just use /language:vb or /l:vb

/language: The language to use for the generated proxy class. Choose from 'CS', 'VB', 'JS', 'VJS', 'CPP' or provide a fully-qualified name for a class implementing System.CodeDom.Compiler.CodeDomProvider.

The default language is 'CS' (CSharp). Short form is '/l:'.

This command will put inside your C:\myProxyScripts the auto generated proxy.

if your using the WSDL file in your computer, just change the URL to your full path, for example

wsdl /language:cs /protocol:soap /out:C:\myProxyScripts C:\myProxyScripts\myWsdlFile.wsdl

Note: your Generated proxy will be called the Service Name, the one you have specified, in our example, as:

<wsdl:service name="TranslateService">

I hope this helps you, understand the WSDL, the Auto Generated Proxies and that you can manage now everything in your end to fulfill your client wishes.

balexandre
+3  A: 

Actually, you should do this with svcutil.exe, not with wsdl.exe. WSDL.EXE is part of the ASMX web service technology that Microsoft now considers to be "legacy" code, which will not have bugs fixed.

John Saunders
be advise that this generates WCF code, not ASMX :)
balexandre
That's kind of the point. The idea would be to generate code that the manufacturer does not consider "legacy", and where they still plan to enhance it and fix bugs.
John Saunders
+1 from me. I should of mentioned this point in my answer.
RichardOD