通过Angular应用程序使用SOAP Web服务

时间:2019-02-18 14:11:55

标签: javascript angular typescript rest web-services

我知道我们可以在Restful services个应用中使用Angular。但是我的一位客户给了我web service这样的http://123.618.196.10/WCFTicket/Service1.svc?wsdl。所以我的问题是我可以在Angular应用中使用它吗?我没用过有什么线索吗?

1 个答案:

答案 0 :(得分:2)

ngx-soap 是一个很棒的库,我已经在我们的一个客户项目中使用过。

以下是使用此库的步骤。

步骤1:安装ngx-soap和依赖项

npm install --save ngx-soap

npm install --save buffer concat-stream core-js crypto-js events lodash sax stream uuid

第2步:

import { NgxSoapModule } from 'ngx-soap';
...
    @NgModule({
        imports: [ ..., NgxSoapModule, ... ]
    ...

步骤3:在组件中注入NgxSoapService

...
import { NgxSoapService, Client, ISoapMethodResponse } from 'ngx-soap';
...

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
    client: Client;

    constructor(private soap: NgxSoapService) {
        this.soap.createClient('http://123.618.196.10/WCFTicket/Service1.svc?wsdl').subscribe(client => this.client = client);
    }
 }

希望这会有所帮助!

相关问题