Post XML to jersey rest webservice
<p>i'm trying to post a message from a facelet (.xhtml) page to a REST web service (Jersey). I think it would be possible to do within javascript/jQuery if the server would have, let's say</p>

<pre><code>&lt;?php header('Access-Control-Allow-Origin: *'); ?&gt;
</code></pre>

<p>However the server seems to not have a property like that, and I don't know where to modify that in the config. </p>

<p>I tried this;</p>

<pre><code>var settings = {
  "async": true,
  "crossDomain": true,
  "url": "example.com",
  "method": "POST",
  "headers": {
    "content-type": "application/xml",
    "cache-control": "no-cache"
  },
"data": 
  "&lt;consultation&gt;\n    \n\
    &lt;consultationDescription&gt;"+description+"&lt;/consultationDescription&gt;\n    \n\
    &lt;customerName&gt;"+fullName+"&lt;/customerName&gt;\n    \n\
    &lt;customerPhone&gt;"+phonenumber+"&lt;/customerPhone&gt;\n    \n\
    &lt;endDateAndTime&gt;"+endDateAndTime+"&lt;/endDateAndTime&gt;\n    \n\
    &lt;startDateAndTime&gt;"+startDateAndTime+"&lt;/startDateAndTime&gt;\n\n\
  &lt;/consultation&gt;",
  contentType: "application/xml", 

$.ajax(settings).done(function (response) {
  console.log(response);
});
</code></pre>

<p>But I only get cross origin error.</p>

<p>So should I try to find where to modify the origin on the server, or should I go with a different approach? Maybe a &lt; h:form > and post via a javabean like #{sendXML.someMethod} etc, but I don't know where to find the syntax for that. I've been stuck with this problem for some time and can't find a good answer. Do you guys have any idee what to do?</p>

<p>Example: <a href="http://postimg.org/image/5k2thyl3p/" rel="nofollow">http://postimg.org/image/5k2thyl3p/</a></p>

<p>Click green cell --> Write message (submit) --> book time on server. Update view.</p>