Ankur
Ankur

Reputation: 3209

Angular POST with XML

I am using angular (not AngularJS). I have web service(SOAP) which is expecting XML data.

I tried to search but i couldn't find complete example of POST request with XML.

I need a sample in angular 2+ that explain data format, content-type, handle response...

Any help would be greatly appreciated.

Upvotes: 0

Views: 750

Answers (1)

Rap
Rap

Reputation: 7292

@Component({
  /* templateUrl, stylesUrls, selector, providers, etc. go here */
})
export class FooComponent {
  someXml;
  constructor(private _http:Http) {}
  // Maybe postStuff() is called on a button click or something.
  postStuff() {
    this._http.post("http://example.com/api", { responseType:'text' })
      .subscribe(
        res => this.someXml = res
      );
  }
}

Now, how you parse the XML and what you do with it is chapter 2 of the story, but we'd need some real examples to answer that.

Upvotes: 0

Related Questions