Dynamic implementation of WSDL in C #

I am relatively new to web services on .Net, so I apologize if this is a question like newbies.

I found many resources on how to implement web services in a .Net project, but they all seem to include a static definition of public methods. Although this may be appropriate for some applications, it is not suitable for billing for what I need.

I am wondering if there is a way to dynamically implement methods open in WSDL, like PHP SoapClient this?

+4
source share
1 answer

WSDL does exist to help determine the names and parameters of a method and mask all HTTP headers for you, the developer.

It looks like you want to specify the method name and parameters at runtime. Perhaps the way around this is to completely forget about WSDL in general. Make your own HTTP calls.

 HttpWebRequest req = (HttpWebRequest)WebRequest.Create( "http://foo.com/Some.asmx"); //build string from .config instead. //here Register is the name of the method. take yours from config as well if needed req.Headers.Add("SOAPAction", "\"http://tempuri.org/Register\""); req.ContentType = "text/xml;charset=\"utf-8\""; req.Accept = "text/xml"; req.Method = "POST"; 

For more information, see Calling a Web Service Dynamically Using HttpWebRequest .

As for the .NET web services wrapper classes in general, they are trying to help secure server contracts with the client. Obviously, you are trying to avoid changing statically typed clients, as shown in the .NET wrapper classes. I hope this will not be too burdensome for you.

+7
source

All Articles