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

Matthew Ashton matthew.ashton3 at gmail.com
Thu Aug 9 18:32:06 UTC 2012


Perhaps Suds isn't recognizing the elements in the request are a list?
The only items you successfully put in the request are Elements that call
setText to put a string in the field, but the other Elements you try to
append the string to a list...

Formally I've used suds to handle it's own definitions of soap objects and
use them in a call, like after getting the client ->
theCopyIntoRequest = client.factory.create("ns1:CopyIntoRequest") #which is
the SOAP definition of the request, Suds generates metadata (and other
stuff) to properly handle this (I don't know what object is needed here)

theCopyIntoRequest.DestinationUrls.append('url1') #etc (assuming this is
correct)

I don't know about your SOAP objects but I'd think you'd have an easier
time going through Suds to interface with the wsdl


On Thu, Aug 9, 2012 at 12:20 PM, DINE, TIM <TIM.DINE at nspower.ca> wrote:

>  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.
>
>
> _______________________________________________
> suds mailing list
> suds at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/suds
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.fedoraproject.org/pipermail/suds/attachments/20120809/c6e344f0/attachment-0001.html>


More information about the suds mailing list