0

A python rookie here and thank you for taking time to help.

I am sending a SOAP request to download some mp4 recordings from a server using zeep. The server responds by sending the following MessagePack attachments. How do I unpack this and convert to mp4. The multi-part attachment has both the decsription of the file and the actual MP4 file itself. Thanks

<MessagePack(attachments=[<Attachment('<6X3ER09X000X401BEFX91B4FFBD48906>', 'application/octet-stream')>, <Attachment('<0XECXX28CX0RS9DD28BYYA9F2CBA177D>', 'application/octet-stream')>])>

Here is the code I am trying to use

def get_record(client, siteid, username, passwd, ticket):
    return client.downloadNBRStorageFile(**{'siteId': 'xxxxx', 'recordId': xxxxx, 'ticket':ticket})

def main():

client = Client(wsdl=wsdl)
service = client.create_service(BINDING_NAME, ADDRESS)
resp = update_phone_by_name(service, siteid, username, password, ticket)
pack = client.service.downloadNBRStorageFile
recording = pack.root
description = pack.attachments[0].content
rec_file = pack.attachments[1].content

When I run this I get this error "recording = pack.root AttributeError: 'OperationProxy' object has no attribute 'root'"

I am trying to do the same as this post but unable to figure out how to download the attachments

Python SOAP WSDL works in SOAPpy but not ZSI or zeep

----Edit-----Update----- I have updated the code as below:

def get_ticket(client):
    global rec_ticket
    global ticket
    rec_ticket = client.getStorageAccessTicket(**{'siteId': siteid, 'username': username, 'password': password})
    return rec_ticket

def get_record(client):
    return client.downloadNBRStorageFile(**{'siteId': 'xxxxx', 'recordId': 

recordid, 'ticket':rec_ticket})

def main():
    client = Client(wsdl=wsdl)
    axl = client.create_service(BINDING_NAME, ADDRESS)
    resp_ticket = get_ticket(axl)
    resp_rec = get_record(axl)
    pack = client.service.downloadNBRStorageFile(siteid, recordID, rec_ticket)

    record_details = pack.root
    record_file = pack.attachments[1].content

However I get the response below: " raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.224.91.216', port=2001): Max retries exceeded with url: /nbr/services/NBRStorageService (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))"

Dejoskii
  • 1
  • 2
  • What have you tried so far? Have you read through the zeep documentation? There is some example code [in the docs](https://python-zeep.readthedocs.io/en/master/attachments.html). – larsks Nov 28 '18 at 02:35
  • Thanks larsks. I have looked at that doc but it does not help or I cant seem to understand how to apply it to this scenario. I have updatedmy question to include the code I am trying to use and the error I am getting – Dejoskii Nov 28 '18 at 04:16
  • Can anyone please help out here. – Dejoskii Nov 29 '18 at 10:10

1 Answers1

0

You're not actually calling client.service.downloadNBRStorageFile. To actually call the method, you would need:

pack = client.service.downloadNBRStorageFile()

(Note the parentheses on the end.)

Your current code is simply assigning the client.service.downloadNBRStorageFile object to your pack variable, which is why your error message refers to an OperationProxy type.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • Thank you @larsks for taking time to help me on this. I modified the code as shown above but I just get connection timeout. NB if I remove the pack commands, the server responds with the messagePack attachments – Dejoskii Nov 29 '18 at 15:52