JAXB :Need Namespace Prefix to all the elements

前端 未结 6 2070
[愿得一人]
[愿得一人] 2020-11-28 06:15

I am Using Spring WebServiceTemplate to make webservice call which uses JAXB to generate request XML. My requirement needs all the elements (including root) to have a namesp

6条回答
  •  情歌与酒
    2020-11-28 06:29

    Another way is to tell the marshaller to always use a certain prefix

    marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new NamespacePrefixMapper() {
                 @Override
                public String getPreferredPrefix(String arg0, String arg1, boolean arg2) {
                    return "ns1";
                }
            });'
    

提交回复
热议问题