title: Is SoapUI converting my REST API's XML to JSON?
body: <p>I've been assigned the task of building a REST API with basic authentication that outputs an XML file.</p>
  
  <p>I struggled for awhile getting XML to come out instead of JSON, but I think I got it. I've annotated @XmlRootElement s and @XmlElements and, sure enough, when I access the API with a browser, XML comes back and the browser even tells me "This XML file does not appear to have any style information associated with it. " Yay! XML! Mission accomplished, right?</p>
  
  <p>However, when I access the API with SoapUI or Postman, it always gives me JSON. Tells me there's no XML, not even in the raw. Is this something SoapUI and Postman do, or (more likely) do I need to change something in my code to make it XML every time?</p>
  
  <p>Thanks in advance if you are able to help!</p>
  
  <p>Here is what I believe to be the relevant code:</p>
  
  <p>Application.java:
      package hello;</p>
  
  <pre><code>import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.security.web.context.*;
  
  @SpringBootApplication
  public class Application {
      public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
  
          public SecurityWebApplicationInitializer() {
              super(WebSecurityConfig.class);
          }
      }
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>Address.java</p>
  
  <pre><code>package hello;
  
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name="address")
  public class Address {
  
  
      private String street;
      private String city;
      private String stateZip;
  
      public Address() {
          this.street = "123 Main Street ";
          this.city = "Concord";
          this.stateZip = "NC-28027";
      }
  
      public String getStreet() {
          return street;
      }
  
      public String getCity() {
          return city;
      }
  
      public String getStateZip() {
          return stateZip;
      }
  
      @XmlElement
      public void setStreet(String street) {
          this.street = street;
      }
      @XmlElement
      public void setCity(String city) {
          this.city = city;
      }
      @XmlElement
      public void setStateZip(String stateZip) {
          this.stateZip = stateZip;
      }
  
  
  
  }
  </code></pre>
  
  <p>AddressArray.java</p>
  
  <pre><code>package hello;
  
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name="addresses")
  public class AddressArray {
  
      public Address address1 = new Address();
      public Address address2 = new Address();
      public Address address3 = new Address();
  }
  </code></pre>
  
  <p>AddressController.java</p>
  
  <pre><code>package hello;
  
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  public class AddressController {
  
      @RequestMapping("/address")
      public @ResponseBody AddressArray addresses() {
          return new AddressArray();
      }
  
  
  }
  </code></pre>
  
  <p>While accessing this in a browser I get XML back, sure enough, but here's the kind of response I get back in Postman or SoapUI, still frustratingly in JSON:</p>
  
  <pre><code>{
    "address1": {
      "street": "123 Main Street ",
      "city": "Concord",
      "stateZip": "NC-28027"
    },
    "address2": {
      "street": "123 Main Street ",
      "city": "Concord",
      "stateZip": "NC-28027"
    },
    "address3": {
      "street": "123 Main Street ",
      "city": "Concord",
      "stateZip": "NC-28027"
    }
  }
  </code></pre>