AtomPubClient AtomPubClient AtomPubClient AtomPubClient Class

Encapsulates the methods needed to implement the AtomPub protocol which enables HTTP CRUD access to Web resources using the Atom 1.0 wire format.

Syntax

Declaration

public sealed class AtomPubClientpublic sealed class AtomPubClientPublic NotInheritable Class AtomPubClient

Remarks

For examples of how these class methods are implemented to create, retrieve, update, or delete syndicated content, see Quickstart: Managing Feed Entries.

Constructors summary

Creates a new AtomPubClient object.

Creates a new AtomPubClient object with the credential to use when making requests to the server. Initially, a 'username/password' tuple. However, for domain credentials, the username must be in 'domain\user form'.

Properties summary

Gets or sets a Boolean value that specifies whether to bypass the cache when retrieving the feed.

Gets or sets the maximum number of bytes to buffer when receiving a response from a server.

Gets or sets the credentials to use when making requests via a proxy.

Gets or sets the credentials to use when making requests to the server.

Gets or sets the maximum amount of time, in milliseconds, to wait for any of the asynchronous operations to complete. If the operation is not complete within this amount of time, it will fail with a status code indicating that it timed out.

Methods summary

Cancels any in-progress asynchronous operations, causing them to fail (asynchronously) with an error code indicating cancellation.

Creates a new media resource in the specified collection.

Creates a new Entry resource in the specified collection. The Uri of the collection in which to create the new resource can be discovered from the ResourceCollection object retrieved from the RetrieveResourceAsync(Windows.Foundation.Uri) method.

Deletes an existing Entry or Media Link resource.

Deletes an existing Entry or Media Link resource. This differs from the DeleteResourceAsync(Windows.Foundation.Uri) method in that the SyndicationItem object that represents the resource to be deleted is specified instead of the Uri. The DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem) method uses the property of the specified SyndicationItem as the Uri of the resource to be deleted.

Starts an asynchronous operation to download the syndication feed from the given URI. This method instantiates a SyndicationFeed object from the feed string, which can be in one of the formats specified in SyndicationFormat.

Retrieves a media link resource from the specified Uniform Resource Identifier (URI).

Retrieves an Entry resource or Media Link resource from the specified Uniform Resource Identifier (URI).

Retrieves a service document from the specified Uri.

Sets an HTTP header for the request. This method can be called multiple times to set multiple headers. When the same header is set multiple times, the values will be concatenated and separated by ",".

Updates a media link resource from the specified Uniform Resource Identifier (URI).

Updates an existing Entry or Media Link resource. If an ETag: header has previously been seen while retrieving this resource (in a response to RetrieveResourceAsync(Windows.Foundation.Uri), CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem) or a previous call to UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem) ), this method automatically sends an If-Match: header with the remembered value.

Updates an existing Entry or Media Link resource. This differs from the UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem) method in that the EditUri property of the specified SyndicationItem object is used as the Uri of the resource to be updated.

Constructors

  • AtomPubClient()
    AtomPubClient()
    AtomPubClient()
    AtomPubClient()

    Creates a new AtomPubClient object.

    public AtomPubClient()public AtomPubClient()Public Function AtomPubClient() As
  • AtomPubClient(Windows.Security.Credentials.PasswordCredential)
    AtomPubClient(Windows.Security.Credentials.PasswordCredential)
    AtomPubClient(Windows.Security.Credentials.PasswordCredential)
    AtomPubClient(Windows.Security.Credentials.PasswordCredential)

    Creates a new AtomPubClient object with the credential to use when making requests to the server. Initially, a 'username/password' tuple. However, for domain credentials, the username must be in 'domain\user form'.

    public AtomPubClient(Windows.Security.Credentials.PasswordCredential)public AtomPubClient(Windows.Security.Credentials.PasswordCredential)Public Function AtomPubClient(Windows.Security.Credentials.PasswordCredential) As

    Parameters

