What you need is a service that wraps around Http
and provides deserialization:
@Injectable()
export class SOAPService{
constructor(private http:Http){}
public get(url:string, options?:RequestOptionsArgs):Observable{
return this.http.get(url, options).map(res => {
let xmlresult = res.text();
let result = //Here you deserialize your xml object
return result;
}
}
}
Then you can use it this way:
@Component({...})
export class ExampleComponent{
constructor(private soap:SOAPService){}
foo():{
this.soap.get('foo/bar').subscribe(...);
}
}
Since I'm not an xml parsing expert, I can't tell you how to deserialize your XML, but you can check MDN for that, you simply have to wrap the serialization/deserialization process in another service and inject it in your SOAPService
.