Repository navigation
Write a namespaced class name with dots, and refuse a document the parser objects to - #5
Merged
Conversation
…e a document the parser objects to The provider's class name reached the document as it stood: in the target namespace, urn:App\Soap\QuoteProviderwsdl, and in the definitions, portType, binding, service and port names and the QNames referring to them. A backslash is valid in neither a URI nor an NCName. libxml loads such a document and warns about the namespace, PRADO's error handler turns the warning into an exception, and TSoapServer::getWsdl() threw for every namespaced provider. The unreleased loadOrFail() hid the warning behind @ and handed the document back, which is worse: it parses, and no client accepts it. A namespaced type had a related gap. The @PARAM, @return, @var and @soaptype grammars accepted only \w, so App\Soap\Quote was cut at the first separator and reflected on as a class named App. Separate the class name, which reflection needs, from the name the document carries. Wsdl::documentName() replaces each separator with a dot and drops a leading one, so App\Soap\QuoteProvider is written as App.Soap.QuoteProvider, valid as both a URN and an NCName. The full name is kept rather than the short one, so two classes sharing a short name do not collide. Wsdl maps the service name once and writes the mapped name everywhere, and convertType() maps a type name the same way while declaring it and referring to it, so every tns: reference resolves to the complexType it names, the Array form included. The four tags take a fully qualified name, with or without the leading separator; a short name resolves in the global namespace as it always did. A class name holds nothing else the mapping touches, so a global class produces the document it always did, byte for byte. Two documents generated before this change are committed under tests/unit/Fixtures and compared whole, in both styles. loadOrFail() no longer hides anything. It keeps libxml's errors internal, so no warning reaches an error handler, and refuses a document the parser said anything about, naming what it said. The first parse now catches an invalid namespace, so the re-parse of the serialized document is gone. A service name that is not a class name and yields a URN the parser rejects, such as one holding a quote or a space, is refused where it loaded with a hidden warning before. The SOAP client and server of PHP accept the document of a namespaced provider in both styles: a client reads the signatures and the dotted struct names, and a client calling a server in the same process round-trips a call, through an adapter in the document style, where PHP hands a method the request wrapper as one object and encodes what it returns as the response wrapper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4.
The provider's class name reached the document as it stood: in the target namespace, urn:App\Soap\QuoteProviderwsdl, and in the definitions, portType, binding, service and port names and the QNames referring to them. A backslash is valid in neither a URI nor an NCName. libxml loads such a document and warns about the namespace, PRADO's error handler turns the warning into an exception, and TSoapServer::getWsdl() threw for every namespaced provider. The unreleased loadOrFail() hid the warning behind @ and handed the document back, which is worse: it parses, and no client accepts it.
A namespaced type had a related gap. The @PARAM, @return, @var and @soaptype grammars accepted only \w, so App\Soap\Quote was cut at the first separator and reflected on as a class named App.
Separate the class name, which reflection needs, from the name the document carries. Wsdl::documentName() replaces each separator with a dot and drops a leading one, so App\Soap\QuoteProvider is written as App.Soap.QuoteProvider, valid as both a URN and an NCName. The full name is kept rather than the short one, so two classes sharing a short name do not collide. Wsdl maps the service name once and writes the mapped name everywhere, and convertType() maps a type name the same way while declaring it and referring to it, so every tns: reference resolves to the complexType it names, the Array form included. The four tags take a fully qualified name, with or without the leading separator; a short name resolves in the global namespace as it always did.
A class name holds nothing else the mapping touches, so a global class produces the document it always did, byte for byte. Two documents generated before this change are committed under tests/unit/Fixtures and compared whole, in both styles.
loadOrFail() no longer hides anything. It keeps libxml's errors internal, so no warning reaches an error handler, and refuses a document the parser said anything about, naming what it said. The first parse now catches an invalid namespace, so the re-parse of the serialized document is gone. A service name that is not a class name and yields a URN the parser rejects, such as one holding a quote or a space, is refused where it loaded with a hidden warning before.
The SOAP client and server of PHP accept the document of a namespaced provider in both styles: a client reads the signatures and the dotted struct names, and a client calling a server in the same process round-trips a call, through an adapter in the document style, where PHP hands a method the request wrapper as one object and encodes what it returns as the response wrapper.