I have a Silverlight Application, that uploads file(s) to a Sharepoint Site. I got it working for a Sharepoint site in my box and in a Sharepoint site in someone else’s box, where I login using my Windows account to that site. But I am not able to upload files into Sharepoint sites which are in a different domain / use a different login.
For uploading files into sites which do not use my account. I use this to get the credentials and to change the endpoints
CopySoapClient copy = new CopySoapClient();
copy.ClientCredentials.UserName.UserName = obj.UserName;
copy.ClientCredentials.UserName.Password = obj.Password;
copy.Endpoint.Address = new System.ServiceModel.EndpointAddress(newMaster.Url + "/_vti_bin/Copy.asmx");
copy.Endpoint.Contract.Name = "CopyReference.CopySoap";
copy.Endpoint.Binding.Name = "basicHttpBinding";
copy.Endpoint.Contract.ConfigurationName = "CopySoap";
where obj.UserName has the DomainName too.. For eg. Domain\UserName.
Here is a snippet of code that I have used in the past to upload a document to a SharePoint document library using the SharePoint web services SDK.
FYI – This
Copyproxy was generated using the old school Add Web Reference instead of the newer Add Service Reference. I find it easier to use the old school proxies when working with the old ASMX SharePoint web services.and if you need to dynamically change the endpoint url you can use the following before invoking the
CopyIntoItems()method.