MartyConnelly
martyconnelly at shaw.ca
Wed Mar 2 21:51:38 CST 2005
Another little oddity about using Access Web Services to Sharepoint is some services screw up over authentication. If the user has not been authenticated, a Maximum retry on connection exceeded error occurs. In Visual Basic .NET or C# .NET, you authenticate the user from code by creating a Credentials object for the user. wsAdapter.Credentials = System.Net.CredentialCache.DefaultCredentials However it is not easy to do in Access 2003 with say GetListCollection of sharepoint http://username.sharepointsite.com/_vti_bin/Lists.asmx?op=GetListCollection So if you create a web service class via the wizard to getlist collection it doesn't authenticate properly with code like this testws. But if you pre run any straight forward soap xmlhttp call to the site it then works okay and the access program has established authentication as shown in the click sub below Sub testws() ' Class created by Access WS toolkit to connect to the Web service Dim ws As New clsws_Lists ' The collection is returned as an XML node list Dim lc As MSXML2.IXMLDOMNodeList 'Root node of the returned list Dim nod As MSXML2.IXMLDOMNode ' Document to hold an XSLT transform Dim docXSLT As New MSXML2.DOMDocument50 ' Output string for the XML transformation Dim strOutput As String ' Retrieve the collection of lists Set lc = ws.wsm_GetListCollection ' Create the XSLT to select the desired information docXSLT.LoadXml ("<?xml version=""1.0"" encoding=""utf-8""?> <xsl:stylesheet" & _ " xmlns:xsl=""http://www.w3.org/1999/XSL/Transform""" & _ " xmlns:wss=""http://schemas.microsoft.com/sharepoint/soap/""" & _ " version=""1.0""><xsl:output method=""text"" />" & _ "<xsl:template match=""wss:List"">" & _ "<xsl:value-of select=""@Title""/>," & _ "<xsl:value-of select=""@Description""/>," & _ "<xsl:value-of select=""@ID""/><xsl:text>
</xsl:text></xsl:template></xsl:stylesheet>") ' Get the root node from the list Set nod = lc.Item(0) ' Apply the XSLT transform strOutput = (nod.transformNode(docXSLT)) Debug.Print strOutput End Sub Sub Click() On Error GoTo Err_Command8_Click Dim URL As String Dim http As New MSXML2.XMLHTTP Dim objResult As New MSXML2.DOMDocument Dim objStyle As New MSXML2.DOMDocument Dim strEnvelopeBegin As String Dim strEnvelopeEnd As String Dim xmlReq As String Dim s As String Dim strReturned As String Dim strQuery As String s = "<?xml version=""1.0""?>" & vbCrLf URL = "http://mconnelly.sharepointsite.com/_vti_bin/Lists.asmx" strEnvelopeBegin = "<soap:Envelope " & vbCrLf & _ " xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""" & vbCrLf & _ " xmlns:xsd=""http://www.w3.org/2001/XMLSchema""" & vbCrLf & _ " xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""> " & vbCrLf & _ " <soap:Body> <GetListCollection xmlns=""http://schemas.microsoft.com/sharepoint/soap/"" />" strEnvelopeEnd = vbCrLf & " </soap:Body> </soap:Envelope>" xmlReq = s & strEnvelopeBegin & strEnvelopeEnd Debug.Print xmlReq ' Me!Text0 = xmlReq ' Me!Text2 = URL http.Open "POST", URL, False 'http.setRequestHeader "Accept", "text/xml" http.setRequestHeader "Content-Type", "text/xml" ' http.setRequestHeader "Cache-Control", "no-cache" http.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListCollection" ' http.setRequestHeader "SOAPMethodName", "GetListCollection" http.send xmlReq Debug.Print http.responseText; Len(http.responseText) Debug.Print http.Status; http.statusText WriteFile "C:\Access files\sharepoint\" & "test" & _ Format(Now, "yyyymmddhhmmss") & ".xml", http.responseText Debug.Print http.responseBody; Len(http.responseBody) Set http = Nothing Exit_Command8_Click: Exit Sub Err_Command8_Click: MsgBox Err.Description Resume Exit_Command8_Click End Sub Public Sub WriteFile(ByVal sFileName As String, ByVal sContents As String) ' Dump XML String to File for debugging Dim fhFile As Integer fhFile = FreeFile ' Debug.Print "Length of string=" & Len(sContents) Open sFileName For Output As #fhFile Print #fhFile, sContents; Close #fhFile Debug.Print "Out File" & sFileName End Sub MartyConnelly wrote: > One thing I found out that isn't clear in Sharepoint, is that you have > to assign web designer or contributor rights to a user > even if user is the administrator in order to upload an Access Table. > Now I just have to figure out how to link pictures on the site into > the list (table). > Maybe I have to do this with xml web services. > > Sub WWSupload() > On Error GoTo errout > DoCmd.TransferDatabase transfertype:=acExport, databasetype:="WSS", _ > databasename:="http://username.sharepointsite.com", _ > objecttype:=acTable, Source:="Household Inventory", _ > Destination:="Household Inventory", structureonly:=False > errout: > Debug.Print Err.Number & "-" & Err.Description > End Sub > > Martin Reid wrote: > >> >> Jim >> >> heres another article >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/pjsdk/html/pjsdkWebpInstallAndWSS_HV01100336.asp >> >> >> >> Martin >> >> On Mar 1 2005, Jim DeMarco wrote: >> >>> Are we able to create and use custom web parts if we are only using >>> Sharepoint Services (not Portal Server)? >>> >>> Jim DeMarco >>> >>> -----Original Message----- >>> From: accessd-bounces at databaseadvisors.com >>> [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Martin Reid >>> Sent: Tuesday, March 01, 2005 10:02 AM >>> To: Access Developers discussion and problem solving >>> Subject: RE: [AccessD] Re: [dba-Tech] Overview of Sharepoint Server >>> >>> >>> LOL >>> >>> I have been discussing some stuff of list. >>> But in general SP also contains its own security systemn with lists >>> etc. I am doing two major reviews for a publisher on Sharepoint. I >>> also did a section on FrontPage 203 for Microsoft and I know there >>> are a few articles up on MSDN. Have a look for FrontPage 2003 and >>> Sharepoint. Paul Litwin wrote an article at the same time as me for >>> them which dealt with Web Parts/XML and Access. >>> >>> Its really a trinity of Products - FrontPage 2003 (or .NET) >>> Sharepoint services and SharePoint Portal Server. The Portal Server >>> provides great indexing and searching capability for Sharepoint >>> Services. But the main development tool is Web parts. Web parts >>> provide descrite functionality for example a set of data from SQL >>> Server, DB2 etc. ALso provides a single sign on cabability for >>> multiple systems. >>> >>> Martin >>> >>> >>> >>> On Mar 1 2005, Susan Harkins wrote: >>> >>> > I think Martin's writing a book on SharePoint -- you might ring >>> his > chimes. >>> > > Susan H. > > Marty, >>> > > Under the paragraph Using Sharepoint Lists, Mike states that > >>> Sharepoint > uses an optimistic record locking scheme. This would >>> let > me use an Access database as read-write for one location and >>> read-only > for any others. >>> > > Still, that could be useful in some situations. >>> > > Dan Waters >>> > ProMation Systems >>> > > >>> >> > -- Marty Connelly Victoria, B.C. Canada