共用方式為


Dws.CreateDws Method

Creates a Document Workspace site and optionally adds users to the new SharePoint site.

Namespace:  [DWS Web service]
Web service reference: http://Site/_vti_bin/DWS.asmx

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/dws/CreateDws", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/dws/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/dws/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function CreateDws ( _
    name As String, _
    users As String, _
    title As String, _
    documents As String _
) As String
'Usage
Dim instance As Dws
Dim name As String
Dim users As String
Dim title As String
Dim documents As String
Dim returnValue As String

returnValue = instance.CreateDws(name, _
    users, title, documents)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/dws/CreateDws", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/dws/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/dws/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string CreateDws(
    string name,
    string users,
    string title,
    string documents
)

Parameters

  • name
    Type: System.String

    String. The optional URL of the new Document Workspace site. If an empty string is passed, the URL of the new SharePoint site is based on the title, with illegal characters removed or replaced with underscores and with (n) appended if needed to make the URL unique.

  • users
    Type: System.String

    String. An optional list of users to add to the new SharePoint site, in the following format:

    <UserInfo><item Email="{email address of user}" Name="{display name of user}"/>
    </UserInfo>
    
  • title
    Type: System.String

    String. The title of the new Document Workspace site.

  • documents
    Type: System.String

    String. An optional list of documents for Microsoft Windows SharePoint Services to retain for subsequent calls to the FindDwsDoc method. Used by Microsoft Office Outlook when adding shared attachments to a new Document Workspace site. This list is returned in the following format:

    <Documents><item ID="{document ID}" Name="{document name}"/>
    </Documents> 
    

Return Value

Type: System.String
The string that the CreateDws method returns results in the following format when successful.

<Results>
    <Url>{url of the Document Workspace site}</Url>
    <DoclibUrl>{url of the document library in the Document Workspace site}</DoclibUrl>
    <ParentWeb>{title of the Document Workspace site</ParentWeb>
    <FailedUsers>
        <User Email="user_not_added@example.com"/>
        ...
    <FailedUsers>
</Results>

Exceptions

Exception Condition
[HTTPerrorcode401]

The user does not have sufficient rights.

[DWSError.AlreadyExists(13)]

The specified URL already exists.

[DwsError.QuotaExceeded(14)]

This operation exceeds the user's quota.

Remarks

The CreateDws method creates a Document Workspace site and optionally adds users and documents to the new SharePoint site. This method creates a Document Workspace site in the same language as the parent Web site but with unique permissions. The new site does not inherit permissions from the parent site.

When the user does not have sufficient rights, the HTTP error response raises an exception.

Examples

The following code example uses the CreateDws method to create a Document Workspace site and add a new user to the SharePoint site. For more information about the full text of the helper functions used in this example, see the CanCreateDwsUrl method.

Try
    Dim strResult As String
    Dim strNewUser As String = "<UserInfo>" & _
        "<item Email='someone@example.com' Name='Someone'/>" & _
        "</UserInfo>"
    strResult = dwsWebService.CreateDws _
        ("site_name", strNewUser, "site_title", "")
    If IsDwsErrorResult(strResult) Then
        Dim intErrorID As Integer
        Dim strErrorMsg As String
        Call ParseDwsErrorResult(strResult, intErrorID, strErrorMsg)
        MessageBox.Show _
            ("A document workspace error occurred." & vbCrLf & _
            "Error number: " & intErrorID.ToString & vbCrLf & _
            "Error description:" & strErrorMsg, _
            "DWS Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        MessageBox.Show _
            ("The document workspace was successfully created.", _
            "Create DWS", MessageBoxButtons.OK, _
            MessageBoxIcon.Information)
    End If
Catch exc As Exception
    MessageBox.Show("An exception occurred." & vbCrLf & _
        "Description: " & exc.Message, _
        "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
try
{
    string strResult = "";
    string strNewUser = "<UserInfo>" +
        "<item Email='someone@example.com' Name='Someone'/>" + 
            "</UserInfo>";
    strResult = dwsWebService.CreateDws
            ("site_name", strNewUser, "site_title", "");
    if (IsDwsErrorResult(strResult))
    {
        int intErrorID  = 0;
        string strErrorMsg = "";
        ParseDwsErrorResult(strResult, out intErrorID, 
            out strErrorMsg);
        MessageBox.Show
            ("A document workspace error occurred.\r\n" +
            "Error number: " + intErrorID.ToString() + "\r\n" +
            "Error description: " + strErrorMsg,
            "DWS Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    else
    {
        MessageBox.Show
            ("The document workspace was successfully created.",
            "Create DWS", MessageBoxButtons.OK,
            MessageBoxIcon.Information);
    }
}
catch (Exception exc)
{
    MessageBox.Show("An exception occurred.\r\n" +
        "Description: " + exc.Message,
        "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

See Also

Reference

Dws Class

Dws Members

DWS Web Service