Properties

  • BypassCacheOnRetrieve
    BypassCacheOnRetrieve
    BypassCacheOnRetrieve
    BypassCacheOnRetrieve

    Gets or sets a Boolean value that specifies whether to bypass the cache when retrieving the feed.

    public bool BypassCacheOnRetrieve { get; set; }public bool BypassCacheOnRetrieve { get; set; }Public ReadWrite Property BypassCacheOnRetrieve As bool

    Property Value

    • bool
      bool
      bool
      bool

      TRUE if the cache should be bypassed; otherwise FALSE.

  • MaxResponseBufferSize
    MaxResponseBufferSize
    MaxResponseBufferSize
    MaxResponseBufferSize

    Gets or sets the maximum number of bytes to buffer when receiving a response from a server.

    public uint MaxResponseBufferSize { get; set; }public uint MaxResponseBufferSize { get; set; }Public ReadWrite Property MaxResponseBufferSize As uint

    Property Value

    • uint
      uint
      uint
      uint

      Maximum size and default is UInt32.MaxValue.

    Remarks

    Applications can protect themselves against a malicious server which sends an excessively large response body to DoS the client by setting the property to a smaller number.

    If the response from the server contains a Content-Length header with a value greater than the value of this property, the request will be aborted immediately and the operation will immediately fail with an error indicating that the response body was too large. If no Content-Length header is present in the response, the response body will be buffered up to the point of this value. As soon as the response body grows to be larger than this value, the request will be aborted, the buffered response data will be released, and the operation will immediately fail with an error indicating that the response body was too large.

  • ProxyCredential
    ProxyCredential
    ProxyCredential
    ProxyCredential

    Gets or sets the credentials to use when making requests via a proxy.

    public PasswordCredential ProxyCredential { get; set; }public PasswordCredential ProxyCredential { get; set; }Public ReadWrite Property ProxyCredential As PasswordCredential

    Property Value

  • ServerCredential
    ServerCredential
    ServerCredential
    ServerCredential

    Gets or sets the credentials to use when making requests to the server.

    public PasswordCredential ServerCredential { get; set; }public PasswordCredential ServerCredential { get; set; }Public ReadWrite Property ServerCredential As PasswordCredential

    Property Value

  • Timeout
    Timeout
    Timeout
    Timeout

    Gets or sets the maximum amount of time, in milliseconds, to wait for any of the asynchronous operations to complete. If the operation is not complete within this amount of time, it will fail with a status code indicating that it timed out.

    public uint Timeout { get; set; }public uint Timeout { get; set; }Public ReadWrite Property Timeout As uint

    Property Value

    • uint
      uint
      uint
      uint

      Default value is 30000 (30 seconds). A value of UInt32.MaxValue indicates that the syndication client will wait indefinitely for a response.

