Templates: transforming a Java class from axis objects

I use the axis to automatically generate webservice artifacts, which are then converted to objects used in our application. Is there any reasonable pattern for this? We wrote conversion methods for deriving our objects from the created object axes, at another time we wrote an intermediate set of transformer classes that convert axis objects to our application objects? Is there a general way to approach this?

+7
java axis
source share
5 answers

If I understand correctly, you want to use the Axis function WSDL2Java to generate code from WSDL and then map it to an existing application object model. In this case, you may need to use Axis with JiBX binding.

+3
source share

If the goal is to convert the "generated axis" into your business objects, you can try a tool like dozer ( http://dozer.sourceforge.net/ ) that is, "mapper" to copy from the implementation of the object to another implementation. He does not know how to use it (I think you need to explain the translation in xml files), and then it should work (I did not use myself, but some colleagues used it for a similar purpose and seemed to work)

+1
source share

I guess there is a general way to do this. Abstract a little of your mind and introduce layers.

  • You get a library with basic IO and possibly basic session features and / or credentials.
  • Create a conversion layer. Here you will place all the code necessary to create application-dependent objects. Finish this layer with a nice interface for your application.

The conversion level can be done in several ways.

  • If the conversion is simple, you can combine the first and second levels in almost one. Extend POJOS to provide conversion functionality. This will give you at least two code snippets automatically generated and extensions + functionality

  • If we are talking about huge XML files that need to be converted into several small application objects. So, leave the first layer as is in the second use:

    • Command template : for encapsulating transformations.
    • If a transformation also becomes erratic: A chain of responsibility will help you generate a transformation tree.

I hope this helps

+1
source share

We have encountered similar problems in the past. Recently, for the complex web service for which we created Axis artifacts, we got 157 Java classes with names such as "MaintainOffersRequestTypeReqReqDataMaintEnhancementCancellationReason".

We're done writing classes that transform these objects created by Axis into business objects similar to your latest idea. I do not know if this is the best, but it is certainly an acceptable solution.

0
source share

If you use Axis 1, your business classes have the same qualified name as the Axis data class, and some other conditions apply, you can simply use your business classes instead of Axis without configuration. We have done this many times.

For Axis 2, we had problems with data bindings other than ADB (by default), so we actively use Apache Commons Beanutils to copy data between Axis classes and our business classes.

0
source share

All Articles