0

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:

  1. Generate XSD from the sample inbound XML using XMLSpy .
  2. Generate Java classes from the XSD using maven-jaxb2-plugin.
  3. Unmarshal the inbound XML to JAXB object.
  4. Extract data from the JAXB object, apply business logic on some of them.
  5. Generate SOAP client by using of the SOAP WSDL document with cxf-codegen-plugin.
  6. 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);
Community
  • 1
  • 1
OSGI Java
  • 545
  • 7
  • 21

1 Answers1

0

Using XSLT for something that's just payload of a SOAP communication sounds wrong. Payload shouldn't be bothered with envelope stuff.

Take a look at the WSDL first. Modern Web Services are usually not document stype anymore, so you might be able to skip steps 1.-4.

My clients usually go through:

  1. Generate SOAP client implementation using cxf-codegen using

    <extraarg>-client</extraarg>
    <extraarg>-impl</extraarg>
    
  2. Generate a test client implementation by extending the ServiceName_Service class, getting its port object and then just call one of the methods defined in the WSDL.

Community
  • 1
  • 1
wallenborn
  • 4,158
  • 23
  • 39
  • I did fix the link in my original post. – OSGI Java Jun 13 '16 at 16:43
  • We use document style. The WSDL includes XSD schema. – OSGI Java Jun 13 '16 at 16:47
  • So what happens when you let the maven plugin generate code? Do you get a RPC-style API or just a get-/setDocument? – wallenborn Jun 14 '16 at 07:17
  • I cannot tell whether it is RPC or Document style generated client. – OSGI Java Jun 14 '16 at 19:07
  • I should have mentioned that we also use Spring. I am not sure if that makes any difference. – OSGI Java Jun 14 '16 at 19:08
  • I have added a snippet of the generated client code. – OSGI Java Jun 14 '16 at 19:26
  • Next to the OrderService class there should be a demo Client implementation showing you how to use it. But basically, you can ask the service for the port by calling `service.getOrderServicePort()` (or similar. The port then should implement all the methods defined in the WSDL. – wallenborn Jun 15 '16 at 10:36
  • Yes, there is. I have updated the original post with the snippet. – OSGI Java Jun 15 '16 at 13:18
  • Then you have all you need, right?. The JAXB XML-to-Java binding is already in place, You can instantiate a `ProcessOrderType message`, fill it with data, and then call `port.processOrder(message)`. No XSL wizardry needed. – wallenborn Jun 15 '16 at 14:35
  • Right. Thanks for confirming of the flow! If you like you can add a new answer confirming the correctest of the flow so that we can bump it as the correct answer. – OSGI Java Jun 15 '16 at 16:05