title: Consume SOAP XML in Rest WebService
body: <p>I am able to consume xml based request in rest webservice. Below is the sample code how I am consuming XML request in my rest webservice.</p>
  <p>Now, I want to consume soap request XML and I know SOAP is a messaging protocol. It can only be consumed by SOAP based webservices but it uses an XML data format to declare its request and response messages, relying on XML Schema. I just want to recevice its XML based request in rest webservice.</p>
  <p>Is there any way around to cater this requirement in rest based web service.</p>
  <p>Below is the sample soap request which I want to consume in rest webservice.</p>
  <p><strong>SOAP Request:</strong></p>
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:int=&quot;http://example.com/&quot;&gt;
      &lt;soapenv:Header/&gt;
      &lt;soapenv:Body&gt;
          &lt;order&gt;
              &lt;order-no&gt;&lt;/order-no&gt;
              &lt;custmer&gt;&lt;/custmer&gt;
              &lt;address&gt;&lt;/address&gt;
              &lt;bill-amount&gt;&lt;/bill-amount&gt;
          &lt;/order&gt;
      &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  <p>Below sample code of how I am consuming XML request in my rest webservice.</p>
  <p><strong>Sample Code:</strong></p>
  <p>Rest Endpoint for Consuming XML Request</p>
  <pre><code>    @Path(&quot;/processOrder&quot;)
      @POST
      @Produces(&quot;application/xml&quot;)
      @Consumes(&quot;application/xml&quot;)
      public OrderResponse processOrder(Order order) {
      return processUser(order);
      }
  </code></pre>
  <p><strong>Order.java</strong></p>
  <pre><code>    @XmlRootElement(name = &quot;order&quot;)
      public class Order {    
      private int orderNo;
      private String custmer;
      private String address;
      private String amount;
       
      @XmlAttribute(name = &quot;order-no&quot;)
      public int getOrderNo() {
          return orderNo;
      }
      public void setOrderNo(int orderNo) {
          this.orderNo = orderNo;
      }
       
      @XmlElement
      public String getCustmer() {
          return custmer;
      }
      public void setCustmer(String custmer) {
          this.custmer = custmer;
      }
       
      @XmlElement
      public String getAddress() {
          return address;
      }
      public void setAddress(String address) {
          this.address = address;
      }
       
      @XmlElement(name = &quot;bill-amount&quot;)
      public String getAmount() {
          return amount;
      }
      public void setAmount(String amount) {
          this.amount = amount;
      }    
     }
  </code></pre>
  <p><strong>OrderResponse.java</strong></p>
  <pre><code>    @XmlRootElement(name = &quot;orderResponse&quot;)
      public class OrderResponse{    
      private String response;
  
      @XmlElement(name = &quot;response&quot;)
      public String getResponse() {
          return response;
      }
      public void setResponse(String response) {
          this.response= response;
      }
      }
  </code></pre>
  <p><strong>XML Request:</strong></p>
  <pre><code>&lt;order&gt;
      &lt;order-no&gt;&lt;/order-no&gt;
      &lt;custmer&gt;&lt;/custmer&gt;
      &lt;address&gt;&lt;/address&gt;
      &lt;bill-amount&gt;&lt;/bill-amount&gt;
  &lt;/order&gt;
  </code></pre>
  <p><strong>XML Response:</strong></p>
  <pre><code>&lt;orderResponse&gt;
      &lt;response&gt;&lt;/response&gt;
  &lt;/orderResponse&gt;
  </code></pre>