【问题标题】:Calling specific method inside a WSDL Web Service (SOAP) using Ionic v3/v4使用 Ionic v3/v4 在 WSDL Web 服务 (SOAP) 中调用特定方法
【发布时间】:2019-05-07 18:04:14
【问题描述】:

我有一个 WSDL Web 服务 URL,该 URL 包含多个函数,我必须调用它们才能在 Ionic v3/v4 中获得响应。如何调用这些函数?

目前我只设法使用此代码将整个 XML 日期检索到我的应用程序中:


import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import xml2js from 'xml2js';


@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {

  headers: any;
  xmlItems: any;

  constructor(private http: HttpClient) { 

  }

  checkAPI()
  {

    this.http.get('https://MyWebService/svc/AllServices.svc?wsdl', { responseType: 'text'}).subscribe(data => {
    this.xmlItems = data;
    console.log("data:"+data);
    xml2js.parseString(this.xmlItems, function (err, result) {
        console.log(result);
    });
      }, error => {
        console.log(error);
    });
}
}

在这个 WSDL Web 服务中,我有多个功能,例如 (GetAllVehicles),但我不知道如何检索数据。

【问题讨论】:

  • 你试过https://MyWebService/svc/AllServices.svc/GetAllVehicles吗?

标签: api web-services ionic-framework soap wsdl


【解决方案1】:

尝试类似:

return this.httpClient.get<any[]>(
  url,
  {
    headers : new HttpHeaders(
      {
        'Content-Type': 'text/xml;charset=UTF-8',
        'SOAPAction': ''
      }
    )
      ,Accept: 'text/xml;charset=utf-8'
      ,responseType: 'text'
  });

尝试使用 SOAPUI 或 Postman 调用 SOAP API,以确保您必须传递的标头才能运行 SOAP 调用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-26
    相关资源
    最近更新 更多