Upon making a SOAP service call with my Nativescript application, I am encountering a situation where the response status is '200' but the response itself states 'Response with status: 200 OK for URL: null'. The code snippet I am using involves a post method and is outlined below,
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 = `<?xml version="1.0" encoding="utf-8"?>
<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/">
<soap:Body>
<HelloWorld xmlns="http://bernera.zapto.org/" />
</soap:Body>
</soap:Envelope>`;
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 => this.result = data,
err => this.logError(err),
() => console.log('Call complete')
);
alert('result ' + this.result);
}
logError(err) {
console.error('There was an error: ' + err.statusText);
alert('There was an error: ' + err.statusText);
}
}