How to set xml namespace when using jersey, jaxb & jax-rs

How to set xml namespace when using jQuery, jaxb and jax-rs

+3
source share
1 answer

All of this is done using JAXB annotations. The values โ€‹โ€‹below apply to your domain model.

Circuit level

You can specify schema level namespace information using the @XmlSchema package level annotation:

@XmlSchema(namespace = "http://www.example.org",
           elementFormDefault = XmlNsForm.QUALIFIED)
package org.example;

import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlNsForm;

The aforementioned FormDefault annotation anchor will use the namespace of all elements in " http://www.example.org " by default .

Type Level

@XmlType:

@XmlType(namespace="http://www.example.org/foo")

/

/ :

  • @XmlAttribute ( = "http://www.example.org/bar" )
  • @XmlElement ( = "http://www.example.org/bar" )
  • @XmlElementWrapper ( = "http://www.example.org/bar" )
  • @XmlRootElement ( = "http://www.example.org/bar" )

, :

+5

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


All Articles