views:

26

answers:

1

I'm trying to call the AddAttachment of the Lists.asmx SharePoint web service the below code works fine if I'm calling the web service over HTTP.

        Dim img(MyFile.PostedFile.ContentLength - 1) As Byte
        MyFile.PostedFile.InputStream.Read(img, 0, img.Length)

        'Dim fStream As FileStream = File.OpenRead(FullFileName)
        Dim fileName As String = MyFile.PostedFile.FileName.Substring(3)

        Dim listService As New wsList.Lists()
        Dim credentials As New System.Net.NetworkCredential(UserName, Password, Domain)

        If Not SiteUrl.EndsWith("/") Then
            SiteUrl += "/"
        End If
        SiteUrl += "_vti_bin/Lists.asmx"
        'SiteUrl = SiteUrl.ToLower.Replace("http:", "https:")

        listService.Url = SiteUrl
        listService.Credentials = credentials

        Dim addAttach As String = listService.AddAttachment(ListName, ItemId, fileName, img)

        ReturnValue = True

However if I uncomment out this line

'SiteUrl = SiteUrl.ToLower.Replace("http:", "https:")

I will get the following error: The request failed with HTTP status 401: Unauthorized

Now if I leave the above line commented out AND then also comment out this line

listService.Credentials = credentials

I will get the same 401 error (expected) so it appears the credentials are being accepted correctly over HTTP but not HTTPS. Can one help explain this to me and have any thoughts on how to fix the issue?

Thanks in advance!

A: 

This morning I was working with one of our system guys. He checked some IIS logs and could see errors trying to access the web service over HTTPS. He went into Central Admin and added some Alternate Access Mappings to include the HTTPS urls. Then everything worked!

Greg