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

5

我知道我们可以在Angular应用程序中使用Restful服务,但我的客户给了我一个类似这样的web服务http://123.618.196.10/WCFTicket/Service1.svc?wsdl。我的问题是,我能在Angular应用程序中使用它吗?我从未使用过它,有什么提示吗?

1个回答

5

ngx-soap是一款非常优秀的库,我在我们的一个客户项目中使用过。

以下是使用此库的步骤。

第一步:安装ngx-soap及其依赖项。

npm install --save ngx-soap

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

第二步:

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

步骤三:在你的组件中注入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);
    }
 }

希望这能帮到你!

很高兴有一个使用过它的人。你对这个转换的性能满意吗?因为这是为移动应用程序设计的。 - Sampath
你对这种包装后服务的性能没有任何想法吗? - Sampath
我用于Web应用程序,没有看到任何性能问题。对于移动设备,可能会有性能问题。 - TheParam
谢谢。还有一个问题。你能告诉我一个工具来查看这种WSDL服务的详细信息吗?当我在浏览器中打开它时,细节不清楚。例如,公开方法名称参数等。例如:http://www.thomas-bayer.com/axis2/services/BLZService?wsdl - Sampath
2
你可以使用SOAPUI吗? - Ch'nycos

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接