Comments (7)
Hi! Thanks for the interest in this project.
Firs of all, this project currently supports WSDL-1.1 (see https://github.com/goetas-webservices/wsdl-reader), so I'm not sure how to proceed.
I haven't yet experimented with WSDL-2.0 (is it already adopted? I thought it never took off...).
https://github.com/goetas-webservices/xsd-reader should be able to support extension (instead of override).
Is this behavior also part of WSDL-1.1?
from soap-client.
So, I've researched this thing all day, and found the following..
XML Inline schemas definition by Microsoft .NET:
You can also have multiple inline schemas that define the same target namespace as long as no elements or attributes from that namespace were processed.
I found some old threads like this one, stating:
I created a WSDL with multiple inline schema's with the same targetNamespace. WSDL 1.1 is not very clear regarding this, but this is corrected in WSDL 2.0, which explicitly allows this:
A WSDL 2.0 document may define multiple inline schemas in its types element. The two or more schemas may have the same target namespace provided that they do not define the same elements or types. It is an error to define the same element or type more than once, even if the definitions are identical.
So it seems nobody ever stated that it ISN'T allowed, and the 2.0 spec states specifically that it IS.
For arguments sake, let's consider this slimmed down piece of WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="MetadataService" targetNamespace="http://rechtspraak.nl/MetadataService/v1"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://rechtspraak.nl/MetadataService/v1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<wsdl:types>
<xs:schema elementFormDefault="qualified" targetNamespace="http://rechtspraak.nl/Service/DataTypes"
xmlns:q1="http://rechtspraak.nl/Service/DataTypes">
<xs:complexType name="CodelijstWaarde">
<xs:sequence>
<xs:element name="Titel" type="xs:string"/>
<xs:element name="Waarde" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="CodelijstWaarde" type="q1:CodelijstWaarde"/>
</xs:schema>
<!--<xs:schema targetNamespace="http://rechtspraak.nl/Service/DataTypes"-->
<!--xmlns:q1="http://rechtspraak.nl/Service/DataTypes">-->
<!--<xs:simpleType name="String50">-->
<!--<xs:restriction base="xs:string">-->
<!--<xs:minLength value="1"/>-->
<!--<xs:maxLength value="50"/>-->
<!--</xs:restriction>-->
<!--</xs:simpleType>-->
<!--<xs:element name="String50" type="q1:String50" xmlns:q1="http://rechtspraak.nl/Service/DataTypes"/>-->
<!--</xs:schema>-->
<xs:schema elementFormDefault="qualified" targetNamespace="http://rechtspraak.nl/Service/Metadata" xmlns:tns="http://rechtspraak.nl/Service/Metadata">
<xs:import namespace="http://rechtspraak.nl/Service/DataTypes"/>
<xs:complexType name="CodelijstWaarden">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="CodelijstWaarde" nillable="true" type="q1:CodelijstWaarde" xmlns:q1="http://rechtspraak.nl/Service/DataTypes" />
</xs:sequence>
</xs:complexType>
<xs:element name="CodelijstWaarden" type="tns:CodelijstWaarden"/>
</xs:schema>
</wsdl:types>
</wsdl:definitions>
When I run vendor/bin/soap-client -vvv generate config/config.yml src/Service/Container --dest-class=Service/Container/SoapContainer
in the demo app, it generates all code just fine. But if I uncomment the second schema, I get the following error:
In SchemaReader.php line 1024:
[GoetasWebservices\XML\XSDReader\Exception\TypeException]
Can't find type named {http://rechtspraak.nl/Service/DataTypes}#CodelijstWaarde, at line 34 in ~/soap-client-demo/config/metadata-snippet.xml
What do you think the intended behaviour of your library should be?
from soap-client.
Oh, btw, if I uncomment and put the second block on top, it all works fine, so that indicates that it is overriding the first schema (or at least the reference).
from soap-client.
The trick stays somewhere in this lines:
https://github.com/goetas-webservices/xsd-reader/blob/58aafb98e868b9fb0e0553a8a6310fc99164a166/src/Schema/Schema.php#L33
There is performed the search of elements, if you are interested to play with it, that should be a good starting point.
from soap-client.
Thanks! I'll have a look at it today
from soap-client.
Yet another day of debugging and I FINALLY found the bug, yay!
The schema gets overridden on line:
https://github.com/goetas-webservices/xsd-reader/blob/58aafb98e868b9fb0e0553a8a6310fc99164a166/src/Schema/Schema.php#L267
This behaviour seems inconsistent with that of SchemaReader::loadedSchemas[NAMESPACE][]
, which is a multidimensional array, also indexed by namespace.
So the following if statement fixes the issue, but does not seem to me as a proper fix.
public function addSchema(self $schema, string $namespace = null): void
{
if ($namespace !== null) {
if ($schema->getTargetNamespace() !== $namespace) {
throw new SchemaException(
sprintf(
"The target namespace ('%s') for schema, does not match the declared namespace '%s'",
$schema->getTargetNamespace(),
$namespace
)
);
}
/** FIX STARTS HERE **/
dump('Now adding child schema on array key '.$namespace);
if (isset($this->schemas[$namespace])) {
dump('but it is already set! Oh well, we just save a copy of it');
$this->schemas[] = $this->schemas[$namespace];
}
/** END FIX **/
$this->schemas[$namespace] = $schema;
} else {
$this->schemas[] = $schema;
}
}
I can verify that above fix works for multiple schemas in one file.
We could make the schemas
property multidimensional too, but I'm afraid that will break BC. Suggestions?
from soap-client.
goetas-webservices/xsd-reader#40 was merged
from soap-client.
Related Issues (20)
- CDATA HOT 8
- SoapFault HOT 2
- Adding xmlns:xsi XMLSchema-instance HOT 5
- Soap Security Header HOT 15
- SOAP-Envelope
- Problems with Symfony 4.3 HOT 1
- Multiple xml_root_namespace HOT 1
- Find Element. HOT 3
- Generate soap client inside existing Symfony app container HOT 2
- Fault Header
- Bug in example HOT 4
- FAULTDETAIL
- Update JMS Serializer HOT 1
- Can't make anyType to work with soap-client HOT 1
- Is there a way to see/print the request and response messages? HOT 1
- HTML_ENTITY_DECODE
- How to pass credentials to client? HOT 2
- About credentials HOT 2
- Release request (0.2.12) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from soap-client.