[Fedora-suds-list] optional elements

Jeff Ortel jortel at redhat.com
Thu May 21 12:50:43 UTC 2009


Hey Yi,

Welcome to suds :-)

That is annoying.  Making input XML have elements that are required and read only is 
contradictory.  They (the service provider) must be using these elements in reply messages 
as well.

Anyway, The suds factory doesn't (currently) provide a way to specify a way to filter 
(in|out) nodes.  Although, I'm very willing to discuss added this functionality if we 
can't find a suitable work around.

In the mean time, a good workaround might be to use the schema /doctor/ functionality 
introduced in 0.3.6 beta.  You'll have to get from trunk or wiki.  You can implement a 
Doctor to mark these elements to minOccurs=0 like you did in your local copy.  Using the 
schema doctor will at least keep you from having to maintain a local copy of the wsdl.

You can do something like:

from suds.xsd.doctor import Doctor

class MyDoctor(Doctor):
   def examine(root):
     <navigate to problem elements>
     child = root.getChild('xyz')
     child.set('minOccurs', 0)

In you code:

client = Client(url, schemadoctor=MyDoctor())

Hope this helps.
Please let me know how you make out.

Regards,

Jeff

Yi Qiang wrote:
> Hi,
> The WSDL I am trying to use suds with is a bit annoying in that it 
> defines certain elements as REQUIRED but read only. For example, it will 
> have something like the following:
> 
> <s:element minOccurs="1" maxOccurs="1" name="fDefault" type="s:boolean"/>
> 
> So when suds generates the SOAP request, it will put the following as a 
> default:
> 
> <ns0:fDefault xsi:nil="true"/>
> 
> Then the server complains that this is not valid. If I set this to say 
> "true" or "false", the server complains that this field is read only.
> 
> The only way I've been able to work around this is to download the WSDL 
> from the server, make that element optional by changing "minOccurs" to 0.
> 
> Is there anyway to tell suds to not put default elements? I.e., only 
> create XML elements that I specifically ask for?
> 
> Thanks,
> Yi
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> fedora-suds-list mailing list
> fedora-suds-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-suds-list




More information about the fedora-suds-list mailing list