Tuesday 8 November 2011

Clarity and Sharepoint Integration - Create Site

I have been getting questions on how to create sites in SharePoint using Clarity. Here is a step-by-step explanation.

1. Create a process and create a step with a custom script action.

2. In the GEL script, first check to make sure the site doesn't exist

<core:catch var="soapError">
    <s:invoke endpoint="${Endpoint}" soapAction="http://schemas.microsoft.com/sharepoint/soap/GetWeb" var="Result">
            <s:message>
                    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sp="http://schemas.microsoft.com/sharepoint/soap/">
                            <soap:Header/>
                                <soap:Body>
                                    <sp:GetWeb>
                                        <sp:webUrl>${parent_url}</sp:webUrl>
                                    </sp:GetWeb>
                                </soap:Body>
                        </soap:Envelope>
                </s:message>
    </s:invoke>
</core:catch>

where ${Endpoint} would be "${parent_url}/_vti_bin/Webs.asmx"
and ${parent_url} would be the URL you are trying to test if exists

3. Check the result of the above soap call

<core:catch var="selectFaultError">
    <gel:set asString="true" select="$Result//sp:GetWebResult" var="Exists"/>
</core:catch>

4. Based on the result, create the site if needed:

<core:choose>
    <core:when test="${Exists == NULL}">
            <core:catch var="soapError">
                    <s:invoke endpoint="${addSiteEndpoint}" soapAction="http://microsoft.com/webservices/CreateWebs" var="AddResult">
                            <s:message>
                                    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                          <soap:Body>
                                <CreateWebs xmlns="http://microsoft.com/webservices/">
                                      <parentUrl>string</parentUrl>
                                      <siteName>string</siteName>
                                      <siteTitle>string</siteTitle>
                                      <siteDescription>string</siteDescription>
                                      <nLCID>unsignedInt</nLCID>
                                      <webTemplate>string</webTemplate>
                                      <ownerLogin>string</ownerLogin>
                                      <useUniquePermissions>boolean</useUniquePermissions>
                                      <bConvertIfThere>boolean</bConvertIfThere>
                                </CreateWebs>
  </soap:Body>
</soap:Envelope>

                </s:message>
            </s:invoke>
        </core:catch>
    </core:when>
</core:choose>

where ${addSiteEndpoint} would be in the form "<SP Entry URL>/SiteManagement/<Admin page>.asmx"

Parameters:
•    parentUrl -: Url of the parent site under which we wish to create a new site
•    siteName -: name of the site which will be the URL of the site
•    siteTitle -: title of the new site
•    siteDescription: description on new site
•    nLCID -: local id of the site (unsigned integer value)
•    webTemplate -: template for the new site
•    ownerLogin -: owner for the new site (should have rights to create sites under the parent)
•    useUniquePermissions -: boolean value whether to keep unique permissions for the new site
•    bConvertIfThere -: boolean value whether to covert the site if already exists



Now, the above is based on our configuration. What I would suggest is to use soapUI, start a new project and in the initial WSDL, provide the following URL "<Sharepoint Entry URL/SiteManagement/<admin page>.asmx?WSDL"

The program may ask you for login parameters - provide the user details who has full rights to create site in Share Point

Once the WSDL is imported into SoapUI, right click on "CreateWebs" and choose "New Request", give a name and the program would show you a sample SOAP call that you could embed in your GEL script (replacing the soap call above with the one you get from SOAPui).

No comments:

Post a Comment