WSDL Best Practices

I am developing a SOAP application that integrates with a third party. I think the WSDL of this third party is very strange. I am new to SOAP, so I do not want to ask them to fix it if it is not broken. Here are some things that I noticed that I am mistaken about this, although I am sure that this is a technically correct document (hence the reason why I wrote "best practices" in the title). In addition, I use gSOAP as my SOAP library, and so I think some of these things are weird (I'm even new to gSOAP than I am to SOAP in general).

  • they have interfaces specified for both SOAP 1.1 and SOAP 1.2 in the same WSDL. This forces gSOAP to generate twice as many classes as needed, since I will use only 1.2.

  • all their namespaces are http://tempuri.org . That shouldn't be so, right?

  • Despite defining many RPC calls, their WSDL uses a document format. I am thinking of asking them to switch to the RPC format, because it seems that gSOAP will not generate methods that take C ++ - typed parameters for the document format. Instead, it creates a new class for each entry and response of the API data. I will have to write another wrapper layer around the gSOAP material to provide a reasonable API to the rest of my applications if I cannot fix it. Also, AFAICT, the XML that will go back and forth, will be the same as it is now if they switch to RPC, so I don’t think it will be difficult.

  • the elements have minOccurs = 0, but when I send requests without them, I return errors indicating that they are required (sometimes even null pointer exception trace stacks). They should specify them as minOccurs = 1, if they are required, right?

  • almost all web service functions define a response that includes an integer indicating success (truly logical) and an error message line. Should they use SOAP errors for this? I think it would be easier if my application was processed, if it was an error, since gSOAP will make me easy to understand (and print the error message is trivial).

Of course, I don’t have much hope that this third-party company will change its WSDL just because I asked for them. At least I will find out something ... all that I know, none of this is wrong or even dubious. Thank you for your help.

+4
source share
6 answers

1 - They probably consider this feature. :-)

2 - This is terrible.

3 - Many recommend this. It is called a wrapped format.

4 - You are right.

5 - It depends. Theoretically, you are probably right, but in practice many SOAP tools do not support SOAP errors very well, so they may have intentionally decided not to use exceptions.

+2
source

I would like to get a more general idea of ​​the best methods for creating WSDL:

1. First contract contract
Unlike James, I would particularly emphasize the use of the Contract-First method, since it allows the developer to use all the XML features (restrictions, templates ...), and from there it is quite easy to generate code for any programming language. Another reason is that the scheme in <wsdl: types> is a contract between two systems talking to each other. If a developer creates WSDL from code, technical dependencies can be introduced in a specific programming language (data types ...).

2. Document / literal style
Validating SOAP-encoded SOAP can be complex, XPATH queries and XSLT transformations are simply not possible, and this style is not recommended anyway.

RPC / literal also causes problems with XML validation (an account for a specific convention name). Some SOAP mechanisms discard schemas, specific namespaces, so validation becomes impossible.

Using the Document / literal style, the SOAP body is completely processed as an XML document that can be validated, converted, and requested in a standard way.

3. Separation of problems
Separate the schema definition from the WSDL file itself using <import ..> and <include. > directives. This promotes reuse of schemas and separation of namespaces into different .xsd files, and also reduces file size;)

+3
source

It sounds the same as the third party you are trying to interact with and does not know web services.

From your description, this sounds very typical for implementing a Microsoft ASP.NET web service, a third party writes a little VB or C # for the interface, what they can offer, push it to the ASP.NET server and name it day, depending on the ASP mechanism .NET to automatically generate WSDL on demand.

You can ask them not to provide SOAP 1.1 definitions, but I don’t think they will help you because they don’t know how to do it. You could ask them why the namespace is tempuri.org, and I’m sure that their answer would be something like “Will we have to learn this” when they really want to say this “Is this ??” because they don’t know why.

The namespace is controlled by the compiler directive in the code, and tempuri.org is Microsoft's default default (don't remember what it called atm sorry). Of course, the value of the namespace doesn’t really matter much (other than just weird), because in fact it is simply intended to provide a unique string identifier for resolving variable names. Perhaps other things can be controlled in a similar way, I don’t know, I really don’t know web services or ASP.NET or any of these materials, and not a big fan of this technology.

+2
source

Connect to this just now and find that you need to spell the prefix correctly, the prefix should be executed after TWO contus underscore 'youtns__methodname "

eg

 typedef double xsd_double; int ns__add(xsd_double a, xsd_double b, xsd_double &result); int ns__sub(xsd_double a, xsd_double b, xsd_double &result); int myns__sqrt(xsd_double a, xsd_double &result); 

this will lead to the creation of two wsdl files after running soapcpp2: ns.wsdl and myns.wsdl

But you define your method like this (one underscore)

 int ns_add(xsd_double a, xsd_double b, xsd_double &result); // wrong 

spapcpp2 will not generate anything.

+1
source

What you are facing is a typical third-party laziness when creating your web services. I would suggest that you are out of luck with them, but you can edit the WSDL to remove the definitions 1.1.

0
source

Firstly, no one writes WSDL - generated by tools. Vendor tools are likely to insert CORRECT URLs for the namespace and probably have some switches saying - V1.0, V1.1, Both. The provider probably had some existing code without SOAP and used some tools to port them as a SOAP service.

No one writes WSDL, so you should not read it! Get a decent set of tools, something like SOAPUI will decrypt WSDL and allow you to view it without banging your head. Its Java, but its the best testing tool in any language you code.

My experience with SOA is mainly based on Java, where you are free from the choice of libraries and tools. C ++ is probably less mature in this area, but it seems that the problem is with the tool selection and not the WSDL. In the real world, you will be presented with a less perfect WSDL, so your tool should be able to deal with it in a reasonable way.

0
source

All Articles