Is it more or less acceptable (i.e. standard) to create a publicly-exposed web service with these method signatures:
ThisMethodDoesSomething(ComplexType param)
ThisMethodDoesSomethingElse(AnotherComplexType param)
Or this:
ThisMethodDoesSomethingAndSomethingElse(string xml)
Where the operation being performed depends upon the XML string passed to a single does-it-all method? I have always gone with the former, but a coworker of mine prefers the latter and I'm trying to weigh pros and cons of both strategies before we begin a new project. Which is more accepted and easier for the public to work with and why?
It means you can pass an arbitrary number of arguments to the method (even zero). In the method, the arguments will automatically be put in an array of the specified type, that you use to access the individual arguments.
I would never send an XML string. First of all, "XML" is not the same thing as "string". They do not follow the same rules.
Any reasonable client can accept a complex type consisting of primitive types and lists or arrays of primitive types, recursively (C# syntax):
public class ComplexType1
{
public int IntegerProperty {get;set;}
public int[] ArrayOfIntegers {get;set;}
public List<int> ListOfIntegers {get;set;} // Same as ArrayOfIntegers
}
public class ComplexType2
{
public ComplexType1 CT1 {get;set;}
public List<ComplexType1> LCT1 {get;set;}
}
Frankly, any client that can't deal with something like the above deserves to be retired.
Formerly I would have prefered the latter, because I wasn't sure, if in cross platform situation, every SOAP client would be able to consume the complex types properly. So I thought a SOAP call, that just takes and returns (XML-)Strings will give me no headache. In the meantime I experienced there is generally no problem with the first approach at least for .Net interoperating with JAVA/AXIS and vice versa. I'm still watching to make the complex type not too complex though.
I assume that ThisMethodDoesSomething()
and ThisMethodDoesSomethingElse()
are atomic operations? If this not the case (ThisMethodDoesSomethingElse()
requires a call to ThisMethodDoesSomething()
to execute), the first approach is a no go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With