I’ve got a custom HTTP server built in C# which accepts requests for REST services and responds with XML or JSON (depending on what the client needs). The REST services are defined at runtime from a database-based configuration, vary widely in input parameters and output types, and it’s working beautifully in production.
However, I’d like to add SOAP access to the same services, with appropriate WSDLs as well. Since the available services aren’t hard-coded, this means:
- Publishing a WSDL generated at runtime from the method definitions in the database
- Parsing incoming SOAP requests, mapping them to those definitions, and making sure the requests conform to the method signature before handling them
- Once the response is handled, creating a SOAP response meeting the WDSL to return the results
The MS documentation (and Google) documents using Visual Studio to generate web services (and WSDLs) at design time, exposing stuff using WebMethods, ASP.NET MVC etc. This isn’t what I’m looking for, as there are no method definitions from which to generate the bindings at design time.
Does anyone have any ideas (e.g. toolkits for raw SOAP parsing), and thoughts on generation of WSDLs from dynamically created method signatures, etc? Any idea how one might go about building such things if not? I’m looking to avoid re-inventing the wheel if possible.
PS: Clearly there’s standardised stuff in the .NET framework for this, since Visual Studio does it for you – any ideas how to access that at a lower level, at runtime?
To create a wsdl dynamically you can use
ServiceDescriptionReflectorFor example: for class
you can use this code
But since you’ve said
you have to create the
Typeat runtimeNow you can use
typeto create wsdlFor reading request and forming response, you can use Linq2Xml. Fiddler can give you an idea about SOAP(xml) format sent between client and server