mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.89k stars 586 forks source link

Working with extended types #884

Open mbunse opened 5 years ago

mbunse commented 5 years ago

I'm struggling with the same problem as Vasireddydivya reported here while trying to access a legacy IBM FileNet server.

WSDL is available here: https://github.com/mulesoft/mule-wsdl-parser/blob/master/src/test/resources/wsdl/multiple-imports-as-value/multiple-imports-base.wsdl https://github.com/mulesoft/mule-wsdl-parser/blob/master/src/test/resources/wsdl/multiple-imports-as-value/multiple-detailed.wsdl

I am using version 2.5.0 of zeep .

I managed to manually write a working xml request. It looks like this:

<soap:Envelope xmlns:sch="http://www.filenet.com/ns/fnce/2006/11/ws/schema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
      <sch:ExecuteSearchRequest continuable="true" continueFrom="" maxElements="10" repositorySearchMode="Rows" xsi:type="RepositorySearch">
         <sch:SearchScope objectStore="ObjStoreName" xsi:type="ObjectStoreScope"/>
         <sch:SearchSQL>SELECT DocumentTitle FROM FOO</sch:SearchSQL>
      </sch:ExecuteSearchRequest>
   </soap:Body>
</soap:Envelope>

Unfortunatly, I am not able to reproduce this with zeep. The problem is to create ExecuteSearchRequest of type RepositorySearch.

The operation is defined as follows:

        <operation name="ExecuteSearch">
            <input message="cdef:ExecuteSearchRequest"/>
            <output message="cdef:ExecuteSearchResponse"/>
            <fault name="GeneralError" message="cdef:FaultResponse"/>
        </operation>

ExecuteChangesRequest is defined as

            <xsd:element name="ExecuteSearchRequest" type="SearchRequestType"/>
            <xsd:complexType name="SearchRequestType" abstract="true">
                <xsd:sequence>
                    <xsd:element name="SelectionFilter" type="PropertyFilterType" minOccurs="0"/>
                </xsd:sequence>
                <xsd:attribute name="maxElements" type="xsd:int"/>
                <xsd:attribute name="continueFrom" type="xsd:string"/>
                <xsd:attribute name="continuable" type="xsd:boolean"/>
            </xsd:complexType>

            <xsd:complexType name="RepositorySearch">
                <xsd:complexContent>
                    <xsd:extension base="SearchRequestType">
                        <xsd:sequence>
                            <xsd:element name="SearchScope" type="SearchScopeType"/>
                            <xsd:element name="SearchSQL" type="xsd:string"/>
                        </xsd:sequence>
                        <xsd:attribute name="repositorySearchMode" type="RepositorySearchModeType"/>
                    </xsd:extension>
                </xsd:complexContent>
            </xsd:complexType>

My code looks like

from zeep import Client

client = Client("filenet.wsdl")
search_type = client.get_type('ns0:RepositorySearch')
node = client.create_message(client.service, 'ExecuteSearch', search_type())

But this already gives the following error:

  File "C:\...\lib\site-packages\zeep\xsd\elements\element.py", line 236, in validate
    "Missing element %s" % (self.name), path=render_path)
zeep.exceptions.ValidationError: Missing element SearchScope (ExecuteSearchRequest.SelectionFilter.SearchScope)

But SearchScope should not be a sub element of SelectionFilter, it should be a sub element of ExecuteSearchRequest, according to the schema above.

from zeep import Client

client = Client("filenet.wsdl")
search_scope = factory.ObjectStoreScope(objectStore="ObjStoreName")
search_sql = "SELECT DocumentTitle FROM FOO"
repository_search = factory.RepositorySearch(SearchSQL=search_sql,
    SearchScope=search_scope,
    maxElements=10,
    repositorySearchMode="Rows",
    )
node = client.create_message(client.service, 'ExecuteSearch', repository_search)

results in the following output:

<soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope">
  <soap-env:Body>
    <ns0:ExecuteSearchRequest xmlns:ns0="http://www.filenet.com/ns/fnce/2006/11/ws/schema">
      <ns0:SelectionFilter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" maxElements="10" repositorySearchMode="Rows" xsi:type="ns0:RepositorySearch">
        <ns0:SearchScope objectStore="ObjStoreName" xsi:type="ns0:ObjectStoreScope"/>
        <ns0:SearchSQL>SELECT DocumentTitle FROM FOO</ns0:SearchSQL>
      </ns0:SelectionFilter>
    </ns0:ExecuteSearchRequest>
  </soap-env:Body>
</soap-env:Envelope>

where again, SearchScope und SearchSQL are subelements of subselection which shouldn't be the case.

Any help would be appreciated.

Haigutus commented 2 years ago

Any updates on this issue?

jeromerg commented 1 year ago

Same question: Any update on this issue?

kwosie commented 9 months ago

having this same issue - any updates here? seems the class CompoundValue: doesn't work the same on the first object of the body.