Thursday, February 28, 2013

Detyped WS contract browsing and endpoint invocation

In response to some good feedback received from the community after the recent 2.0 release, I've been enriching the API of Wise Core to further simplify ws testing using it.
Till now the Wise core API has fundamentally been based on the WSEndpoint, WSMethod, WebParameter abstraction:
A given WSDL contract is mapped to at least one WSEndpoint instance having one or more WSMethod instances. Each WSMethod can have multiple WebParameter objects depending on the WSDL operation signature. By inspecting the type information in WebParameter instances, the user is meant to build the actual objects to be passed as arguments to WSMethod:invoke(Object args). While effective, this might turn out to be not very practical and easy (due to reflection, see here) if the consumed WSDL contract is complex and includes multiple nested schema types.
It's well known that Wise core supports Smooks transformations, with the sake of allowing conversion of existing application data models into the object structure required for performing the invocation. However that's not really helping a lot when the target is programmatically testing a given endpoint.
In particular some users expressed the interest in the tree view offered by the Wise GUI on top of the core model: similarly to what is shown in the GUI, a tree model (think about e.g. the DOM tree approach) could be provided to describe each parameter type of a given WSMethod. Each element of the tree would allow getting children and setting values (for leaves only). So here is what I came up with: The current Wise core 2.0.1-SNAPSHOT features an implementation of the Element interface above, as well as a builder implementation for converting a WebParameter into an Element tree:
The end result is in a really simplified contract browsing of a WS endpoint as well as simple invocation (see the integration test here too):
The tree view can of course be used to convert and access the data returned in the InvocationResult instance.
Please note how the parameters type info is completely hidden to the user, who basically ends up setting string values for leaves elements. Strings are parsed into proper primitives (and wrappers) depending on the actual parameter type. Wise default Element impl is currently able to convert values to String, Character, all numerical types, QName, XMLGregorianCalendar and Duration classes.
So, leveraging Wise, a user can invoke / test an endpoint by browsing its contract and setting parameters in a fully dynamic and detyped way, while still being sure the generated SOAP request is compliant with the contract requirements and constraints.

The additions described above are currently being tested and will be included soon in next release. Any comment / feedback is welcome as usual!