1

I need to publish a webservice that take a variable number of parameters. My problem is that the caller can send only simple parameters (primitive datatype) not xml, array or lists.

So i would like to dynamically generate wsdl so that if the caller try to access my webservice eg http://myendpoint:myport/baseWsName_numberOfParameter?wsdl then a wsdl with a customizable number of parameters is served (and the caller can use that versione of WebService), the parameters can be all of type strings in my scenario

I would like to avoid to manually define a huge number of overload one for any reasonable number of parameters.

Skary
  • 1,322
  • 1
  • 13
  • 40
  • 1
    You can pass an array as parameter. – Reza Aghaei Sep 24 '15 at 14:37
  • what is the problem with for example – BRAHIM Kamel Sep 24 '15 at 14:39
  • @Reza absolutley no, as stated in the question, the caller does not support array but only simple parameters of primitives types. – Skary Sep 24 '15 at 14:59
  • @Skary What kind of client can't support array as parameter? You can take a look at [this link](http://stackoverflow.com/questions/12991703/passing-string-array-to-webservice-method) – Reza Aghaei Sep 24 '15 at 15:14
  • @Reza i work with a third party program (used by my customer) that can send parameters to any webservice, but only int, string or boolean. No array is supported and i would avoid strange thing like string concatenation (or CSV) for simulate array – Skary Sep 24 '15 at 15:14
  • @Skary If I understand your question correctly, IMHO using such dynamic webservice is more strange ;) and if the client can't pass array, using a comma separated string is a good option. – Reza Aghaei Sep 24 '15 at 15:17
  • 1
    @Skary Also you may find this link useful: [Creating and exposing a SOAP service and its WSDL dynamically in C# (with a custom TCP listener!)](http://stackoverflow.com/questions/11549498/creating-and-exposing-a-soap-service-and-its-wsdl-dynamically-in-c-sharp-with-a) – Reza Aghaei Sep 24 '15 at 15:30
  • @Reza that's really interesting, thanks i suppose i made something configurable in that way. – Skary Sep 24 '15 at 15:44
  • @Skary I posted an answer based on comments, to be more useful for future readers. Hope you find it helpful. – Reza Aghaei Sep 24 '15 at 15:52

1 Answers1

1

If I understand your question correctly and if the client can't pass array, while using a comma separated string is a good option you can use AppDomain.DefineDynamicAssembly and ServiceDescriptionReflector as used in Creating and exposing a SOAP service and its WSDL dynamically in C#

Community
  • 1
  • 1
Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
  • 1
    Thanks it seems a good idea, these day i try to implement it. I'll let you know if it work as expected. – Skary Sep 24 '15 at 16:16