/// <remarks/>
 public void editAsync(authentication authentication, asset asset)
 {
     this.editAsync(authentication, asset, null);
 }
 /// <remarks/>
 public void editAsync(authentication authentication, asset asset, object userState)
 {
     if ((this.editOperationCompleted == null))
     {
         this.editOperationCompleted = new System.Threading.SendOrPostCallback(this.OneditOperationCompleted);
     }
     this.InvokeAsync("edit", new object[] {
                 authentication,
                 asset}, this.editOperationCompleted, userState);
 }
 public operationResult edit(authentication authentication, asset asset)
 {
     object[] results = this.Invoke("edit", new object[] {
                 authentication,
                 asset});
     return ((operationResult)(results[0]));
 }
 /// <remarks/>
 public void createAsync(authentication authentication, asset asset)
 {
     this.createAsync(authentication, asset, null);
 }
 public createResult create(authentication authentication, asset asset)
 {
     object[] results = this.Invoke("create", new object[] {
                 authentication,
                 asset});
     return ((createResult)(results[0]));
 }
        protected void Page_Load(object sender, EventArgs e)
        {   
            System.Web.UI.WebControls.Label label = new Label();
            
            // enclosing in try/catch for easier debugging, primarily
            try
            {
                // get a handle to the asset operation service
                proxy = new AssetOperationHandlerService();

                // contruct a path object referencing the 'about' page from the example.com site
                // note:  change this path to a page that actually exists in your cms instance, if necessary
                pagePath = new path();
                // set the relative path (from the Base Folder) to the asset
                pagePath.path1 = "/about";
                // set the site name of the path object (note: set siteName to 'Global' if the asset is not in a Site)
                pagePath.siteName = "example.com";
               
                // contruct asset identifier used for read() operation
                id = new identifier();
                // set the asset type
                id.type = entityTypeString.page;
                // set asset path (may use either path or id, but never both)
                id.path = pagePath;

                // contruct authentication element to be used in all operations
                auth = new authentication();
                // change username / password as necessary
                auth.username = "******";
                auth.password = "******";

                // attempt to read the asset
                result = proxy.read(auth, id);

                // print asset contents to page label
                label.Text = CascadeWSUtils.printAssetContents(result.asset);

                // edit the asset
                // create an empty asset for use with edit() operation
                // (note: this is assuming the authentication user has bypass workflow abilities --
                // if not, you will also need to supply workflowConfig information)
                asset editAsset = new asset();
                editAsset.page = result.asset.page;
                // add some content to the exiting page xhtml
                editAsset.page.xhtml += "<h1>Added via .NET</h1>";
                // must call this method to avoid sending both id and path values in 
                // component references in the asset -- will generate SOAP errors otherwise
                CascadeWSUtils.nullPageValues(editAsset.page);

                // attempt to edit
                operationResult editResult = proxy.edit(auth, editAsset);
                // check results
                label.Text += "<br/><br/>edit success? " + editResult.success + "<br/>message = " + editResult.message;


                // create new asset (using read asset as a model)
                asset newAsset = new asset();
                page newPage = result.asset.page;

                // must call this method to avoid sending both id and path values in 
                // component references in the asset -- will generate SOAP errors otherwise
                CascadeWSUtils.nullPageValues(newPage);

                // since this will be a new asset, change its name
                newPage.name = "new-page-created-via-dot-net";
                // remove id from read asset
                newPage.id = null;
                // remove other system properties brought over from read asset
                newPage.lastModifiedBy = null;
                newPage.lastModifiedDate = null;
                newPage.lastModifiedDateSpecified = false;
                newPage.lastPublishedBy = null;
                newPage.lastPublishedDate = null;
                newPage.lastPublishedDateSpecified = false;
                newPage.pageConfigurations = null;

                newAsset.page = newPage;

                // attempt to create
                createResult createResults = proxy.create(auth, newAsset);
                
                // check create results
                label.Text = label.Text + "<br/><br/>create success? " + createResults.success + "<br/>message = " + createResults.message;

                // debugging -- writes the serialzed XML of the asset element sent in create request to a file
                /*
                // Serializing the returned object
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(newAsset.GetType());

                System.IO.MemoryStream ms = new System.IO.MemoryStream();

                x.Serialize(ms, newAsset);

                ms.Position = 0;

                // Outputting to client

                byte[] byteArray = ms.ToArray();

                Response.Clear();
                Response.AddHeader("Content-Disposition", "attachment; filename=results.xml");

                Response.AddHeader("Content-Length", byteArray.Length.ToString());

                Response.ContentType = "text/xml";

                Response.BinaryWrite(byteArray);
                Response.End();
                 * */
            }
            catch (Exception booboo) { label.Text = "Exception thrown:<br>" + booboo.GetBaseException() + "<br/><br/>STACK TRACE:<br/>" + booboo.StackTrace; }

            WSContent.Controls.Add(label);
        }
        // ----------------------------------------------------------------------------------------------------------------
        // debugging utilities:

        /*
         * Returns an XHTML string containing a listing of the provided asset's structure.
         * For use in debugging.
         * (Only implemented for page assets at the moment)
         */
        public static string printAssetContents(asset a)
        {
            string contents = "<ul>";

            contents += "<li>WorkflowConfiguration:" + printWorkflowConfiguration(a.workflowConfiguration) + "</li>";

            if (a.page != null)
            {
                contents += "<li>Page:</li><ul>";
                page p = a.page;
                contents += "<li>name = " + p.name + "</li>";
                contents += "<li>id = " + p.id + "</li>";
                contents += "<li>configurationSetId = " + p.configurationSetId + "</li>";
                contents += "<li>configurationSetPath = " + p.configurationSetPath + "</li>";
                contents += "<li>contentTypeId = " + p.contentTypeId + "</li>";
                contents += "<li>contentTypePath = " + p.contentTypePath + "</li>";
                contents += "<li>entityType = " + p.entityType + "</li>";
                contents += "<li>expirationFolderId = " + p.expirationFolderId + "</li>";
                contents += "<li>expirationFolderPath = " + p.expirationFolderPath + "</li>";
                contents += "<li>expirationFolderRecycled = " + p.expirationFolderRecycled + "</li>";
                contents += "<li>expirationFolderRecycledSpecified = " + p.expirationFolderRecycledSpecified + "</li>";
                contents += "<li>lastModifiedBy = " + p.lastModifiedBy + "</li>";
                contents += "<li>lastModifiedDate = " + p.lastModifiedDate + "</li>";
                contents += "<li>lastModifiedDateSpecified = " + p.lastModifiedDateSpecified + "</li>";
                contents += "<li>lastPublishedBy = " + p.lastPublishedBy + "</li>";
                contents += "<li>lastPublishedDate = " + p.lastPublishedDate + "</li>";
                contents += "<li>lastPublishedDateSpecified = " + p.lastPublishedDateSpecified + "</li>";
                contents += "<li>metadata = " + printMetadata(p.metadata) + "</li>";
                contents += "<li>metadataSetId = " + p.metadataSetId + "</li>";
                contents += "<li>metadataSetPath = " + p.metadataSetPath + "</li>";
                contents += "<li>pageConfigurations = " + printPageConfigurations(p.pageConfigurations) + "</li>";
                contents += "<li>parentFolderId = " + p.parentFolderId + "</li>";
                contents += "<li>parentFolderpath = " + p.parentFolderPath + "</li>";
                contents += "<li>path = " + p.path + "</li>";
                contents += "<li>shouldBeIndexed = " + p.shouldBeIndexed + "</li>";
                contents += "<li>shouldBeIndexedSpecified = " + p.shouldBeIndexedSpecified + "</li>";
                contents += "<li>shouldBePublished = " + p.shouldBePublished + "</li>";
                contents += "<li>shouldBePublishedSpecified = " + p.shouldBePublishedSpecified + "</li>";
                contents += "<li>siteId = " + p.siteId + "</li>";
                contents += "<li>siteName = " + p.siteName + "</li>";
                contents += "<li>structuredData = " + printStructuredData(p.structuredData) + "</li>";
                contents += "<li>xhtml = " + p.xhtml + "</li>";
                

                contents += "</ul>";
            }
            else if (a.file != null)
            {
                contents += printFileData(a.file);
            }

            contents += "</ul>";

            return contents;
        }