美文网首页
关于angular6使用SOAP协议获取数据

关于angular6使用SOAP协议获取数据

作者: SevenLonely | 来源:发表于2019-05-28 13:51 被阅读0次

    1.安装插件

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

    2.添加模块

    将NgxSoapModule添加到您的应用模块

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

    3.使用

    ...
    import { NgxSoapService, Client, ISoapMethodResponse } from 'ngx-soap';
    ...
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
        xmlResponse:any;
        client: Client;
        intA = '参数1';
        intB = '参数2';
        url = 'WebService.asmx?WSDL';
    
        
        constructor(private soap: NgxSoapService) {
            this.soap.createClient(this.url).then(client => {
                console.log('Client', client);
                this.client = client;
             })
             .catch(err => console.log('Error', err));
        }
        
        sum() {
            const body = {
                intA: this.intA,
                intB: this.intB
            };
    
            this.client.call('Add', body).subscribe(res => {
                this.xmlResponse = res.responseBody;
            }, err => console.log(err));
        }
    }
    

    相关文章

      网友评论

          本文标题:关于angular6使用SOAP协议获取数据

          本文链接:https://www.haomeiwen.com/subject/juahtctx.html