[Fedora-suds-list] Issue using suds with Sharepoint (CopyIntoItems)

DINE, TIM TIM.DINE at nspower.ca
Thu Aug 9 17:20:36 UTC 2012


I've just recently found suds, but have been using python for quite a while now.  Suds looks great.  I'm having an issue with combining suds and sharepoint.  I have been able to get a few different commands to function correctly, like creating a folder, but haven't gotten copyintoitems to work yet.  Getting it to go was the original reason I ended up finding suds.

The documentation seems to suggest that I need to build the XML elements manually and then pass them to the service rather than a string, specifically for the destinationurls.  When I attempt this I do not get any text content in those elements (they just end <DestinationUrls/> rather than being <DestinationUrls><string>some text</string></DestinationUrls>).  Has anyone used the webservices in sharepoint with suds to upload files?  Is there something obvious that I am missing?

Thanks for any help you may be able to provide.

Tim


import suds
import base64
import os
import logging
from suds.transport.https import WindowsHttpAuthenticated
from suds.sax.element import Element
from suds.sax.attribute import Attribute

logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)

ntlm = WindowsHttpAuthenticated(username='obscured', password='obscured')
client = suds.client.Client('http://obscured/gis/_vti_bin/copy.asmx?WSDL', transport=ntlm)

theSourceUrl = Element('ns1:SourceUrl').setText("something.pdf")
theDestinationURLs = Element('ns1:DestinationUrls')
theString = Element('string').setText('http://obscured/GIS/One%20Line%20Maps/Work%20Depot%20by%20Scale')
theDestinationURLs.append(theString)
theFields = Element('ns1:Fields')
theFieldInformation = Element('FieldInformation')
theFields.append(theFieldInformation)
sampleBytes = 'AwMDExODQ5MjcgMDAwMDAgbgowMDAxMTg1MTA2IDAwMDAwIG4KMDAwMDAwODA5NiAwMDAwMCBuCnRyYWlsZXIKPDwvU2l6ZSA2Mzg'  #Excerpt from the actual bytes of the file I am uploading
theStream = Element('Stream').setText(sampleBytes)

theResult = client.service.CopyIntoItems(theSourceUrl,theDestinationURLs,theFields,theStream)
theResult = client.service.CopyIntoItems('something.pdf', theDestinationURLs, '', sampleBytes)


Request 1:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><ns0:Body><ns1:CopyIntoItems><SourceUrl/><DestinationUrls/><ns1:Fields></ns1:Fields><Stream/></ns1:CopyIntoItems></ns0:Body></SOAP-ENV:Envelope>

Request 2:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><ns0:Body><ns1:CopyIntoItems><ns1:SourceUrl>something.pdf</ns1:SourceUrl><DestinationUrls/><ns1:Fields></ns1:Fields><ns1:Stream>AwMDExODQ5MjcgMDAwMDAgbgowMDAxMTg1MTA2IDAwMDAwIG4KMDAwMDAwODA5NiAwMDAwMCBuCnRyYWlsZXIKPDwvU2l6ZSA2Mzg</ns1:Stream></ns1:CopyIntoItems></ns0:Body></SOAP-ENV:Envelope>



Confidentiality Notice - The email communication is considered confidential
and is intended only for the recipient(s). If you received this email in error,
please contact the sender and delete the email. Unauthorized disclosure or
copying of this email is prohibited.

Attachment Limits - Emera will not accept email larger than 10MB or emails 
containing high risk attachments like ZIP, EXE or others that could contain viruses.
If you have a business need to send such an email, please contact the recipient for instructions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.fedoraproject.org/pipermail/suds/attachments/20120809/ff32d0b6/attachment.html>


More information about the suds mailing list