How to make java class Serializable which is generated by wsdl

荒凉一梦 提交于 2019-12-29 01:56:06

问题


In my project, classes are generated by wsdl. One of these classes is User class. This class must be Serializable. How can I change my pom.xml file for making User Serializable? I can find example but can't apply it to my project https://pragmaticintegrator.wordpress.com/2009/03/14/make-serializable-jax-ws-clients-with-maven2/


回答1:


Finally I could find answer for my question. In our project we use org.apache.cxf plugin to generate classes. I created binding.xml file in resources folder.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
           elementFormDefault="qualified" attributeFormDefault="unqualified"
           jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1">
    <xs:annotation>
        <xs:appinfo>
            <jaxb:globalBindings>
                <xjc:serializable uid="1337" />
            </jaxb:globalBindings>
        </xs:appinfo>
    </xs:annotation>
</xs:schema>

Then I referenced to this xml file from my pom.xml, for this I added

<bindingFiles>
    <bindingFile>${basedir}/src/main/resources/binding.xml</bindingFile>
</bindingFiles>

under wsdlOptions/wsdlOption tag. That's all



来源:https://stackoverflow.com/questions/52658580/how-to-make-java-class-serializable-which-is-generated-by-wsdl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!