wood burning stoves 2.0*
The moose likes Web Services and the fly likes searching for a  simple example for practising creation of Contract First Soap web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "searching for a  simple example for practising creation of Contract First Soap web service" Watch "searching for a  simple example for practising creation of Contract First Soap web service" New topic
Author

searching for a simple example for practising creation of Contract First Soap web service

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 594
I have done examples for creation of Code First web service. Now I am searching for a simple example for Contract First web service. I am searching for a simple example on that. I tried searching but at most links I found examples of Code first web service not contract first web service. Where can I find it?

thanks...
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1080
    
    1

Hi
Below mentioned are the steps involved in writing Contract first Web service based on JAX-WS stack

1. First give a thought to web service objective, it's input and output parameters.
For example - let us say we want to build a web service for Temp conversion (from celsius to fahrenheit and from fahrenheit to celsius ). So we would need two web methods convertToFahrenhiet(double celsius) and convertToCelsius(double fahrenheit).

2. Create XSD files which defines input and output parameters of these two operations.

3. Then build a WSDL file with these two operations convertToFahrenhiet and convertToCelsius. Along with it, also defines all necessary tags in WSDL like Service, SOA Binding, Service etc.

4. Once you have WSDL File, generate JAX-WS classes using wsimport uitlity of JAX-WS. This shall generates Java classes from WSDL.

5. In those generated classes, there shall be one interface which corresponds to Port defined in WSDL File. You need to implement that interface. On implementation, you shall get convertToFahrenhiet(double celsius) and convertToCelsius(double fahrenheit) methods. You just need add actual implementation logic (in this case, code logic to perform temp conversion).

That's it , now you have end to end working Web Service with Contract First approach.

Thanks
Abhay Agarwal

Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
Tex Martin
Greenhorn

Joined: Sep 09, 2010
Posts: 7
    
    1

Hi Monica
I certainly understand your frustration. I was in the same situation this summer.
My breakthrough was reading a blog entry by Roger Goossens. It helped me to create a very simple example of a contract first webservice.

I made a blog entry myself, describing the various difficulties i experienced and how i overcame them. I think it might be what you are looking for.

The practise assignment could then be: Implement a webservice to convert between degrees celsius and degrees fahrenheit (and vice versa) along the lines mentioned in Abhay's answer. Please publish your answer (or a link to your answer) here, for the next frustrated java web service newbie to find.

Hope it helps...

Happy hacking.

Cheers
Tex Martin


SCJP, SCWCD
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 594
thanks all. Let me try it.
Tex Martin
Greenhorn

Joined: Sep 09, 2010
Posts: 7
    
    1

I cloned the BeerExpert web service, and changed it into a Celsius-to-Fahrenheit conversion web service, according to the bullet list in Abhay's answer to your original question.
In case you get stuck, you can browse The code at my bitbucket account.

I will probably add gradle build files to the project - that's where my focus is at the moment.

Happy hacking

Cheers Tex
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 594
thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: searching for a simple example for practising creation of Contract First Soap web service
 
Similar Threads
Axis 2 Vs Spring Web Services stack
Help regarding Metro
Types of webservices
Axis2 Vs. CXF
How do WSDL and services.xml relate