views:

466

answers:

2

I have a bunch of very simple functions. Each function has one input and one output.

OutputType function func(InputType);

The types of input/output are defined in xsd schema and generated into java classes with JAXB/XJC. Now I want to expose those functions as WSDL Web service running on Geronimo.

I just took a look at Axis/WSDL2Java/Java2WSDL; I thought that is pretty in a similar way as my functions are created.

I guess, I can use Java2WSDL to generate WSDL from my function and input/output types. and then use some tools to generate server/client side binding,

Can anyone give more further suggestions? especially I have defined my input/output of functions in a xsd schema.

thanks very much.

A Summary:


These are what I have now....

Many implemented functions with one input and one outout.

public OutputType functionXXX(InputType in) { ....; return output; }

InputType and OutputType are already defined in a xsd schema (and turned into java classes with Jaxb/xjc).


What I want is....

Build Web services to execute those functions. Not to touch the code of implemented functions. And with WSDL,

+2  A: 

I found a tutorial using CXF to do what you are looking to here.

That document claims to be using a contract first approach, but it isn't exactly. When discussing SOAP-based services, contract first means creating the descriptors (WSDL, XSD) first. You then generate any code artifacts from those descriptors. You can see the comments in the original blog post for the debate about the original author's choice of words.

That being said, a contract first approach has many benefits depending on what you are trying to accomplish. See the Spring Web Services tutorial for some information about it.

laz
The situation is that we have already many implemented business logic functions which didn't run as web service, and we are going to make an "interface" to expose them. A contract first approach may not suitable for such situation. am I right? I don't want to touch or change those implemented code, even to add some Annotation.Thanks for your answer and I am going to take a look at CXF.
elgcom
+1  A: 

If you have an existing schema, with existing JAXB2 bindings for it, then in my experience Spring WebServices is by far the easiest way of exposing that as a SOAP web service. Its philosophy is "contract first", which is is exactly what you have. You don't need to generate any additional bindings, just wire up the endpoints a la Spring MVC, plug in the marshaller, and of it goes. It will introspect your schema looking for things that look like operations and expose them as WSDL operations automatically (you can tell it how to do that, if the default auto-discovery doesn't quite work).

skaffman