mvantellingen / python-zeep

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

tag <sessionHeader> missing in soapheader part #783

Open bghuang opened 6 years ago

bghuang commented 6 years ago

I already performed login successfully. But when I performed operation WorkOrderIntf_submit the xml file generated without tag.

......
Global types:
......
     ns0:Session(sessionId: xsd:string, wsdlVersion: xsd:string, sessionNVs: ns0:ArrayOfNameValue)
......
Service: ProvService
     Port: ProvPort (Soap11Binding: {http://alcatel-lucent.com/esm/ws/prov/V2_0}ProvBinding)
         Operations:
......
            WorkOrderIntf_submit(wo: ns0:WorkOrderData, isNew: xsd:boolean, _soapheaders={sessionHeader: ns0:Session}) -> header: {sessionHeader: ns0:Session}, body: {result: xsd:boolean, woName: xsd:string, valErrors: ns0:ArrayOfValError}

Current XML request generated with header:

<soap-env:Header>
    <ns0:sessionId xmlns:ns0="http://xxx.com/abc/ws/prov/V2_0">1243066533</ns0:sessionId>
    <ns1:wsdlVersion xmlns:ns1="http://xxx.com/abc/ws/prov/V2_0">V2_0</ns1:wsdlVersion>
</soap-env:Header>

But actually expect

<soap-env:Header>
  <sessionHeader xmlns="http://xxx.com/abc/ws/prov/V2_0">
    <ns0:sessionId xmlns:ns0="http://xxx.com/abc/ws/prov/V2_0">1243066533</ns0:sessionId>
    <ns1:wsdlVersion xmlns:ns1="http://xxx.com/abc/ws/prov/V2_0">V2_0</ns1:wsdlVersion>
  </sessionHeader>
</soap-env:Header>

Tag "sessionHeader" is missing.

code related:

sessoin_header_obj = factory.Session(sessionId=session_header.sessionId,wsdlVersion=session_header.wsdlVersion,sessionNVs=session_header.sessionNVs)
workorder_response = client.service.WorkOrderIntf_submit(wo_data,True,_soapheaders=[sessoin_header_obj])

How can I control to generated tag "sessionHeader" in tag "soap-env:Header"?

bghuang commented 6 years ago

Issue resolved:

session_header_type = client.get_element('ns0:sessionHeader')
session_header2 = session_header_type(sessionId=session_header.sessionId,wsdlVersion=session_header.wsdlVersion,sessionNVs=session_header.sessionNVs)

workorder_response = client.service.WorkOrderIntf_submit(wo_data,True,_soapheaders=[session_header2])
plaes commented 4 years ago

Yeah, SOAP headers are described in documentation, so this issue can be closed.