need to use custom classes instead of generated (by wsimport) in web-services

╄→гoц情女王★ 提交于 2019-12-05 12:42:02
kostya

To generate classes from wsdl, use in ant :


<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
<wsimport keep="true" sourcedestdir="..." wsdl="..." wsdllocation="..." xnocompile="true" />

Don't use 'package' attribute on wsimport ant task, so all classes are created in their correct packages.

In general, to customize package, i.e. change generated package name a.b.c to name x.y.z add element to wsimport task and define binding.jxb file as follows.


<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jxb:bindings schemaLocation="schema-for-a.b.c.xsd" node="/xs:schema">
        <jxb:schemaBindings>
            <jxb:package name="x.y.z" />
        </jxb:schemaBindings>
    </jxb:bindings>
</jxb:bindings>

where schema-for-a.b.c.xsd is the schema generated by wsgen task (that creates wsdl with suitable schemes).

More detailed about JAXB customization : http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/1.6/tutorial/doc/JavaWSTutorial.pdf, section "Customizing JAXB Bindings"

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