jQuery in Action, 3rd edition
The moose likes Web Services and the fly likes Schema for Web service types ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Schema for Web service types ? " Watch "Schema for Web service types ? " New topic

Schema for Web service types ?

amol deshpande
Ranch Hand

Joined: Sep 05, 2003
Posts: 162

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.

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
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).

Best wishes!

My free books and tutorials: http://www.slideshare.net/krizsan
amol deshpande
Ranch Hand

Joined: Sep 05, 2003
Posts: 162
Thanks Ivan,

I'll try and see if that works for me.

wood burning stoves
subject: Schema for Web service types ?
It's not a secret anymore!