Methods

  • CancelAsyncOperations()
    CancelAsyncOperations()
    CancelAsyncOperations()
    CancelAsyncOperations()

    Cancels any in-progress asynchronous operations, causing them to fail (asynchronously) with an error code indicating cancellation.

    public void CancelAsyncOperations()public void CancelAsyncOperations()Public Function CancelAsyncOperations() As void
  • CreateMediaResourceAsync(Windows.Foundation.Uri,System.String,System.String,Windows.Storage.Streams.IInputStream)
    CreateMediaResourceAsync(Windows.Foundation.Uri,System.String,System.String,Windows.Storage.Streams.IInputStream)
    CreateMediaResourceAsync(Windows.Foundation.Uri,System.String,System.String,Windows.Storage.Streams.IInputStream)
    CreateMediaResourceAsync(Windows.Foundation.Uri,System.String,System.String,Windows.Storage.Streams.IInputStream)

    Creates a new media resource in the specified collection.

    public IAsyncOperationWithProgress<TransferProgress> CreateMediaResourceAsync(Windows.Foundation.Uri,System.String,System.String,Windows.Storage.Streams.IInputStream)public IAsyncOperationWithProgress<TransferProgress> CreateMediaResourceAsync(Windows.Foundation.Uri,System.String,System.String,Windows.Storage.Streams.IInputStream)Public Function CreateMediaResourceAsync(Windows.Foundation.Uri,System.String,System.String,Windows.Storage.Streams.IInputStream) As IAsyncOperationWithProgress( Of TransferProgress )

    Parameters

    • uri

      The Uniform Resource Identifier (URI) of the specified collection in which the new resource should be created.

    • mediaType
      System.String
      System.String
      System.String
      System.String

      The type for the media resource.

    • description
      System.String
      System.String
      System.String
      System.String

      The description of the new resource that is turned into the Slug: header of the POST request.

    • mediaStream

      Specifies the IInputStream to use as the media resource.

    Returns

    • The object that is used to create the resource asynchronously and to report the progress and completion status of the operation.

  • CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem)
    CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem)
    CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem)
    CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem)

    Creates a new Entry resource in the specified collection. The Uri of the collection in which to create the new resource can be discovered from the ResourceCollection object retrieved from the RetrieveResourceAsync(Windows.Foundation.Uri) method.

    public IAsyncOperationWithProgress<TransferProgress> CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem)public IAsyncOperationWithProgress<TransferProgress> CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem)Public Function CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem) As IAsyncOperationWithProgress( Of TransferProgress )

    Parameters

    • uri

      The Uri of the specified collection in which the new resource should be created.

    • description
      System.String
      System.String
      System.String
      System.String

      The description of the new resource that is turned into the Slug: header of the POST request.

    • item

      The new resource to be created.

    Returns

    • The object that is used to create the resource asynchronously and to report the progress and completion status of the operation.

    Remarks

    Examples

    The following code demonstrates how to access a service document and retrieve edit URI values. For additional examples of how AtomPub can be used to manage feed content, download the AtomPub sample.

        function createResource() {
            try {
                // Refresh client in case server url or credential have changed.
                createClient();
    
                var title = document.getElementById("titleField").value;
                if (title === "") {
                    outputField.innerHTML = "Post title cannot be blank";
                    return;
                }
    
                var serviceUri = new Windows.Foundation.Uri(document.getElementById("serviceAddressField").value.trim() + defaultServiceDocUri);
                outputField.innerHTML = "Fetching service document: " + serviceUri.absoluteUri + "</br>";
                findEditUri(serviceUri).then(function (resourceUri) {
                    if (!resourceUri) {
                        outputField.innerHTML += "Error: Edit uri not found in service document";
                        return null;
                    }
    
                    outputField.innerHTML += "Uploading post: " + resourceUri.absoluteUri + "</br>";
    
                    var item = new Windows.Web.Syndication.SyndicationItem();
                    item.title = new Windows.Web.Syndication.SyndicationText(title, Windows.Web.Syndication.SyndicationTextType.text);
                    var content = document.getElementById("bodyField").value;
                    item.content = new Windows.Web.Syndication.SyndicationContent(content, Windows.Web.Syndication.SyndicationTextType.html);
    
                    return client.createResourceAsync(resourceUri, item.title.text, item);
                }).done(function (result) {
                    if (result) {
                        outputField.innerHTML += "Posted at " + result.itemUri.absoluteUri + "</br>";
                        outputField.innerHTML += "Complete</br>";
                    }
                }, onError);
            }
            catch (ex) {
                outputField.innerHTML += "Exception:" + ex + "</br>";
            }
        }
    
    Note

    See RetrieveServiceDocumentAsync(Windows.Foundation.Uri) for the code behind the findEditUri function called in this example.

  • DeleteResourceAsync(Windows.Foundation.Uri)
    DeleteResourceAsync(Windows.Foundation.Uri)
    DeleteResourceAsync(Windows.Foundation.Uri)
    DeleteResourceAsync(Windows.Foundation.Uri)

    Deletes an existing Entry or Media Link resource.

    public IAsyncActionWithProgress<TransferProgress> DeleteResourceAsync(Windows.Foundation.Uri)public IAsyncActionWithProgress<TransferProgress> DeleteResourceAsync(Windows.Foundation.Uri)Public Function DeleteResourceAsync(Windows.Foundation.Uri) As IAsyncActionWithProgress( Of TransferProgress )

    Parameters

    • uri

      The Uri of the resource to be deleted.

    Returns

    • The object that is used to delete the resource asynchronously and to report the progress and completion status of the operation.

    Remarks

    For an example of how this methods is implemented to delete syndicated content, see Quickstart: Managing Feed Entries.

  • DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem)
    DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem)
    DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem)
    DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem)

    Deletes an existing Entry or Media Link resource. This differs from the DeleteResourceAsync(Windows.Foundation.Uri) method in that the SyndicationItem object that represents the resource to be deleted is specified instead of the Uri. The DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem) method uses the property of the specified SyndicationItem as the Uri of the resource to be deleted.

    public IAsyncActionWithProgress<TransferProgress> DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem)public IAsyncActionWithProgress<TransferProgress> DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem)Public Function DeleteResourceItemAsync(Windows.Web.Syndication.SyndicationItem) As IAsyncActionWithProgress( Of TransferProgress )

    Parameters

    Returns

    • The object that is used to delete the resource asynchronously and to report the progress and completion status of the operation.

  • RetrieveFeedAsync(Windows.Foundation.Uri)
    RetrieveFeedAsync(Windows.Foundation.Uri)
    RetrieveFeedAsync(Windows.Foundation.Uri)
    RetrieveFeedAsync(Windows.Foundation.Uri)

    Starts an asynchronous operation to download the syndication feed from the given URI. This method instantiates a SyndicationFeed object from the feed string, which can be in one of the formats specified in SyndicationFormat.

    public IAsyncOperationWithProgress<RetrievalProgress> RetrieveFeedAsync(Windows.Foundation.Uri)public IAsyncOperationWithProgress<RetrievalProgress> RetrieveFeedAsync(Windows.Foundation.Uri)Public Function RetrieveFeedAsync(Windows.Foundation.Uri) As IAsyncOperationWithProgress( Of RetrievalProgress )

    Parameters

    • uri

      The URI from which the feed is downloaded.

    Returns

    • Contains the results of the operation.

    Remarks

    Examples

    The following code demonstrates how a feed is retrieved at a specific service address using AtomPubClient. For additional examples of how AtomPub can be used to manage feed content, download the AtomPub sample.

    
        function retieveFeed() {
            try {
                // Refresh client in case server url or credential have changed.
                createClient();
    
                // Note that this feed is public by default and will not require authentication.
                // We will only get back a limited use feed, without information about editing.
                var resourceUri = new Windows.Foundation.Uri(document.getElementById("serviceAddressField").value.trim() + defaultFeedUri);
    
                outputField.innerHTML = "Fetching resource: " + resourceUri.absoluteUri + "/br";
                client.retrieveFeedAsync(resourceUri).done(function (feed) {
                    currentFeed = feed;
                    currentItemIndex = 0;
    
                    outputField.innerHTML += "Complete</br>";
                    displayCurrentItem();
                }, onError);
            }
            catch (ex) {
                outputField.innerHTML += "Exception:" + ex + "</br>";
            }
        }
    
  • RetrieveMediaResourceAsync(Windows.Foundation.Uri)
    RetrieveMediaResourceAsync(Windows.Foundation.Uri)
    RetrieveMediaResourceAsync(Windows.Foundation.Uri)
    RetrieveMediaResourceAsync(Windows.Foundation.Uri)

    Retrieves a media link resource from the specified Uniform Resource Identifier (URI).

    public IAsyncOperationWithProgress<RetrievalProgress> RetrieveMediaResourceAsync(Windows.Foundation.Uri)public IAsyncOperationWithProgress<RetrievalProgress> RetrieveMediaResourceAsync(Windows.Foundation.Uri)Public Function RetrieveMediaResourceAsync(Windows.Foundation.Uri) As IAsyncOperationWithProgress( Of RetrievalProgress )

    Parameters

    • uri

      The Uniform Resource Identifier (URI) for the media resource.

    Returns

    • The object used to retrieve the media resource and report the progress and completion status of the operation.

  • RetrieveResourceAsync(Windows.Foundation.Uri)
    RetrieveResourceAsync(Windows.Foundation.Uri)
    RetrieveResourceAsync(Windows.Foundation.Uri)
    RetrieveResourceAsync(Windows.Foundation.Uri)

    Retrieves an Entry resource or Media Link resource from the specified Uniform Resource Identifier (URI).

    public IAsyncOperationWithProgress<RetrievalProgress> RetrieveResourceAsync(Windows.Foundation.Uri)public IAsyncOperationWithProgress<RetrievalProgress> RetrieveResourceAsync(Windows.Foundation.Uri)Public Function RetrieveResourceAsync(Windows.Foundation.Uri) As IAsyncOperationWithProgress( Of RetrievalProgress )

    Parameters

    • uri

      The specified Uniform Resource Identifier (URI).

    Returns

    • The object that is used to retrieve the resource asynchronously and to report the progress and completion status of the operation.

  • RetrieveServiceDocumentAsync(Windows.Foundation.Uri)
    RetrieveServiceDocumentAsync(Windows.Foundation.Uri)
    RetrieveServiceDocumentAsync(Windows.Foundation.Uri)
    RetrieveServiceDocumentAsync(Windows.Foundation.Uri)

    Retrieves a service document from the specified Uri.

    public IAsyncOperationWithProgress<RetrievalProgress> RetrieveServiceDocumentAsync(Windows.Foundation.Uri)public IAsyncOperationWithProgress<RetrievalProgress> RetrieveServiceDocumentAsync(Windows.Foundation.Uri)Public Function RetrieveServiceDocumentAsync(Windows.Foundation.Uri) As IAsyncOperationWithProgress( Of RetrievalProgress )

    Parameters

    Returns

    • The object that is used to retrieve the service document asynchronously and to report the progress and completion status of the operation.

    Remarks

    Examples

    The following code demonstrates how to access a service document and retrieve edit URI values. For additional examples of how AtomPub can be used to manage feed content, download the AtomPub sample.

    
        function findEditUri(serviceUri) {
            return client.retrieveServiceDocumentAsync(serviceUri).then(function (serviceDocument) {
                for (var i in serviceDocument.workspaces) {
                    var workspace = serviceDocument.workspaces[i];
                    for (var j in workspace.collections) {
                        var collection = workspace.collections[j];
    
                        if (collection.accepts.join(";") === "application/atom+xml;type=entry") {
                            return collection.uri;
                        }
                    }
                }
    
                return null;
            });
        }
    
  • SetRequestHeader(System.String,System.String)
    SetRequestHeader(System.String,System.String)
    SetRequestHeader(System.String,System.String)
    SetRequestHeader(System.String,System.String)

    Sets an HTTP header for the request. This method can be called multiple times to set multiple headers. When the same header is set multiple times, the values will be concatenated and separated by ",".

    public void SetRequestHeader(System.String,System.String)public void SetRequestHeader(System.String,System.String)Public Function SetRequestHeader(System.String,System.String) As void

    Parameters

    • name
      System.String
      System.String
      System.String
      System.String

      The name of the header.

    • value
      System.String
      System.String
      System.String
      System.String

      The value of the header.

  • UpdateMediaResourceAsync(Windows.Foundation.Uri,System.String,Windows.Storage.Streams.IInputStream)
    UpdateMediaResourceAsync(Windows.Foundation.Uri,System.String,Windows.Storage.Streams.IInputStream)
    UpdateMediaResourceAsync(Windows.Foundation.Uri,System.String,Windows.Storage.Streams.IInputStream)
    UpdateMediaResourceAsync(Windows.Foundation.Uri,System.String,Windows.Storage.Streams.IInputStream)

    Updates a media link resource from the specified Uniform Resource Identifier (URI).

    public IAsyncActionWithProgress<TransferProgress> UpdateMediaResourceAsync(Windows.Foundation.Uri,System.String,Windows.Storage.Streams.IInputStream)public IAsyncActionWithProgress<TransferProgress> UpdateMediaResourceAsync(Windows.Foundation.Uri,System.String,Windows.Storage.Streams.IInputStream)Public Function UpdateMediaResourceAsync(Windows.Foundation.Uri,System.String,Windows.Storage.Streams.IInputStream) As IAsyncActionWithProgress( Of TransferProgress )

    Parameters

    Returns

    • Completion status or error codes.

  • UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem)
    UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem)
    UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem)
    UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem)

    Updates an existing Entry or Media Link resource. If an ETag: header has previously been seen while retrieving this resource (in a response to RetrieveResourceAsync(Windows.Foundation.Uri), CreateResourceAsync(Windows.Foundation.Uri,System.String,Windows.Web.Syndication.SyndicationItem) or a previous call to UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem) ), this method automatically sends an If-Match: header with the remembered value.

    public IAsyncActionWithProgress<TransferProgress> UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem)public IAsyncActionWithProgress<TransferProgress> UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem)Public Function UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem) As IAsyncActionWithProgress( Of TransferProgress )

    Parameters

    Returns

    • The object that is used to update the resource asynchronously and to report the progress and completion status of the operation.

    Remarks

    For an example of how this method is implemented to update syndicated content see Quickstart: Managing Feed Entries.

  • UpdateResourceItemAsync(Windows.Web.Syndication.SyndicationItem)
    UpdateResourceItemAsync(Windows.Web.Syndication.SyndicationItem)
    UpdateResourceItemAsync(Windows.Web.Syndication.SyndicationItem)
    UpdateResourceItemAsync(Windows.Web.Syndication.SyndicationItem)

    Updates an existing Entry or Media Link resource. This differs from the UpdateResourceAsync(Windows.Foundation.Uri,Windows.Web.Syndication.SyndicationItem) method in that the EditUri property of the specified SyndicationItem object is used as the Uri of the resource to be updated.

    public IAsyncActionWithProgress<TransferProgress> UpdateResourceItemAsync(Windows.Web.Syndication.SyndicationItem)public IAsyncActionWithProgress<TransferProgress> UpdateResourceItemAsync(Windows.Web.Syndication.SyndicationItem)Public Function UpdateResourceItemAsync(Windows.Web.Syndication.SyndicationItem) As IAsyncActionWithProgress( Of TransferProgress )

    Parameters

    Returns

    • The object that is used to update the resource asynchronously and to report the progress and completion status of the operation.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Capabilities

internetClient
privateNetworkClientServer

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute

Details

Assembly

Windows.Web.AtomPub.dll