Suds with Soap request as Raw xml is working after i used byte_str to convert the raw xml string to byte_str
please find the code .I used this from suds import byte_str .
But i am getting Object reference not set to an instance of an object when i pass as object instead of xml
please find the code .I used this from suds import byte_str .
But i am getting Object reference not set to an instance of an object when i pass as object instead of xml
import numpy as np # installed with matplotlib import matplotlib.pyplot as plt import logging import suds import ssl import requests import base64 def main(): from suds.sax.element import Element from suds.sax.attribute import Attribute from suds import byte_str from suds.sax.text import Raw from suds.client import Client from suds.bindings import binding binding.envns=('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope') from suds.plugin import MessagePlugin https = suds.transport.https.HttpTransport() urlvalue="https://wvua-eucluw-iws-446.aceins.com:446/WorkView/DocumentService/DocumentService.svc?wsdl" client = Client(urlvalue ,unwrap=False,transport=https) client.options.cache.clear() client.options.headers.clear() client.set_options(headers={"Content-type" : 'application/soap+xml; charset=UTF-8','SoapAction':'http://xxxx.com/xxxxyyyy/DocumentService/2016/06/DocumentService/GetSpecificDocument'}) client.options.prettyxml = True #logging.basicConfig(level=logging.DEBUG) #logging.getLogger('suds.client').setLevel(logging.DEBUG) inputxml=Raw("""<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:ns0="http://xxxx.com/xxxyyyy/DocumentService/2016/06" xmlns:ns1="http://www.w3.org/2003/05/soap-envelope" xmlns:ns2="http://xxxx.com/xxxyyyy/DocumentService/2016/06"> <SOAP-ENV:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> <wsa:Action>http://xxxx.com/xxxyyyy/DocumentService/2016/06/DocumentService/GetSpecificDocument</wsa:Action> <wsa:To SOAP-ENV:mustUnderstand="true">https://xxxx.com/xxxyyyy/DocumentService/DocumentService.svc</wsa:To> </SOAP-ENV:Header> <ns1:Body> <ns0:GetSpecificDocument> <ns0:request> <ns2:DocumentGUID>0D7B80C9-4356-44D4-8C6E-4D479409F314</ns2:DocumentGUID> <ns2:EnvironmentData> <ns2:MessageGUID>msg-ID</ns2:MessageGUID> <ns2:CountryCode>GB</ns2:CountryCode> <ns2:SourceSystem>TrackandTrace</ns2:SourceSystem> <ns2:xxxxyyyyLogonID>TrackandTrace</ns2:xxxxyyyyLogonID> <ns2:xxxxyyyyEnvironment>UAT</ns2:xxxxyyyyEnvironment> </ns2:EnvironmentData> </ns0:request> </ns0:GetSpecificDocument> </ns1:Body> </SOAP-ENV:Envelope> """) message = byte_str(inputxml) try: print('Start...') specificDocumentResponse =client.factory.create('ns0:SpecificDocumentResponse') specificDocumentResponse =client.service.GetSpecificDocument(__inject={'msg': message}) for item in specificDocumentResponse: extention = item[1].xxxxyyyyDocument.MimeType documentdata = item[1].xxxxyyyyDocument.DocumentData base64_img_bytes = documentdata.encode('utf-8') with open('test.'+extention, 'wb') as file_to_save: decoded_image_data = base64.decodebytes(base64_img_bytes) file_to_save.write(decoded_image_data) print ('Passed') except RuntimeError as detail: print ('Handling run-time error:'+ detail) print("passed") main()
Larz60+ write Sep-30-2022, 04:47 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please heed above. Continuing without using tags may lead to warning.
Fixed for you one more time.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please heed above. Continuing without using tags may lead to warning.
Fixed for you one more time.