Closed Bishal18 closed 3 years ago
Hello @Bishal18.
Which version of nestjs-soap are you running on?
I've tried to reproduce it by your examples but I couldn't exactly reproduce it. If possible, could you provide a working repository with your problem?
I've tested forRootAsync with v1.2.2, using useFactory and some injected class and both clients were working fine. Example:
@Injectable()
export class Config {
getJsonConfig(): Object {
return {
SAMPLE: {
SUB1: {
uri: 'https://sub1.asmx?wsdl',
},
SUB2: {
uri: 'https://sub2.asmx?wsdl',
},
}
};
}
}
const getOptions = (jsonConfig: any, serviceId: string, subModule?: string): SoapModuleOptions => {
return {
uri: jsonConfig[serviceId][subModule].uri
};
};
export const Soap: DynamicModule = SoapModule.forRootAsync([
{
name: 'CLIENT-1',
inject: [Config],
useFactory: (config: Config) => getOptions(config.getJsonConfig(), 'SAMPLE', 'SUB1'),
},
{
name: 'CLIENT-2',
inject: [Config],
useFactory: (config: Config) => getOptions(config.getJsonConfig(), 'SAMPLE', 'SUB2'),
},
]);
Controller:
export class SoapExampleController {
constructor(
@Inject('CLIENT-1') private readonly client: Client,
@Inject('CLIENT-2') private readonly client2: Client
) {}
}
Hello @lehh , there's no problem with the DI and code compiles fine, but if a call is made to a soap function inside the loaded client , it doesn't even recognize it and throws this function is not present in the client. You can check with two valid uris. Only the client-2 function calls will work.
Also, fyi, am using the 1.2.2 ver.
P.S. Thanks for your efforts to support this legacy module in the NestJS world!
Oh, right. I tested with two identical endpoints, that's why it was working fine 🤦🏻 . All right, I'm going to fix it. Thanks for reporting!
Also, I will be soon releasing a v2 with some improvements and, I do hope, less bugs.
You're welcome :)).
Haha, looking forward to it! :)
@lehh
For the below code snippet: The client-2 is only instantiated
Also, FYI: in the main module the Soap is imported as such: