我正在使用Angular4。我想从soap Web服务获取XML中的方法,然后想从Web服务获取名为“ sayHello”的函数,但我不能。
// get wsdl content
this.http.get('/address/test.wsdl', {responseType: 'text'}).subscribe(response => {
if (response) {
this.client = this.soap.createClient(response);
console.log(response);
}
});
它只是返回XML。 我搜索了很多,但没有答案。
答案 0 :(得分:1)
您必须为客户端构造函数(而不是XML)的wsdl提供 url 或 path 。来自文档的示例:
import { Component, OnInit } from '@angular/core';
import { NgxSoapService, Client, security } from 'ngx-soap';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
client: Client;
constructor(private soap: NgxSoapService) {
this.soap.createClient('assets/calculator.wsdl').then(client => {
// if need WSSecurity
// client.setSecurity(new security.WSSecurity('username', "password", {}));
this.client = client
});
}
}