Home » Javascript » Angular 5 – HttpClient XML Post – Http failure during parsing

Angular 5 – HttpClient XML Post – Http failure during parsing

Posted by: admin October 29, 2018 Leave a comment

Questions:

I am trying to login on a local webservice using xml:

Here is the code:

const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type':  'text/xml',
    'Accept':  'text/xml',
    'Response-Type': 'text'
  })
};


login() {
    const postedData = `
        <authenticationDetail>
            <userName>myusername</userName>
            <password>mypassword</password>
        </authenticationDetail>`;
    return this.http.post('http://localhost/login.ws', postedData, httpOptions)
    .subscribe(
        result => {
            console.log('This result is' + result);
        },
        error => {
            console.log('There was an error: ', error);
        }
    );
}

The error I’m getting is:

Http failure during parsing for 'http://localhost/login.ws'

What is the problem here? How can I fix this?

Answers: