Invalid content generated when RequireValidWhenGenerating is False
sinitsynsv opened this issue · comments
Sergei Sinitsyn commented
Hello. I took this wsdl file and generated bindings, running command pyxbgen -W wsdl_test.wsdl
. Here is example script:
import pyxb
import pyxb.bundles.wssplat.soap11 as soapenv
import binding
# pyxb.RequireValidWhenGenerating(False)
request_header = None
request_body = binding.GetCitiesByCountry(
CountryName='Russia')
env = soapenv.Envelope(
soapenv.Body(request_body)
)
print(env.toxml())
When I run this script, I get this xml
<?xml version="1.0" ?>
<ns1:Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://www.webserviceX.NET">
<ns1:Body>
<ns2:GetCitiesByCountry>
<ns2:CountryName>Russia</ns2:CountryName>
</ns2:GetCitiesByCountry>
</ns1:Body>
</ns1:Envelope>
But when I uncomment 4-th line (# pyxb.RequireValidWhenGenerating(False)
) I get this
<?xml version="1.0" ?><ns1:Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"><ns1:Body/></ns1:Envelope>
Body element is empty.
Peter A. Bigot commented
Generating documents often requires information that comes from the validation phase. Disabling validation puts PyXB into a mode that may be useful during development but that does not provide any promise of correct behavior.