ngx-soap icon indicating copy to clipboard operation
ngx-soap copied to clipboard

Partially initialized client for complex WSDL

Open jcharlytown opened this issue 5 years ago • 5 comments

There is an issue with importing WSDL definitions with imported XSDs. The promise for _requestWSDL actually completes before all imports have been processed and the WSDL has been parsed completely. As a consequence, the client gets initialized with an incomplete WSDL definition and is lacking ports. I guess there is a good chance that some of the Method not found issues reported here actually stem from this issue. At least this is the error I got. In order to reproduce the issue I attached console.log(JSON.stringify(client.wsdl.definitions.services)); to the createClient Promise. The tricky part is that the client.wsdl gets modified in-place and the debugging console updates accordingly.

A dirty workaround to avoid the issue is to call into client.setEndpoint(' '); using setTimeout() in order to trigger the client to "reparse" the hopefully by then completely parsed WSDL.

If it is helpful I can definitely supply the WSDL which is affected for me. Am I reading the clues correctly or am I missing something?

jcharlytown avatar Mar 25 '19 15:03 jcharlytown

Hi jcharlytown

I have same issue with missing methods when importing from WSDL with XSDs. Please, can you share your "dirty" solution how you solved it?

Thanks a lot

irudji avatar Apr 08 '19 06:04 irudji

@lula any solution about this?

PedroDominMor avatar Apr 24 '19 07:04 PedroDominMor

I can share my solution, I forgot about this. Won't get to it until tomorrow throughAm 24.04.2019 09:17 schrieb PedroDominMor [email protected]:@lula any solution about this?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

jcharlytown avatar Apr 24 '19 08:04 jcharlytown

Hello guys! Sorry for delay. Have you tried with node soap? Please remember that this is a porting from server lib.

So I did a quick test and it doesn't seem to work for me, although I might have created the wsdl and xsd not correctly. @jcharlytown can you perhaps share a repo with a sample to test with?

lula avatar Apr 24 '19 16:04 lula

Hi, sorry for the delay. I solved it like this:

private createService(uri: string): Promise<Client>
{
	return new Promise((resolve, _) =>
	{
		this.soap.createClient(uri, { disableCache: true }).then((c: Client) =>
		{
			// HACK: https://github.com/lula/ngx-soap/issues/43
			setTimeout(() =>
			{
				c.setEndpoint('');
				// console.log(c.describe());
				// console.log(c);
				resolve(c);
			}, 3000);
		});
	});
}

The setTimeout "ensures" that the entire schema has been fetched and parsed and the ports have been set up.

As to an example: I needed to connect to a SOAP service based on this schema: https://fachportal.gematik.de/fileadmin/user_upload/fachportal/files/Spezifikationen/Produktivbetrieb/Schemata_WDSL/OPB3.0_Schemadateien_R300.zip

More precisely, I used conn/vsds/VSDService.wsdl as entrypoint so to speak. I have the entire schema definitions shipped with my angular app as an asset. In order to make it work I had to modify the schemas slightly (although I do not fully understand whether this is a incompatibility with this library specifically or a general issue with the definitions). There is a patch file attached to this comment.

Once that's done, I load the service from angular like this:

const vsdServiceUri = window.location.origin + '/assets/data/ehealth-gematik/conn/vsds/VSDService.wsdl';
this.vsdService = this.createService(vsdServiceUri);

I hope this helps to track down the underlying issue. Let me know if can assist some more - it'll take a while though for me to put more effort into this.

Patch: 0001-Fix-VSDService-ngx-soap-compatability.tar.gz

jcharlytown avatar May 07 '19 22:05 jcharlytown