-
Notifications
You must be signed in to change notification settings - Fork 0
guide soap
SOAP is a common protocol for services that is rather complex and heavy. It allows to build inter-operable and well specified services (see WSDL). SOAP is transport neutral what is not only an advantage. We strongly recommend to use HTTPS transport and ignore additional complex standards like WS-Security and use established HTTP-Standards such as RFC2617 (and RFC5280).
For building web-services with Java we use the JAX-WS standard. There are two approaches:
-
code first
-
contract first
Here is an example in case you define a code-first service. We define a regular interface to define the API of the service and annotate it with JAX-WS annotations:
@WebService
public interface TablemanagmentWebService {
@WebMethod
@WebResult(name = "message")
TableEto getTable(@WebParam(name = "id") String id);
}
And here is a simple implementation of the service:
@Named("TablemanagementWebService")
@WebService(endpointInterface = "io.oasp.gastronomy.restaurant.tablemanagement.service.api.ws.TablemanagmentWebService")
public class TablemanagementWebServiceImpl implements TablemanagmentWebService {
private Tablemanagement tableManagement;
@Override
public TableEto getTable(String id) {
return this.tableManagement.findTable(id);
}
Finally we have to register our service implementation in the spring configuration file beans-service.xml
:
<jaxws:endpoint id="tableManagement" implementor="#TablemanagementWebService" address="/ws/Tablemanagement/v1_0"/>
The implementor
attribute references an existing bean with the ID TablemanagementWebService
that corresponds to the @Named
annotation of our implementation (see dependency injection guide). The address
attribute defines the URL path of the service.
For testing SOAP services in general consult the testing guide.
For testing SOAP services manually we strongly recommend SoapUI.
This documentation is licensed under the Creative Commons License (Attribution-NoDerivatives 4.0 International).