This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
In attempting the Top Down approach, we create WSDL first and then Java code. So here we need to specify the schema we will be using
for operation and messages.
What I'm considering is how do we develop schema which will be used in WSDL? We can hand create a schema according to our need and
run wsdl2java which willl create Java Types for them.
Or we can even create Java first, use a tool to convert to schema, then use that into WSDL type. So this is a mixed kind of strategy for Web services.
(Top down and Bottom Up).
Although approach 1 seems to be good, the second one also is appealing, but I've not come across a tool doing so, which we can integrate in build process. What do think?
I'm still kinda inclined to first approach.
The mixed approach is indeed less complicated and enables at least me to more quickly get started with the XML schemas, which I then can adjust as required.
To create an XML schema from Java code, I use the following approach:
- Develop a code-first Java web service with annotations (continued in next step).
The method implementation(s) does not have to do anything, just enough as not to cause compilation errors.
- For parameters and return values that you want to obtain XML schema types for, create Java bean classes.
- Use the Java bean classes as parameter types and/or return types where appropriate in the web service implementation class.
- Use wsgen (included in JDK 6) or deploy the web service to, for instance, GlassFish.
This will cause the WSDL and associated XML schemas to be generated.
- Use the generated XML schemas in your WSDL-first development (after having done any adjustments).