In order to generate a C# Interface for my web service I run this tool with options:
wsdl /language:CS /serverInterface wsdl_locationThe command above generates the file "<wsdl _file_name>Interfaces.cs" in default location. Copy generated file to your web service project and create a new class implementing interface from generated file.
Example:
Let's assume we used the wsdl tool and have the generated interface for our service. The interface name is IMyServiceHttpBinding and contains the signatures of 2 methods: void foo(string text) and string goo(). Sample implementation may look as follows:
[WebService(Namespace = "http://somenamespace.com")]
public class MyService : IMyServiceHttpBinding
{
public void foo(string someText) {(...)}
public string goo() {(...)}
}
4 comments:
just what i was looking for! tks!
¡¡¡¡ me salvaste de una semana de codificacion , gracias!!!!!! m(_)m
Hi Filip,
Need some help with creating a client for a web service. I have used your example to create the .CS file. Could you kindly guide me further.
Regards,
Gaurav
Gaurav
This post describes how to implement a web service itself basing on provided wsdl.
If you want to create a client that would consume the service the easiest way to achieve that is by using Visual Studio. You simply choose to add a 'Service Reference' and then you provide the service url. VS will generate client code for you.
Post a Comment