none
How to create web app by webservice in SharePoint? RRS feed

  • 问题

  • Dear All

           Does anyone know how to create a web app by web service ?

    I have been writed a web service to create web app,and failed.

    the code as follow:

     

    SPSecurtiy .RunWhitElevatePrivileges(delegate()
    {
          SPFarm Current = SPFarm.local;
          SPWebApplication webApplication;
          SPWebApplicationBuilder webBuilder = new  
                       SPWebApplicationBuilder(current);
    
          webBuilder.ID = GUid.newGuid();
          webBuilder.Port = 80;
    
          webBuilder.ApplicationPoolID  =_poolID;
          webBuilder.ApplicationPoolUsername  =_username;
          webBuilder.DefaultZoneUri  =  new Uri(url);
    
          webApplication  = webBuilder.Create();
          webApplication.Provision();
    });
    
    

     

    the error as follow:

     

    System.InvalidOperationException:Operation is not Valid due to the current state of the object.

    Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSpcontrol(HttpContext context) at

    Microsoft.SharePoint.Utilities.SPUtilit.validateFormDigest()at

    Microsoft.SharePoint.Administration.SPPersistedObject.Baseupdate() at

    Microsoft.SharePoint.Administration.SPProcessIdentity.Update()  at

    Microsoft.SharePoint.Administration.SPApplicationPool.Update()  at

    Microsoft.SharePoint.Administration.SPWebapplication.createdefaultInstance(…)  

     

    after,I delete the code :   

    SPSecurtiy .RunWhitElevatePrivileges(delegate()
    

     

    but the another issue appeared:

     

    System.nullReferenceException:Object reference not set to an instance of an object. at

    Microsoft.SharePoint.Utilities.SPUtilit.validateFormDigest()at

    Microsoft.SharePoint.Administration.SPPersistedObject.Baseupdate() at

    Microsoft.SharePoint.Administration.SPProcessIdentity.Update()  at

    Microsoft.SharePoint.Administration.SPApplicationPool.Update()  at

    Microsoft.SharePoint.Administration.SPWebapplication.createdefaultInstance(…)

    I doubt whether that is forbidden by SharePoint  to mangment the farm level contains webapplication and siteCollection.


    • 已编辑 海帝 2011年11月2日 4:42
    2011年11月2日 4:41

答案

  • 1. 楼主写的根本就不是web service代码,而是 server Object Model的代码。

    2. SharePoint不支持用web service才来创建web application.

    3.楼主的英文“I have been writed ”有语法错误,为什么不用中文呢? 

    • 已标记为答案 Wayne Fan 2011年11月11日 11:34
    2011年11月7日 8:12