Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Generate dynamic in memory Web service in .NET

1) I'd like to create web services on the fly using reflection.
2) I'd like the web services to be searchable and emit WSDL spec's on themselves like normal web services.
#3) Basically, I want to have my code generate web service functions based on some database data, and create the definitions in memory and expose them on the server.

Is this possible?
0
drinkwater
Asked:
drinkwater
1 Solution
 
ripahoratiuCommented:
It is but is not the best approach.
1. You can create on the fly any kind of classes with Reflection, and their associated asmx.
2. You can query than the .asmx with http://yourserver/yourservice.asmx?WSDL. That will basicaly generate the wsdl and disco
3. You can run on client wsdl.exe tro have your proxy generated.

BUT
1. Be carefull to NOT use the directories in IIS, the app will restart
2. You cannot reference the proxies, as their signature may change
2. Wouldn't be better if you just create simple dll's (the ones that you keep in DB) providing some functionality. Than do a single service called, let's say, "InvokerService" which provides you methods to create objects and invoke their methods (you can even play with their statefull/stateless behaviour, by storing them in Session), and an InvocationResult class to embed the responses, and ensure serializability. Than you may use Assembly.Load, Assembly.Invoke on server side, and you have a fixed proxy on client side that exposes things like:
GUID objectGUID = InvokerService.LoadOnServer("myclass");
InvocationResult respose = InvokerService.InvokeMethodOfStatefullObject(objectGUID, "themethod", object[]...)
InvokerService.Unload("myclass");
or stateless
InvocationResult respose = InvokerService.InvokeMethod(objectGUID, "themethod", object[]...)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now