Skip to content
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

wrong namespace prefix in SOAP request #41

Open
stuartz opened this issue Jul 16, 2019 · 0 comments
Open

wrong namespace prefix in SOAP request #41

stuartz opened this issue Jul 16, 2019 · 0 comments

Comments

@stuartz
Copy link

stuartz commented Jul 16, 2019

I had the same issue as refrenced in this stackoverflow. Alex Miro explained the issue and provided a work around on suds. I believe it will also work on suds-py3. I tried the same solution on my program and it worked perfectly. Something I had been struggling with for a while.

quote:

I use python/suds to implement a client and I get wrong namespace prefixes in the sent SOAP header for a spefic type of parameters defined by element ref= in the wsdl.

The .wsdl is referencing a data types .xsd file, see below. The issue is with the function GetRecordAttributes and its first argument of type gbt:recordReferences.

File: browse2.wsdl

<xsd:schema targetNamespace="http://www.grantadesign.com/10/10/Browse" xmlns="http://www.grantadesign.com/10/10/Browse" xmlns:gbt="http://www.grantadesign.com/10/10/GrantaBaseTypes" elementFormDefault="qualified" attributeFormDefault="qualified"> <xsd:import schemaLocation="grantabasetypes2.xsd" namespace="http://www.grantadesign.com/10/10/GrantaBaseTypes"/> <xsd:element name="GetRecordAttributes"> <xsd:complexType> <xsd:sequence> <xsd:element ref="gbt:recordReferences"> </xsd:element>

Referenced File : grantabasetypes2.xsd

<element name="recordReferences"> <complexType> <sequence> <element name="record" minOccurs="0" maxOccurs="unbounded" type="gbt:MIRecordReference"/> </sequence> </complexType> </element>

SOAP Request sent by suds:

<SOAP-ENV:Envelope xmlns:ns0="http://www.grantadesign.com/10/10/GrantaBaseTypes" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://www.grantadesign.com/10/10/Browse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <ns1:Body> <ns2:GetRecordAttributes> <ns2:recordReferences> <ns0:record> </ns0:record> </ns2:recordReferences> </ns2:GetRecordAttributes> </ns1:Body> </SOAP-ENV:Envelope>

Problem : ns2:recordReferences has wrong prefix, should be ns0:recordReferences since it belongs to the namespace ...GrantaBaseTypes defined in the .xsd.

This happens for all arguments defined by ref= in the wsdl. How can this be automatically fixed?

Note: I checked that the "good" prefix is accepted by the service by manually sending the xml SOAP request via curl.

UPDATE

I meddled with SUDS source code and the following empirical fix forces all elements with ref= attribute to assume the ref-ed namespace (previously, they take on the schema root namespace or whatever tns is):

File: /suds/xsd/sxbase.py

class SchemaObject(object):
....
    def namespace(self, prefix=None):
         ns = self.schema.tns

         #FIX BEGIN
         if self.ref and self.ref in self.schema.elements.keys():
            ns = self.ref
         #FIX END

end quote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant