Search code examples
soapwsdlgsoap

WSDL best practices


I'm developing a SOAP application that integrates with a 3rd party. I think the WSDL of this third party is very strange. I'm pretty new to SOAP, so I don't want to go asking them to fix it if it isn't broken. Here's some things I've noticed that I consider wrong about it, though I'm sure it's technically a valid document (hence the reason I wrote "best practices" in the title). Also, I'm using gSOAP as my SOAP library, which may be why I think some of these things are weird (I'm even newer to gSOAP than I am to SOAP in general).

  1. they have interfaces specified for both SOAP 1.1 and SOAP 1.2 in the same WSDL. This causes gSOAP to generate twice as many classes as it needs to, since I'm only going to use 1.2.

  2. all of their namespaces are http://tempuri.org. That shouldn't be like that, right?

  3. despite defining a bunch of RPC calls, their WSDL uses the document format. I'm thinking of asking them to switch to RPC format because it seems that gSOAP won't generate methods that take C++ typed parameters for document format. Instead, it creates a new class for every API function's input and response data. I'll have to write another layer of wrapping around the gSOAP stuff to provide a reasonable API to the rest of my app if I can't fix that. Also, AFAICT, the XML that will be going back and forth would be exactly the same as it is now if they switched to RPC, so I don't think it would be difficult.

  4. elements have minOccurs = 0 yet when I submit requests without them, I get errors returned back indicating they're required (sometimes even stack traces of null pointer exceptions). They should specify them as minOccurs = 1 if they're required, right?

  5. nearly all of the web service functions specify a response that includes an integer to indicate success (really a boolean) and an error message string. Should they be using SOAP faults for this? I think it would be easier for my application to handle if it was a fault since gSOAP will let me figure that out really easily (and print the error message trivially).

Of course, I don't have high hopes that this 3rd party company will change their WSDL just because I've asked them to. At least I'll learn something... for all I know, none of these are wrong or even questionable. Thanks for your help.


Solution

  • 1 - They probably consider this a feature. :-)

    2 - That's horrible.

    3 - Lots of people recommend this. It's called wrapped format.

    4 - You're correct.

    5 - It depends. Theoretically, you're probably correct, but in practice lots of SOAP toolkits don't have very good support for SOAP faults, so they might have deliberately chosen to not use exceptions.