From the course: Java EE 8: Web Services

Your first SOAP web service - Java EE Tutorial

From the course: Java EE 8: Web Services

Start my 1-month free trial

Your first SOAP web service

- [Instructor] Let's raise the bar with SOAP web services. In this video, we're going to take the simplest path to creating a JAX WS web service. I've gone ahead and duplicated our rest resource from earlier. Here's our rest resource. It's got the get it method and the salute method. And here is the POJO I created, same methods, get it and salute. Slightly different class name. Calling this my SOAP endpoint. What's next? I'm now going to create a JAX WS service, using what's known as a code first approach. We have our SOAP endpoint class here. How to SOAP this up? We just add the at web service annotation, here on line eight. Let's fix the import. Be sure to import it from the javax.jws package. There we go. And that's it. We save that. We deploy it to pay our application server and see how it goes. There we have it. Now to confirm that everything went smoothly with deploying our SOAP web service, simply type in the name of the SOAP resource class, followed by the word service. So our SOAP resource class here is called my SOAP endpoint. We want to come here into the in eclipse browser, type in my SOAP endpoint. It's case sensitive. So you have there my Soap endpoint. And then add the word service. What you get is this webpage that lists all the available SOAP web services. This is automatically generated, you don't have to do any new work for it. Now what's next? Let's view the WSDL for our SOAP web service. You remember the WSDL, right? That's a document that describes our SOAP web service in it's entirety. To view the WSDL for this web service, I'm going to click on the link that's generated here. And there you have it. Our SOAP services WSDL document. You can go to the WSDL directly by simply adding a question mark and the word WSDL. That's your resource name, my SOAP endpoint service, question mark and WSDL. And it'll give you the same results. With me so far? Good. So what we see here is the automatically generated WSDL file that's confirming that our SOAP web service was successfully deployed and open for business. From here on out, we could either download the WSDL file by saving this document, or pass around the full URL to any prospective clients of our web service.

Contents