File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Monica Shiralkar
Ranch Hand
Posts: 825
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1375
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tex Martin
Greenhorn
Posts: 10
1
Eclipse IDE IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Monica Shiralkar
Ranch Hand
Posts: 825
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks all. Let me try it.
 
Tex Martin
Greenhorn
Posts: 10
1
Eclipse IDE IntelliJ IDE Java
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 825
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic