import { Injectable } from '@angular/core';
import { Client, ISoapMethodResponse, NgxSoapService } from 'ngx-soap';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class GeneralService {
client : Client;
constructor(
private soap : NgxSoapService
) {
//this function always skipped only when i reload Document Component
this.soap.createClient(environment.wsURL).then(client=>{
client.addSoapHeader({
'tns:ModuleCredential':{
'tns:ModuleAppName':'xxxx',
'tns:ModuleUserName':'xxxx',
'tns:ModulePassword':'xxxx'
}
});
client.addHttpHeader(
'Content-Type','text/xml; charset=utf-8'
);
this.client = client;
})
.catch(err=>console.log('SoapError',err))
}
GetCategoryList():Observable<ISoapMethodResponse>{
const body ={
data : null
};
return this.client.call('GetCategoryList',body);
}
every time i refresh or reload page i've got this error
ERROR TypeError: Cannot read property 'call' of undefined
at GeneralService.GetCategoryList (general.service.ts:44)
at DocumentComponent.getCategoryList (document.component.ts:104)
at DocumentComponent.initializeList (document.component.ts:91)
at DocumentComponent.ngOnInit (document.component.ts:69)
at callHook (core.js:4726)
at callHooks (core.js:4690)
at executeInitAndCheckHooks (core.js:4630)
at refreshView (core.js:12026)
at refreshEmbeddedViews (core.js:13404)
at refreshView (core.js:12035)
Hi Lula, i had some problem when i refresh page on some component, it says Cannot read property 'call' of undefined
this is my App Module
this is my Component ts
and this is my Service
every time i refresh or reload page i've got this error
the constructor always not triggered