Sharepoint WSDL copy.asmx VB.Net

Tempo di lettura: min.
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
Esplora MrPaloma con la nostra chat IA!. Domanda cosa vuoi trovare per cercare rapidamente.

Link referral

Aiuta MrPaloma.com a crescere, utilizza uno dei seguenti link per iscriverti a qualche sito così che noi possiamo ricevere un omaggio.
Amazon Sostieni MrPaloma facendo acquisti su Amazon partendo da questo link amazon.it.
Plutus Ricevi uno sconto del 100% in PLU su tutti i vantaggi basati su abbonamento. plutus.it.

Ricordiamo che in qualità di Affiliato Amazon riceviamo un guadagno dagli acquisti idonei.

Articoli precedenti

© MrPaloma 2024 - Viaggi - Foto - Forum -
Termini di servizio - Privacy