JAXB Transformation Quickstart
antollinim Jul 11, 2011 3:14 PMHello,
I have just implemented a JAXB quickstart following Tom Fennelly's screencast.
I have it working now (using SOAP binding) but I wanted to discuss some things before pushing the code.
1 - My biggest concern is that, when using JAXB, I had to modify both the signature of the operations and, thus, the internal implementation of the service.
In concrete, before using JAXB the Service looked like this:
@Service(OrderService.class) public class OrderServiceBean implements OrderService { @Override public OrderAck submitOrder(Order order) { // Create an order ack return new OrderAck() .setOrderId(order.getOrderId()) .setAccepted(true) .setStatus("Order Accepted"); } }
Now, with JAXB, it looks like this:
@Service(OrderService.class) public class OrderServiceBean implements OrderService { @Override public SubmitOrderResponseType submitOrder(SubmitOrderType order) { // Create an order ack OrderAckType orderAck = new OrderAckType(); orderAck.setOrderId(order.getOrder().getOrderId()); orderAck.setAccepted(true); orderAck.setStatus("Order Accepted"); SubmitOrderResponseType sort = new SubmitOrderResponseType(); sort.setOrderAck(orderAck); return sort; } }
Am I doing something wrong or is it intended to work this way? I am asking cause I think JAXB is being too invasive here. If the databinding of a running service needs to be changed in the future, the signature will need to change as well.
2 - One minor issue was that during the execution of wsconsume.bat, the source files were generated OK, but the compilation failed with this error:
.\org\switchyard\quickstarts\transform\jaxb\OrderService_Service.java:60: cannot find symbol symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[]) location: class javax.xml.ws.Service super(WSDL_LOCATION, SERVICE, features); ^ .\org\switchyard\quickstarts\transform\jaxb\OrderService_Service.java:67: cannot find symbol symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[]) location: class javax.xml.ws.Service super(wsdlLocation, SERVICE, features); ^ .\org\switchyard\quickstarts\transform\jaxb\OrderService_Service.java:74: cannot find symbol symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[]) location: class javax.xml.ws.Service super(wsdlLocation, serviceName, features); ^ 3 errors Failed to invoke WSDLToJava org.apache.cxf.tools.common.ToolException: Failed to compile generated code at org.apache.cxf.tools.common.ClassUtils.compile(ClassUtils.java:115) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:262) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:138)
The source files compiled ok when integrated in my project.
3 - A minor bug showed up in Windows. In wsconsume.bat, there is a "\" at the end of line 22 which should be replaced by "/" (otherwise it fails to run). I do not know whether this belongs to Switchyard's or AS7's team.
Any thoughts?
Thanks,
Mario