How to Create Site using Sharepoint web services?

Posted by Pari on Stack Overflow See other posts from Stack Overflow or by Pari
Published on 2010-01-29T14:34:34Z Indexed on 2010/03/22 8:01 UTC
Read the original article Hit count: 563

Filed under:
|

Hi All,

I am tring to create site on sharepoint programatically using Sharepoint Web Services.(C#).

I tried Admin.asmx service (CreateSite method).

But it's showing error:

"An unhandled exception of type 'System.InvalidOperationException' occurred in System.Web.Services.dll".

I tried with all possible parameters. Curremtly referring Below Links:

  1. http://www.oliebol.org/blog/Lists/Posts/Post.aspx?ID=6
  2. http://msdn.microsoft.com/en-us/library/administration.admin.createsite.aspx

My Code:

Admin admService             = new Admin();
admService.Credentials       = new NetworkCredential(username,password,domain);
admService.Url               = "http://mychserver/_vti_adm/admin.asmx";
admService.PreAuthenticate   = true;
try
{
  String SitePath   = "http://myserver/SiteDirectory/SharepointSampleSite";
  admService.CreateSite(SitePath,"First Site", "Sample Site", 1033, "STS#0",
                       "Domain\\username",username,userid, "", "");
}
catch (System.Web.Services.Protocols.SoapException ex)
{
 MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" +ex.Detail.InnerText +
                 "\nStackTrace:\n" + ex.StackTrace);
}

Thanx,

© Stack Overflow or respective owner

Related posts about sharepoint2007

Related posts about c#