首页 > 解决方案 > Angular NGX-SOAP 请求获取 ERR_RESPONSE_HEADERS_TRUNCATED

问题描述

我目前在本地主机中,并试图向外部公共 SOAP 服务发出肥皂请求。我能够使用 Soap 客户端在 PHP localhost 上发出请求。但是现在我在提出请求时遇到了 Angular 问题。让我介绍一下我的代码。

首先是 WSDL 的在线版本 => HERE

模块的构造函数没有错误:

  constructor(private soap: NgxSoapService, private httpClient: HttpClient, private snackBar: MatSnackBar, public dialog: MatDialog, private auth: AuthenticationService, private restApi: RestApi) {
    let headers = new HttpHeaders({
      'Content-Type': 'text/xml',
      'Access-Control-Allow-Headers': 'origin, content-type, accept, authorization',
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Credentials': 'true',
      'Access-Control-Allow-Methods': 'GET, POST',
    });
    this.soap.createClient('./assets/wsdl/CityService.wsdl', {headers: headers}).then(client => {
      this.client = client;
    })
      .catch(function(error) {
        console.log(error);
      });
  }

这是一个基本的 SOAP 请求函数。

  makeAnExampleRequest() {
    this.client.call('GetCities', {}).subscribe((res: ISoapMethodResponse) => console.log(res), (error) => console.error(error));
  }

调用上述函数时,出现以下错误:

从控制台.错误(错误):

HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "https://api.n11.com/ws/cityService/", ok: false, …}
headers: HttpHeaders
normalizedNames: Map(0) {}
lazyUpdate: null
headers: Map(0) {}
__proto__: Object
status: 0
statusText: "Unknown Error"
url: "https://api.n11.com/ws/cityService/"
ok: false
name: "HttpErrorResponse"
message: "Http failure response for https://api.n11.com/ws/cityService/: 0 Unknown Error"
error: ProgressEvent
isTrusted: true
lengthComputable: false
loaded: 0
total: 0
type: "error"
target: XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__xhrURL: "https://api.n11.com/ws/cityService/", __zone_symbol__loadfalse: Array(1), __zone_symbol__errorfalse: null, __zone_symbol__xhrScheduled: true, …}
currentTarget: XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__xhrURL: "https://api.n11.com/ws/cityService/", __zone_symbol__loadfalse: Array(1), __zone_symbol__errorfalse: null, __zone_symbol__xhrScheduled: true, …}
eventPhase: 0
bubbles: false
cancelable: false
defaultPrevented: false
composed: false
timeStamp: 3544.754999995348
srcElement: XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__xhrURL: "https://api.n11.com/ws/cityService/", __zone_symbol__loadfalse: Array(1), __zone_symbol__errorfalse: null, __zone_symbol__xhrScheduled: true, …}
returnValue: true
cancelBubble: false
path: []
__proto__: ProgressEvent
__proto__: HttpResponseBase

来自 zone-evergreen.js:

POST https://api.n11.com/ws/cityService/ net::ERR_RESPONSE_HEADERS_TRUNCATED

我用另一个需要身份验证对象的请求尝试了另一个 WSDL,我得到的只是同样的错误

标签: angularsoaphttp-headerswsdl

解决方案


推荐阅读