[Soap-Python] How to add soap header in request

Aafak Mohammad aafak.mitsmca09 at gmail.com
Fri Mar 17 05:05:15 EDT 2017


Hi i am using pysimplesoap latest api with python 2.6 just want to add
header in my request how i can do that?
following is my code i am trying

client = SoapClient(wsdl='mcsdk10.wsdl',
                    location="https://10.10.11.164:9443/services/mcsdk10",
                    trace=True,
                    ns=True,
                    sessions=True,
                    exceptions=True,
                    )

soap_header = {
    'axis2:ServiceGroupId': result['return']['name'],
    'wsa:To': 'https://10.136.12.230:9443/services/mcsdk10',
    'wsa:MessageID': result['return']['name'],
    'wsa:Action': 'urn:getProfileInfo'
}
*client['headers']= soap_header*


result = client.getProfileInfo(args0={'description': "/p1", 'name':
'p1', 'value':'p1'})


also i have tried following

ServiceGroupId = SimpleXMLElement('<Headers/>', namespace=namespace, prefix=ns)
ServiceGroupId['axis2']='http://ws.apache.org/namespaces/axis2'
ServiceGroupId.marshall('axis2:ServiceGroupId',result['return']['name'])
ServiceGroupId.marshall('wsa:To','https://10.136.12.230:9443/services/mcsdk10')
ServiceGroupId.marshall('wsa:MessageID', result['return']['name'])
ServiceGroupId.marshall('wsa:Action', 'urn:getProfileInfo')
*client['headers']=ServiceGroupId*

Both the way it is not working
it is always sending the request with empty header

DEBUG:pysimplesoap.client:<?xml version="1.0"
encoding="UTF-8"?><soapenv:Envelope xmlns:True="http://sdk10.mc.avamar.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
*<soapenv:Header/>*
<soapenv:Body><True:getProfileInfo><args0
xmlns="http://sdk10.mc.avamar.com"><description
xmlns="http://sdk10.mc.avamar.com/xsd">/p1</description><name xmlns="
http://sdk10.mc.avamar.com/xsd">p1</name><value xmlns="
http://sdk10.mc.avamar.com/xsd
">p1</value></args0></True:getProfileInfo></soapenv:Body></soapenv:Envelope>


I just want to pass tp achieve following request

<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">

                <soapenv:Header xmlns:wsa="
http://www.w3.org/2005/08/addressing">



                                <axis2:ServiceGroupId xmlns:axis2="
http://ws.apache.org/namespaces/axis2" wsa:IsReferenceParameter="true">
urn:uuid:F2BB85C670F832B7A71489646820629</axis2:ServiceGroupId>
                <wsa:To>
https://Avamar_Server_IP:9443/services/mcsdk10</wsa:To>


<wsa:MessageID>urn:uuid:D9DD8A6C7B1FAB9CA61489646819241</wsa:MessageID>

                                <wsa:Action>urn:getProfileInfo</wsa:Action>

                </soapenv:Header>

                <soapenv:Body>

                                <ns4:getProfileInfo xmlns:ns4="
http://sdk10.mc.avamar.com">

                                                <ns4:args0 xmlns:ns3="
http://sdk10.mc.avamar.com/xsd" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns3:ProfileMoref">


<ns3:description>/UniqueProfileName</ns3:description>


<ns3:name>UniqueProfileName</ns3:name>


<ns3:value>1489646817758</ns3:value>

                                                </ns4:args0>

                                </ns4:getProfileInfo>

                </soapenv:Body>

</soapenv:Envelope>



I am able to pass body, but not header

Thanks in advance
-- 

Thanks & Regards,

*Aafak Mohammad*

Senior Software Engineer

*Dell **EMC* | GSE | India COE |

Mobile :  +91 9731519922

*Ext: 7857799*

aafak.mohammad at Dell.com

<http://www.cloudbyte.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/soap/attachments/20170317/0bd6152a/attachment.html>


More information about the Soap mailing list