Best Practices, Makes Perfect

One of the biggest mistakes that many developers make when working with WSDL is defining operations and messages that are too fine-grained. By doing so, developers usually define more than they really need. You need to ensure that your web service is coarse-grained and that the messages being defined are more business oriented than programmatic. You shouldn’t define a web service operation for every Java method you want to expose. Rather, you should define an operation for each action you need to expose. Deciding what to expose in your web service requires a methodological rather than a technical mindset.

The natural tendency for a developer is to treat a WSDL document like code because it describes the operations and types for the web service. It’s not code, though—it’s metadata about code. Take care not to include anything that a service requestor doesn’t need to know to invoke the web service.

For maximum interoperability and platform neutrality, use XML Schema as your type system whenever possible. If your WSDL is publicly visible, imagine that it is part of a workflow that you do not get to define. It is entirely feasible that the web service your WSDL describes is upstream or downstream of other actions and that a tool uses the WSDL document to instrument it. Realize that your service hasn’t necessarily succeeded when the particular application you’re developing works; the real test of a successful web service is when other applications that ...

Get Java Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.