I am creating a Java service which would take an inbound XML, applies some business logic on some of the data from the XML, and invokes a SOAP service with this and original data from the XML.
I have a sample of the inbound request XML and WSDL for the outbound SOAP service.
My plan is:
- Generate XSD from the sample inbound XML using XMLSpy .
- Generate Java classes from the XSD using maven-jaxb2-plugin.
- Unmarshal the inbound XML to JAXB object.
- Extract data from the JAXB object, apply business logic on some of them.
- Generate SOAP client by using of the SOAP WSDL document with cxf-codegen-plugin.
- Invoke the SOAP client with the data.
Here I am reading about using XSLT: xml-to-soap-transformation
Am I approaching this task correctly? Should XSLT be part of my implementation?
Thank you!
update:
The outbound SOAP services is 'document style', the WSDL includes XSD schema.
The project uses Spring framework.
The generated code looks something like this:
@WebServiceClient(name = "OrderService",
wsdlLocation = "file:/C:/......./src/main/resources/wsdl/OrderService.wsdl",
targetNamespace = "http://xmlns.some_name_space")
public class OrderService extends Service {
@WebService(targetNamespace = "http://xmlns.some_name_space", name = "OrderPortType")
@XmlSeeAlso({org.....ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface OrderPortType {
Generated client:
QName SERVICE_NAME = new QName("http://xmlns......", "OrderService");
URL wsdlURL = OrderService.WSDL_LOCATION;
OrderService ss = new OrderService(wsdlURL, SERVICE_NAME);
OrderPortType port = ss.getOrder();
CancelOrderType cancelOrderMessage = null;
CancelAcknowledgeOrderType cancelOrderReturn = port.cancelOrder(cancelOrderMessage);
ProcessOrderType processOrderMessage = null;
AcknowledgeOrderType processOrderReturn = port.processOrder(processOrderMessage);