Invalid WSDL - and the answer is ...

I forgot to provide the answer on last quizz about invalid WSDL, and XML tips.

The WSDL in question:

The issue: by mistake, I did reuse the same prefix for two namespace. The tns prefix is associated with ''
at the global scope (wsdl:definitions) and reused with ''
at the schema scope (xsd:schema element).

In the wsdl:part, element="tns:create-account" references an element named {}create-account, which is not found. Based on the schema's targetNamespace, the QName (qualified name) of the element is {}create-account.

There are two ways to fix this error:
  1. Uses the same targetNamespace URI (and tns prefix) for both WSDL and Schema elements. Keep It Simple as much as possible.
  2. Introduce a new prefixe in your wsdl:definition element (xmlns:types="") and uses the newly introduced prefixe to reference elements defined in your schema (element="types:create-account"). It's not a bad idea to avoid reusing the same prefix with different URI in a single document. That way, you will avoid this pitfall.
Remember: Keep It Simple, Stupid.

Here is today's WSDL: Can you spot the mistake?

I agree, it's getting a little more involved.

Have fun,

You can always get back to your favorite sudoku du jour.


Gerard said…

Although JDeveloper will happily generate me a webservice based on this document; but I think that the messgae part should reference a "element" rather than a "type" in the case of document/literal.

The WS-I analyzer would pick up this issue. Might be worth raising a bug so we can flag this in the code editor.

Ecco said…

You got this one right. I'll have to try using WS-I tool and see what error message we do get.

I'll have to see what we get on the server side with top-down assemble.

More next week...


Popular posts from this blog

Changing the version of JDK used by JDeveloper

Connection reset from a WCF Web Service

Test locally first, then deploy to the cloud.