Bad Request When calling SOAP request from Suds Python

Viewed 19

When I call a SOAP request from suds python ,it is giving Bad request .I created the request objects from wsdl and pass the object to the method .It is throwing Bad request .Alternatively I sent the request as Raw XML ,it is also not working .Find the code below

   from suds.sax.text import Raw
   from suds.client import Client

   https = suds.transport.https.HttpTransport()
   urlvalue="https://wvuaxx.com:446/xxxrkView/DocumentService/DocumentService.svc?wsdl"
   client = Client(urlvalue ,unwrap=False)
   client.options.cache.clear()
   client.options.headers.clear()
   client.set_options(headers={"Content-type" : 'application/soap+xml; charset=UTF- 
   8','Soapaction': 
   'http://xxxx.com/xxxxview/DocumentService/2016/06/DocumentService/GetSpecificDocument'})
   client.options.prettyxml = True
   client.options.autoblend  = True

   # Constructing request objects
   spcificdocumentrequest =client.factory.create('ns0:SpecificDocumentRequest')
  
   envrionmentdata=client.factory.create('ns0:EnvironmentData')
   envrionmentdata.MessageGUID = "msgId"
  
   spcificdocumentrequest.EnvironmentData=envrionmentdata

   logging.basicConfig(level=logging.DEBUG)
   logging.getLogger('suds.client').setLevel(logging.DEBUG)
   response =client.service.GetSpecificDocument(spcificdocumentrequest)
   print (response)
   ------------------------------------------------------------------------------------------- 
   xml=Raw("""<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
   xmlns:ns="http://xxxx.com/xxxview/DocumentService/2016/06"
   xmlns:ns1="http://xxxx.com/xxxView/DocumentService/2016/06">
   <soap:Header/>
   <soap:Body>
  <ns:GetSpecificDocument>
     <!--Optional:-->
     <ns:request>
        <!--Optional:-->
        <ns1:DocumentGUID>D589A450-D3CA-4D55-8A0D-1D47E0DD01A2</ns1:DocumentGUID>
        <!--Optional:-->
        <ns1:IsSecurityCheckRequired></ns1:IsSecurityCheckRequired>
        <!--Optional:-->
        <ns1:UserId></ns1:UserId>
        <!--Optional:-->
        <ns1:FileNumber></ns1:FileNumber>
        <!--Optional:-->
        <ns1:FileType></ns1:FileType>
        <!--Optional:-->
        <ns1:EnvironmentData>
           <ns1:MessageGUID>Test-Message-guid</ns1:MessageGUID>
           <ns1:CountryCode>GB</ns1:CountryCode>
           <ns1:SourceSystem>TrackandTrace</ns1:SourceSystem>
           <ns1:xxxxViewLogonID>TrackandTrace</ns1:xxxxViewLogonID>
           <ns1:xxxxViewEnvironment>UAT</ns1:xxxxViewEnvironment>
        </ns1:EnvironmentData>
     </ns:request>
    </ns:GetSpecificDocument>
    </soap:Body>
    </soap:Envelope>
   """)

   response =client.service.GetSpecificDocument( __inject={'msg':xml})
0 Answers
Related