#
Create a Java Web Service (SOAP RPC) for WildFly
This tutorial explains to you how to create a simple Java Web Service using SOAP RPC style deployed as a Web Application on WildFly. This Java Web Service will be deployed on a Java Application Server (WildFly 10.1).
In order to create a simple JAX-WS example using the RPC style for a Java Application Server (WildFly for instance), I will create a "Hello World" example. A Web Service can be deployed "standalone" (without an application server) and on an application server. In my case the JAX-WS using RPC style will be deployed on WildFly Java Application Server. Creating a Web Service (RPC Style) is very simple.
I will create an interface:
package ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorldServerInt {
@WebMethod
String sayHelloWorld(String name);
}
I will create the implementation of the interface:
package ws;
import javax.jws.WebService;
@WebService(endpointInterface = "ws.HelloWorldServerInt")
public class HelloWorldServerImpl
implements HelloWorldServerInt {
public String sayHelloWorld(String name) {
return "Hello World ! My name is " + name + ".";
}
}
Creating a "Publisher" class for publishing the web service is not needed.
Once the Web Application is done under Eclipse or NetBeans you have to generate the .war file and deploy it on the WildFly Server. At this point your JAX-WS must be running. For more details regarding the war file deployment you can take a look at the "Deploy a JAX-WS on WildFly Server" article.
Here are some remarks:
The service endpoint interface
(SEI) is a Java interface class that defines the methods to be exposed as a Web service.
@WebService
annotation define this class as SEI@SOAPBinding
add information about the form of the JAX-WS messages:
Info
- Style.RPC : the messages to/from JAX-WS use parameters/ values
- Style.DOCUMENT : the messages to/from JAX-WS use complex XML
- Use.LITERAL : the messages are serialized according to the XSD (XML Schema)
- Use.ENCODED : the messages are serialized according to SOAP data model (in this case we cannot have a XSD validation)
- ParameterStyle .WRAPPED : how the WSDL is created : wrapped style (not very important)
- ParameterStyle .BARE : how the WSDL is created : bare style (not very important)
@WebMethod
: this method can be called through the Web.You can deploy the Web Service on an Application Server. In this case you don't need a Publisher Class.
When you publish the web service, you can see the WSDL at the following address :
http://localhost:8081/helloworld?wsdl