How to simply convert jaxws objects

HI, I have web services calling each other using jaxws. The problem is that I am passing a compex object, classes. And every time I get the object, a different package belongs (proxy1.jaxs.myClass ...), so I have to write envelopes back and forth. Is there an easy way to convert between a proxy object, an origanl object, or another proxy object? Thanks, I hope I explained myself.

+3
source share
2 answers
  • Dozer is pretty good, if the classes are similar, you can even walk away without a complicated XML configuration. But keep in mind that you will need to unit test the Dozer Display, since it works with reflection, and you must be sure that all fields are correctly displayed.

  • XSLT - if you go around objects without any logic, maybe a simple conversion working at the SOAP XML level will do the trick?

+1
source

I assume that you want to reuse your own Java Bean in the client instead of using artifacts created by JAX-WS / JAX-B.

The solution is to tell JAX-B that you want to use specific classes to represent the Bean. Look at JAX-B Bindings, the solution should look like this:

<jxb:bindings schemaLocation="YourService_schema1.xsd" node="/xs:schema">
<jxb:bindings node="//xs:complexType[@name='yourType']">
    <jxb:class ref="com.myoriginalpackage.YourType">
    </jxb:class>
</jxb:bindings>

Java : http://confluence.highsource.org/display/HJ3/Apache+CXF+Tutorial+-+Building+JAX-WS,+JAXB+and+JPA-based+web+service+with+Apache+CXF,+Spring+and+Hyperjaxb3

+1

Source: https://habr.com/ru/post/1796632/


All Articles