Pregunta

Estoy usando Access y SharePoint 2010. Estoy escribiendo un script de Python, que lee periódicamente las tablas, verifica algunas condiciones y, finalmente, escribe notificaciones por correo electrónico. No tengo permiso para acceder directamente al servidor de SharePoint. También [1]:

Interactuar directamente con una base de datos de contenido de SharePoint causará Su instalación de SharePoint para perder el soporte de Microsoft.

La solución más simple por ahora sería descargar la base de datos a través del acceso, pero primero, no sé cómo hacerlo programáticamente. En segundo lugar, al extender mi solicitud, podría necesitar actualizar la base de datos también.

Así que mi mejor apuesta parece estar usando jabón. Cuando uso el acceso para publicar una tabla simple a SharePoint [2], Afaik, puedo leerlo y escribirlo a través de SharePoints SOAP API proporcionado por ... / _ vti_bin / larss.mxs.mx [3]. Puedo ver en todos los contenidos del sitio que la tabla es un código de lista (cuando paseo sobre el enlace con el MousePointer, puedo ver la función JavaScript que se llama con los parámetros que contienen "... listnode. .. "). Pero cuando publico una base de datos más compleja del acceso, un ACCDB con formularios, es un código web en lugar de un código de lista. Cuando lo selecciono en Todo el contenido del sitio , puedo hacer clic en Opciones:> Configuración donde obtengo una lista de las tablas de la base de datos publicada. ¿Cómo puedo acceder a una tabla en particular de esta lista desde mi script de Python a través de SOAP? Un ejemplo sería mucho apreciado.

hasta ahora tengo esto:

from suds import WebFault
from suds.client import *
from suds.transport.https import WindowsHttpAuthenticated # for https authentification

USER = r'Domain\02345434' #the number is the user id
PWD = 'secret'
#My guess is that you need webs.asmx for accessing WebNodes instead of ListNodes
URL = 'https://mysite.sharepointserver.com/_vti_bin/webs.asmx?WSML'

ntml = WindowsHttpAuthenticated(username=USER, password=PWD)
client = Client(URL, transport=ntml, timeout=200, cache=None)
#try to get some info
#http://msdn.microsoft.com/en-us/library/webs.webs.getwebcollection%28v=office.12%29.aspx
print client.service.GetWebCollection() #fails with SaxParseException: <unknown>:1:0:syntax error

[1] Cómo acceder de forma remota la base de datos de SharePoint

[2] http://blogs.technet.com/b/hub/archive/2010/11/08/publish-your-access-database-to-sharepoint.aspx

[3] http:// www.developer.com/tech/article.php/3104621/sharepoint-and-web-services.htm

¿Fue útil?

Solución

When you publish an access database to sharepoint, it creates a new web and then creates the various tables in Access as lists under that web. to access that data, you need to change the URL to the web service to include this web. For example, if you published a CUSTOMER database, the URL to access the data would be :

sharepointserver.com/CUSTOMER/_vti_bin/webs.asmx

Otros consejos

Here are some python code examples to access the database, as I would have needed them when asking the question. First, you can use haufe.sharepoint module. There is no support for the module anymore, but it works: https://pypi.python.org/pypi/haufe.sharepoint It uses ntlm for authentification. The code below also demonstrates how to convert the date string to a date:

from haufe.sharepoint import Connector
import datetime
# URL of the database in sharepoint
SP_URL = 'https://mysite.sharepointsite.com/personal/dom_2348890/A_Test' 
SP_USER = r'DOM\2348890'
SP_PWD = 'secret'
""" Identifier for the table inside the sharepoint database.
The Id can be obtained like this:
1. Get to All Site Collections page on the account that uploaded the database 
2. Unfold the published accdb Acess database so that you can see its tables below
3. Move the mouse over a table ; the link displayed at the bottom of the browser looks like this:
javascript:_spNavigateHierarchy(this,'','30:ListNode:3558b4e7-d150-414f-a001-927b27a331dc:f2c42f06-54fe-4242-8fab-54fbod191f9c:e014b7d4-f2b5-4141-adc9-55cf930d557d','\u002fpersonal\u002fdom1_268344\u002fPSA_Test\u002fLists\u002fPSA_Webdatadase',false,'ListNode',%20'')
4. Use the second id to address the table (the first id is useless, as it is just the id of the site)
"""
SP_TABLE_ID = "F2C42F06-54FE-4242-8FAB-54FB0D191F9C"

service = Connector(SP_URL, SP_USER, SP_PWD, SP_TABLE_ID)
for row in service.getItems():
    name = row["A_Name"]
    serial_number = row["A_SNr"]
    date = datetime.datetime.strptime(row["Field1"], "%Y-%m-%d %H:%M:%S") #i.e. 2014-05-01 00:00:00
    print name, serial_number, date

Another way to get the list id, and to access the data of a table, without relying on haufe-sharepoint:

from suds import WebFault
from suds.client import *
from suds.transport.https import WindowsHttpAuthenticated
# URL of the database in sharepoint
SP_URL = 'https://mysite.sharepointsite.com/personal/dom_2348890/A_Test/_vti_bin/Lists.asmx?WSDL'
SP_USER = r'DOM\2348890'
SP_PWD = 'secret'
ntlm=WindowsHttpAuthenticated(username=SP_USER, password=SP_PWD)
client=Client(SP_URL,transport=ntlm, timeout=1000, cache=None)
client.service.GetListCollection() # Get an overview of all tables (lists) on the site, including the specific list ids 
client.service.GetListItems("{F2C4FF06-54FE-4941-8FAB-54FB0D191F9C}") # to get the items of the table with the specified id (with suds you need to include the curly braces)
Licenciado bajo: CC-BY-SA con atribución
scroll top