python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

Space is getting inserted between characters of xml restriction element

Open mmsrgit opened this issue 1 year ago • 0 comments

Hi, I am facing an issue where blank spaces are getting inserted in between characters of generated xml element. I am not able to figure out why this is happening.

from zeep import Client, helpers, Settings
from zeep.plugins import HistoryPlugin
from lxml import etree
history = HistoryPlugin()
client = Client("SearchService.wsdl", plugins = [history])
ret_sea = client.get_type("ns0.MemberDetails")
sea_ser = client.get_type("ns0.SearchService")
source_t = client.get_type("ns0.Source")
members = ret_sea(Source= source_t('PAP'), NetworkID='TN7620384', Product='Gems')
sea_req = sea_ser(AppKey='89d038s0s-383nnsu3ms', members=members)
response = client.service.RetrieveMemberDetails(sea_req)
for hist in [history.last_sent, history.last_received]:
    print(etree.tostring(hist["envelope"], encoding = "unicode", pretty_print = True))

which gives me following xml request on console

...
   <ns0:MemberDetails>
      <ns0:Source>P A P</ns0:Source>
      <ns0:NetworkID>TN7620384</ns0:NetworkID>  
      <ns0:Product>Gems</ns0:Product>
   </ns0:MemberDetails>
...

Because of spaces getting added in Source value, I am not getting response.

The Source xsd element is enumeration type defined in xsd as below.

<xs:simpleType name="Source">
  <xs:list>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="PAP"/>
        <xs:enumeration value="XYZ"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:list>
</xs:simpleType name="Source">

mmsrgit avatar Aug 03 '22 18:08 mmsrgit