title: angular2 call to soap web service fails with access denied
body: <p>I'm trying to get a really simple call to a SOAP web service to work using Angular2 and Http POST. if I post the same message using POSTMAN it works fine just by setting the content type to text/xml.</p>
  
  <p>With Angular2 I'm getting these errors:-</p>
  
  <p>SEC7120: Origin <a href="http://localhost:3004" rel="nofollow">http://localhost:3004</a> not found in Access-Control-Allow-Origin header</p>
  
  <p>SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied</p>
  
  <p>any help would be appreciated.</p>
  
  <p>this is the service code</p>
  
  <pre><code>import { Injectable } from 'angular2/core';
  import { Http, Request, Response, Headers, RequestMethod, RequestOptions } from 'angular2/http';
  import { Observable } from 'rxjs/Observable';
  
  @Injectable()
  export class PaymentsService {
  
  private body: string = `&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"    
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Body&gt;
  &lt;HelloWorld xmlns="http://bernera.zapto.org/" /&gt;
  &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;`;
  
  private result;
  
  constructor(private http: Http) { }
  
  callSOAP() {
  
  var headers = new Headers();
  headers.append('Content-Type', 'text/xml');
  headers.append('Access-Control-Request-Method', 'POST');
  headers.append('Access-Control-Request-Headers', 'X-Custom-Header');
  headers.append('Access-Control-Allow-Origin', 'http://localhost:3004');
  
  this.http.post('http://bernera.zapto.org/astronomy/astronomy.asmx',
    this.body,
    { headers: headers })
    .subscribe(
    data =&gt; this.result = data,
    err =&gt; this.logError(err),
    () =&gt; console.log('Call complete')
    );
  
  alert('result ' + this.result);
  </code></pre>
  
  <p>}</p>
  
  <pre><code>logError(err) {
  console.error('There was an error: ' + err.statusText);
  alert('There was an error: ' + err.statusText);
  </code></pre>
  
  <p>}</p>
  
  <p>}</p>