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?
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.
Oracle certified JPA Developer (1Z0-898),Oracle certified Java 8 Programmer I (1Z0-808), 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, CIW Certified Ecommerce specialist
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.
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.
posted 5 years ago
thanks a lot.
moose poop looks like football shaped elk poop. About the size of this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database