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

Sam*_*ath 3 javascript rest web-services typescript angular

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

The*_*ram 5

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
Run Code Online (Sandbox Code Playgroud)

第2步:

import { NgxSoapModule } from 'ngx-soap';
...
    @NgModule({
        imports: [ ..., NgxSoapModule, ... ]
    ...
Run Code Online (Sandbox Code Playgroud)

第 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);
    }
 }
Run Code Online (Sandbox Code Playgroud)

希望这会有所帮助!

  • 也许你可以使用 SOAPUI ? (2认同)