Dws.CanCreateDwsUrl method

Determines whether the user has sufficient rights to create a Document Workspace site with the proposed URL on the server.

Namespace:  WebSvcDWS
Assembly:  STSSOAP (in STSSOAP.dll)

Syntax

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

returnValue = instance.CanCreateDwsUrl(url)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/dws/CanCreateDwsUrl", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/dws/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/dws/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string CanCreateDwsUrl(
    string url
)

Parameters

  • url
    Type: System.String

    String. The proposed URL for the new Document Workspace site.

Return value

Type: System.String
A string that returns the URL in the format <Result>{proposed URL}</Result> when successful.

Note

The URL may be modified as described in Remarks.

Exceptions

Exception Condition
[HTTPerrorcode401]

The user does not have sufficient rights.

Remarks

The CanCreateDwsUrl method determines whether the user has sufficient rights to create a Document Workspace site with the proposed URL on the server. This method returns the suggested URL after replacing illegal characters, shortening the the proposed URL as necessary, and appending a numeric index if needed to make the URL unique. For example, if the proposed URL My_New_Site already exists, the CanCreateDwsUrl method returns My_New_Site(1).

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

Examples

The following code example displays the suggested URL for the new Document Workspace site as returned by the CanCreateDwsUrl method.

Try
    Dim strResult As String
    strResult = dwsWebService.CanCreateDwsUrl("site_name")
    Console.WriteLine("Result of CanCreate operation: {0}", strResult)
    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
        Dim strSuggestedUrl As String
        strSuggestedUrl = ParseDwsSingleResult(strResult)
        MessageBox.Show("User has permission to create: " & _
            vbCrLf & strSuggestedUrl, _
            "CanCreateDwsUrl", 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 = "";
    strResult = dwsWebService.CanCreateDwsUrl("site_name");
    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
    {
        string strSuggestedUrl = ParseDwsSingleResult(strResult);
        MessageBox.Show
            ("User has permission to create: \r\n" +
            strSuggestedUrl,
            "Create DWS", MessageBoxButtons.OK,
            MessageBoxIcon.Information);
    }
}
catch (Exception exc)
{
    MessageBox.Show("An exception occurred.\r\n" +
        "Description: " + exc.Message,
        "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

The following sample helper functions are used in the code samples provided for each method of the Document Workspace service.

    Private Function IsDwsErrorResult(ByVal ResultFragment As String) 
        As Boolean
        Dim srResult As System.IO.StringReader = 
            New System.IO.StringReader(ResultFragment)
        Dim xtr As System.Xml.XmlTextReader = 
            New System.Xml.XmlTextReader(srResult)
        xtr.Read()
        If xtr.Name = "Error" Then
            Return True
        Else
            Return False
        End If
    End Function

    Private Sub ParseDwsErrorResult(ByVal ErrorFragment As String, 
        ByRef ErrorID As Integer, ByRef ErrorMsg As String)
        Dim srError As System.IO.StringReader = 
            New System.IO.StringReader(ErrorFragment)
        Dim xtr As System.Xml.XmlTextReader = 
            New System.Xml.XmlTextReader(srError)
        xtr.Read()
        xtr.MoveToAttribute("ID")
        xtr.ReadAttributeValue()
        ErrorID = xtr.Value
        ErrorMsg = xtr.ReadString()
    End Sub

    Private Function ParseDwsSingleResult(ByVal ResultFragment 
        As String) As String
        Dim srResult As System.IO.StringReader = 
            New System.IO.StringReader(ResultFragment)
        Dim xtr As System.Xml.XmlTextReader = 
            New System.Xml.XmlTextReader(srResult)
        xtr.Read()
        Return xtr.ReadString()
    End Function
private bool IsDwsErrorResult(string ResultFragment)
{
    System.IO.StringReader srResult = 
        new System.IO.StringReader(ResultFragment);
    System.Xml.XmlTextReader xtr = 
        new System.Xml.XmlTextReader(srResult);
    xtr.Read();
    if (xtr.Name == "Error")
    {
        return true;
    }
    else
    {
        return false;
    }
}

private void ParseDwsErrorResult(string ErrorFragment, out int ErrorID, 
    out string ErrorMsg)
{
    System.IO.StringReader srError = 
        new System.IO.StringReader(ErrorFragment);
    System.Xml.XmlTextReader xtr = 
        new System.Xml.XmlTextReader(srError);
    xtr.Read();
    xtr.MoveToAttribute("ID");
    xtr.ReadAttributeValue();
    ErrorID = System.Convert.ToInt32(xtr.Value);
    ErrorMsg = xtr.ReadString();
}

private string ParseDwsSingleResult(string ResultFragment)
{
    System.IO.StringReader srResult = 
        new System.IO.StringReader(ResultFragment);
    System.Xml.XmlTextReader xtr = 
        new System.Xml.XmlTextReader(srResult);
    xtr.Read();
    return xtr.ReadString();            
}

See also

Reference

Dws class

Dws members

WebSvcDWS namespace