Salsomaggiore Terme (Programmazione) - 27/10/2012 - Sharepoint WSDL copy.asmx VB.Net
In questi giorni abbiamo dovuto sviluppare una procedura per la copia dei file su SharePoint con il web service copy.asmx.

Come prima cosa abbiamo scaricato il WSDL del web service per poter creare la classe in VB per la gestione delle chiamate che voi potete trovare seguendo il link

WSDL SharePoint copy.asmx
(Il file ha una estensione txt però basta cambiarla in vb per poterla aggiungere in Visual Studio)

oppure sharepoint-wsdl.

Il codice scritto per riuscire ad invocare il metodo CopyIntoItems per la copia è il seguente

Public Function CopyFile(ByVal sSource As String, ByVal sPathDestination As String, ByRef sError As String) As Boolean
Dim bRet As Boolean = False
Dim oCpyResult As New SharePointCopy.CopyResult()
Dim crArrProfile() As SharePointCopy.CopyResult = {oCpyResult}

Dim fiProfile As New SharePointCopy.FieldInformation
Dim fStream As IO.FileStream = Nothing

Try
If sSource = String.Empty Then Throw New Exception("Errore file sorgente")

Dim fSource As New IO.FileInfo(sSource)
fiProfile.DisplayName = fSource.Name
fiProfile.Type = SharePointCopy.FieldType.File
fiProfile.Value = fSource.Name
fiProfile.InternalName = fSource.Name

Dim fiArrProfile() As SharePointCopy.FieldInformation = {fiProfile}

fStream = New IO.FileStream(sSource, IO.FileMode.Open, IO.FileAccess.Read)
Dim bytearrContent(fStream.Length) As Byte
fStream.Read(bytearrContent, 0, Convert.ToInt32(fStream.Length))

If IsNothing(sPathDestination) Then sPathDestination = String.Empty
Dim sFileDestination As String = IO.Path.Combine(sPathDestination, fSource.Name)
Dim arrDestination() As String = {sFileDestination}

Dim Ws As New SharePointCopy.Copy
Ws.Credentials = New NetworkCredential(NomeUtente, Password, Domain)
Ws.Url = Url

Dim intResult As UInteger = Ws.CopyIntoItems(fSource.FullName, arrDestination, fiArrProfile, bytearrContent, crArrProfile)

bRet = True

Catch ex As Exception
sError = ex.Message

Finally
If Not IsNothing(oCpyResult) Then oCpyResult = Nothing
If Not IsNothing(fiProfile) Then fiProfile = Nothing

If Not IsNothing(fStream) Then fStream.Close()
fStream = Nothing

End Try

Return bRet
End Function

Per avere altre informazioni sul Web Service di Share Point copy.asmx potete visualizzare il link Copy Members
Salsomaggiore Terme (Programmazione) - 27/10/2012 - Sharepoint WSDL copy.asmx VB.Net - Written by Mokik
© MrPaloma 2025 - Viaggi - Foto -

Privacy e Cookie

Questo sito utilizza cookie, anche di terze parti, per inviarti pubblicità e servizi in linea con le tue preferenze
Puoi prendere visione dell’informativa estesa sull’uso dei cookie cliccando https://www.garanteprivacy.it/cookie