Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
http状态代码错误400:angular 4中使用ngx SOAP的SOAP客户端_Angular_Web Services_Soap_Angular Cli_Http Status Code 400 - Fatal编程技术网

http状态代码错误400:angular 4中使用ngx SOAP的SOAP客户端

http状态代码错误400:angular 4中使用ngx SOAP的SOAP客户端,angular,web-services,soap,angular-cli,http-status-code-400,Angular,Web Services,Soap,Angular Cli,Http Status Code 400,我正在尝试将angular 4中的SOAP服务器与ngx SOAP包一起使用 但是,我收到一个跨源请求错误(服务器端没有访问权限,但没有问题,并且访问控制允许源代码良好),http状态代码为400 我真的不知道我为什么会犯这个错误。请帮帮我 这是我的代码(来自NGXSOAP包) 他创建了SOAP客户端,调用SOAP服务器(),并使用post请求从CountryName操作中恢复国家名称 export class AppComponent implements OnInit{ jsonResp

我正在尝试将angular 4中的SOAP服务器与ngx SOAP包一起使用

但是,我收到一个跨源请求错误(服务器端没有访问权限,但没有问题,并且访问控制允许源代码良好),http状态代码为400

我真的不知道我为什么会犯这个错误。请帮帮我

这是我的代码(来自NGXSOAP包)

他创建了SOAP客户端,调用SOAP服务器(),并使用post请求从CountryName操作中恢复国家名称

export class AppComponent implements OnInit{
  jsonResponse: any;
  xmlResponse: string;
  message: string;
  loading: boolean;
  sCountryISOCode: string;
  private client: Client;
  constructor(
    private http: HttpClient,
    private soap: SOAPService
  ) { }
  ngOnInit() {
    this.http.get('/assets/tt.wsdl',
      {responseType: 'text'}).subscribe(response => {
        console.log(response);
      if (response) {
        this.client = this.soap.createClient(response);
      }
    });
  }

  soapCall() {
    this.clear();
    this.loading = true;
    const body = {
      sCountryISOCode: this.sCountryISOCode
    };
    this.client.operation('CountryName', body)
      .then(operation => {
        console.log(operation);
        if (operation.error) {
          console.log('Operation error', operation.error);
          return;
        }
        console.log(operation.url);
        console.log(operation.xml);
        console.log(operation.headers);
        this.http.post(operation.url, operation.xml,
          { headers: operation.headers, responseType: 'text', withCredentials: true }).subscribe(
          response => {
            console.log('GG');
            this.xmlResponse = response;
            this.jsonResponse = this.client.parseResponseBody(response);
            try {
              this.message = this.jsonResponse.Body.AddResponse.AddResult;
            } catch (error) { }
            this.loading = false;
          },
          err => {
            console.log('Error calling ws', err);
            this.loading = false;
            console.log();
          }
        );
      })
      .catch(err => console.log('Error', err));
  }
  clear() {
    this.message = undefined;
    this.jsonResponse = undefined;
    this.xmlResponse = undefined;
  }
}
export interface Output {
  AddResult?: string;
}