-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple XML Schemas with different namespaces in the same WSDL #5
Comments
this should work... i remember that i have already used it to generate some stuff for adyen integration... should investigate... |
Wow, that is a quick answer, I was still investigating myself, it should work indeed looking at this: Will fiddle around a bit more and get back here. |
Is it possible that the DefinitionsReader chokes on: <xsd:element minOccurs="0" name="address" nillable="true" type="ns1:Address" /> because when trying to process that |
Reduced it to this problematic WSDL: <?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:ns1="http://common.services.adyen.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://account.marketplace.services.adyen.com">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://account.marketplace.services.adyen.com">
<xsd:import namespace="http://common.services.adyen.com" />
<xsd:complexType name="AccountHolderDetails">
<xsd:sequence>
<xsd:element minOccurs="0" name="address" nillable="true" type="ns1:Address" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://common.services.adyen.com">
<xsd:complexType name="Address">
<xsd:sequence>
<xsd:element minOccurs="0" name="city" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
</wsdl:definitions> I got the idea that the import of the namespace in the second schema is going wrong. When the first schema is being processed, it is stored in the Storing it internally (
Note that this does not resolve the problem that the type of an XSD element should be defined BEFORE it is used... |
Thanks for isolating the problem, will have a look soon
…On 15 Feb 2017 15:38, "Menno Holtkamp" ***@***.***> wrote:
Reduced it to this problematic wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:ns1="http://common.services.adyen.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://account.marketplace.services.adyen.com">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://account.marketplace.services.adyen.com">
<xsd:import namespace="http://common.services.adyen.com" />
<xsd:complexType name="AccountHolderDetails">
<xsd:sequence>
<xsd:element minOccurs="0" name="address" nillable="true" type="ns1:Address" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://common.services.adyen.com">
<xsd:complexType name="Address">
<xsd:sequence>
<xsd:element minOccurs="0" name="city" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
</wsdl:definitions>
I got the idea that the namespaces of the child schema's get mixed up
somehow..
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAvaJ46PvAgjK51H0fYfG5PzM1UEcFAYks5rc4x6gaJpZM4MCUL6>
.
|
I had a look at the problem... and is not a easy one :( The schema is trying to solve a type that does not exist yet ( will be loaded in the next iteration). I was partially aware of the problem and there is some code and strategy to solve it... but definitively the current code will not work and to make it work will require more that a simple bugfix :( All the callback and
|
Thanks for diving in to this in this short term! That "multi step parsing" seems a biggie indeed... But please note that for the example snippet (where the types are defined before they are being referred to), this 'big' issue does not apply => in that particular case the already processed schema can not be 'applied' / read properly:
I think we can conclude that there are two aspects:
Disclaimer: I did the puzzling late at night, so my issue description might be not have been so well-structured 😨 |
Thanks for taking time for elaborating my analysis.
Types are loaded by namespace and name pair, not by path. The path is used just in error messages and to avoid re-loading the same file twice (this increases performance). so instead of documentUri and index, we can use any random string
Exactly!
I did I in early morning 😄 |
so true, the loading of the types: yes. But the schemas that are processed, are stored in an array (as a local cache?) '$loadedFiles' with a certain key. https://github.com/goetas-webservices/wsdl-reader/blob/7ca312187f620c667f6199ad73ec4ad0c7c4217d/src/DefinitionsReader.php#L160 you can see that this key is appended with an numeric index ( Later on, this index makes it 'impossible' to lookup the schema again for an So I suggested to:
DefinitionsReader::loadTypes(){
...
$key = $childNode->ownerDocument->documentURI . "#" .$childNode->getAttribute('targetNamespace');
$schema = $this->reader->readNode($childNode, $key);
$definitions->getSchema()->addSchema($schema);
} SchemaReader::loadImport(){
...
elseif (isset($this->loadedFiles[$file.'#' . $node->getAttribute("namespace")] )) {
$schema->addSchema($this->loadedFiles[$file.'#' . $node->getAttribute("namespace")] );
...
}
} Only: I am not sure of that loading mechanism with the namespace appended always works... 😄 |
the approach is nice, but unfortunately the DefinitionsReader::loadTypes(){
...
$key = $childNode->ownerDocument->documentURI . "#" .$childNode->getAttribute('targetNamespace');
$schema = $this->reader->readNode($childNode, $key);
$definitions->getSchema()->addSchema($schema);
} |
doh! Sorry. I found out I changed my testing WSDL snippet: first define the types, THEN refer to them: <?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:ns1="http://common.services.adyen.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://account.marketplace.services.adyen.com">
<wsdl:types>
<!-- first define the types! -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://common.services.adyen.com">
<xsd:complexType name="Address">
<xsd:sequence>
<xsd:element minOccurs="0" name="city" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<!-- now we can reference them -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://account.marketplace.services.adyen.com">
<xsd:import namespace="http://common.services.adyen.com" />
<xsd:complexType name="AccountHolderDetails">
<xsd:sequence>
<xsd:element minOccurs="0" name="address" nillable="true" type="ns1:Address" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
</wsdl:definitions> That works with the suggested fix: no more exception is thrown and PHP classes + YAML metadata files are generated properly. Indeed this is not a fix for the second, bigger problem where types are used before they are defined... |
Yes, I agree. Ff you can change the order or schemas in your wsdl, your approach will work! I will be happy to merge a PR fixing it. Regarding the second bigger problem, we can put it in backlog 😄 |
Yeah, tried that, problem is that there is no possible sequence that does not trigger the error. I will isolate and prepare the XML Schema's using some best practices to avoid this problem.
Ok, will do try to!
I was thinking of a viable approach, what about: instead of directly invoking all callbacks:
Did you got inspired by other libraries for parsing the XML Schema's? Or... homebrew 😄 |
Regarding the approach you suggested, more or less that was the way I had in mind too. Where i got inspired? This set of XML-based projects started more than 10 years ago, and I was also not so experienced... so is just a lot of hours spent in coding, coding and...... coding. The first version was still depending on the dom, even after the parsing... was a really bad idea 😄 After so much time, my conclusion is that XSD was a great idea, but over complicated by trying to support each single micro case that was possible to express with XML. Such complexity was not trivial at all to implement in parsers and other tools... especially 10 years ago. With soap, the over complication got even bigger. Now JSON folks are re-implementing for JSON everything was already built for XML because XML become so complicated that takes years to write a parser... or to build something on top of it. Homebrew? Never read a single line of that project 😄 |
haha, I did not mean the project, but "did you all make it yourself?". Apparently so! I recognize the constant change of ideas and strategies over the year! Guess this "we might need multi step parsing" is another one of those bumps in the road ahead 😄 I guess your contribution / work on JMS Serializer also brought new insight on how to design a parser... Thanks anyway! |
While experimenting with this library against https://cal-test.adyen.com/cal/services/Account/v1?wsdl I noticed errors like:
This particular element resides in a different namespace than the target namespace of the first
<xsd:schema/>
tag.As we can see in the WSDL the
<wsdl:types/>
tags contains multiple<xsd:schema/>
tags.I wonder, is this currently supported?
The text was updated successfully, but these errors were encountered: