JAXB :Need Namespace Prefix to all the elements

前端 未结 6 2061
[愿得一人]
[愿得一人] 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:31

    Was facing this issue, Solved by adding package-info in my package

    and the following code in it:

    @XmlSchema(
        namespace = "http://www.w3schools.com/xml/",
        elementFormDefault = XmlNsForm.QUALIFIED,
        xmlns = {
            @XmlNs(prefix="", namespaceURI="http://www.w3schools.com/xml/")
        }
    )  
    package com.gateway.ws.outbound.bean;
    
    import javax.xml.bind.annotation.XmlNs;
    import javax.xml.bind.annotation.XmlNsForm;
    import javax.xml.bind.annotation.XmlSchema;
    

提交回复
热议问题