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 AtomPubClientpublic sealed 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(Uri) method.

Deletes an existing Entry or Media Link resource.

Deletes an existing Entry or Media Link resource. This differs from the DeleteResourceAsync(Uri) method in that the SyndicationItem object that represents the resource to be deleted is specified instead of the Uri. The DeleteResourceItemAsync(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(Uri), CreateResourceAsync(Uri, String, SyndicationItem) or a previous call to UpdateResourceAsync(Uri, 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(Uri, 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 New()Public Sub New()public AtomPubClient()
  • AtomPubClient(PasswordCredential)
    AtomPubClient(PasswordCredential)
    AtomPubClient(PasswordCredential)
    AtomPubClient(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(PasswordCredential serverCredential)public New(PasswordCredential serverCredential)Public Sub New(serverCredential As PasswordCredential)public AtomPubClient(PasswordCredential serverCredential)

    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 boolpublic bool BypassCacheOnRetrieve { get; set; }

    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 uintpublic uint MaxResponseBufferSize { get; set; }

    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 PasswordCredentialpublic PasswordCredential ProxyCredential { get; set; }

    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 PasswordCredentialpublic PasswordCredential ServerCredential { get; set; }

    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 uintpublic uint Timeout { get; set; }

    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 voidpublic void CancelAsyncOperations()
  • CreateMediaResourceAsync(Uri, String, String, IInputStream)
    CreateMediaResourceAsync(Uri, String, String, IInputStream)
    CreateMediaResourceAsync(Uri, String, String, IInputStream)
    CreateMediaResourceAsync(Uri, String, String, IInputStream)

    Creates a new media resource in the specified collection.

    public IAsyncOperationWithProgress<SyndicationItem, TransferProgress> CreateMediaResourceAsync(Uri uri, String mediaType, String description, IInputStream mediaStream)public IAsyncOperationWithProgress<SyndicationItem, TransferProgress> CreateMediaResourceAsync(Uri uri, String mediaType, String description, IInputStream mediaStream)Public Function CreateMediaResourceAsync(uri As Uri, mediaType As String, description As String, mediaStream As IInputStream) As IAsyncOperationWithProgress( Of SyndicationItem, TransferProgress )public IAsyncOperationWithProgress<SyndicationItem, TransferProgress> CreateMediaResourceAsync(Uri uri, String mediaType, String description, IInputStream mediaStream)

    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(Uri, String, SyndicationItem)
    CreateResourceAsync(Uri, String, SyndicationItem)
    CreateResourceAsync(Uri, String, SyndicationItem)
    CreateResourceAsync(Uri, String, 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(Uri) method.

    public IAsyncOperationWithProgress<SyndicationItem, TransferProgress> CreateResourceAsync(Uri uri, String description, SyndicationItem item)public IAsyncOperationWithProgress<SyndicationItem, TransferProgress> CreateResourceAsync(Uri uri, String description, SyndicationItem item)Public Function CreateResourceAsync(uri As Uri, description As String, item As SyndicationItem) As IAsyncOperationWithProgress( Of SyndicationItem, TransferProgress )public IAsyncOperationWithProgress<SyndicationItem, TransferProgress> CreateResourceAsync(Uri uri, String description, SyndicationItem item)

    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(Uri) for the code behind the findEditUri function called in this example.

  • DeleteResourceAsync(Uri)
    DeleteResourceAsync(Uri)
    DeleteResourceAsync(Uri)
    DeleteResourceAsync(Uri)

    Deletes an existing Entry or Media Link resource.

    public IAsyncActionWithProgress<TransferProgress> DeleteResourceAsync(Uri uri)public IAsyncActionWithProgress<TransferProgress> DeleteResourceAsync(Uri uri)Public Function DeleteResourceAsync(uri As Uri) As IAsyncActionWithProgress( Of TransferProgress )public IAsyncActionWithProgress<TransferProgress> DeleteResourceAsync(Uri uri)

    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(SyndicationItem)
    DeleteResourceItemAsync(SyndicationItem)
    DeleteResourceItemAsync(SyndicationItem)
    DeleteResourceItemAsync(SyndicationItem)

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

    public IAsyncActionWithProgress<TransferProgress> DeleteResourceItemAsync(SyndicationItem item)public IAsyncActionWithProgress<TransferProgress> DeleteResourceItemAsync(SyndicationItem item)Public Function DeleteResourceItemAsync(item As SyndicationItem) As IAsyncActionWithProgress( Of TransferProgress )public IAsyncActionWithProgress<TransferProgress> DeleteResourceItemAsync(SyndicationItem item)

    Parameters

    Returns

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

  • RetrieveFeedAsync(Uri)
    RetrieveFeedAsync(Uri)
    RetrieveFeedAsync(Uri)
    RetrieveFeedAsync(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<SyndicationFeed, RetrievalProgress> RetrieveFeedAsync(Uri uri)public IAsyncOperationWithProgress<SyndicationFeed, RetrievalProgress> RetrieveFeedAsync(Uri uri)Public Function RetrieveFeedAsync(uri As Uri) As IAsyncOperationWithProgress( Of SyndicationFeed, RetrievalProgress )public IAsyncOperationWithProgress<SyndicationFeed, RetrievalProgress> RetrieveFeedAsync(Uri uri)

    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(Uri)
    RetrieveMediaResourceAsync(Uri)
    RetrieveMediaResourceAsync(Uri)
    RetrieveMediaResourceAsync(Uri)

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

    public IAsyncOperationWithProgress<IInputStream, RetrievalProgress> RetrieveMediaResourceAsync(Uri uri)public IAsyncOperationWithProgress<IInputStream, RetrievalProgress> RetrieveMediaResourceAsync(Uri uri)Public Function RetrieveMediaResourceAsync(uri As Uri) As IAsyncOperationWithProgress( Of IInputStream, RetrievalProgress )public IAsyncOperationWithProgress<IInputStream, RetrievalProgress> RetrieveMediaResourceAsync(Uri uri)

    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(Uri)
    RetrieveResourceAsync(Uri)
    RetrieveResourceAsync(Uri)
    RetrieveResourceAsync(Uri)

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

    public IAsyncOperationWithProgress<SyndicationItem, RetrievalProgress> RetrieveResourceAsync(Uri uri)public IAsyncOperationWithProgress<SyndicationItem, RetrievalProgress> RetrieveResourceAsync(Uri uri)Public Function RetrieveResourceAsync(uri As Uri) As IAsyncOperationWithProgress( Of SyndicationItem, RetrievalProgress )public IAsyncOperationWithProgress<SyndicationItem, RetrievalProgress> RetrieveResourceAsync(Uri uri)

    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(Uri)
    RetrieveServiceDocumentAsync(Uri)
    RetrieveServiceDocumentAsync(Uri)
    RetrieveServiceDocumentAsync(Uri)

    Retrieves a service document from the specified Uri.

    public IAsyncOperationWithProgress<ServiceDocument, RetrievalProgress> RetrieveServiceDocumentAsync(Uri uri)public IAsyncOperationWithProgress<ServiceDocument, RetrievalProgress> RetrieveServiceDocumentAsync(Uri uri)Public Function RetrieveServiceDocumentAsync(uri As Uri) As IAsyncOperationWithProgress( Of ServiceDocument, RetrievalProgress )public IAsyncOperationWithProgress<ServiceDocument, RetrievalProgress> RetrieveServiceDocumentAsync(Uri uri)

    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(String, String)
    SetRequestHeader(String, String)
    SetRequestHeader(String, String)
    SetRequestHeader(String, 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(String name, String value)public void SetRequestHeader(String name, String value)Public Function SetRequestHeader(name As String, value As String) As voidpublic void SetRequestHeader(String name, String value)

    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(Uri, String, IInputStream)
    UpdateMediaResourceAsync(Uri, String, IInputStream)
    UpdateMediaResourceAsync(Uri, String, IInputStream)
    UpdateMediaResourceAsync(Uri, String, IInputStream)

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

    public IAsyncActionWithProgress<TransferProgress> UpdateMediaResourceAsync(Uri uri, String mediaType, IInputStream mediaStream)public IAsyncActionWithProgress<TransferProgress> UpdateMediaResourceAsync(Uri uri, String mediaType, IInputStream mediaStream)Public Function UpdateMediaResourceAsync(uri As Uri, mediaType As String, mediaStream As IInputStream) As IAsyncActionWithProgress( Of TransferProgress )public IAsyncActionWithProgress<TransferProgress> UpdateMediaResourceAsync(Uri uri, String mediaType, IInputStream mediaStream)

    Parameters

    Returns

    • Completion status or error codes.

  • UpdateResourceAsync(Uri, SyndicationItem)
    UpdateResourceAsync(Uri, SyndicationItem)
    UpdateResourceAsync(Uri, SyndicationItem)
    UpdateResourceAsync(Uri, 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(Uri), CreateResourceAsync(Uri, String, SyndicationItem) or a previous call to UpdateResourceAsync(Uri, SyndicationItem) ), this method automatically sends an If-Match: header with the remembered value.

    public IAsyncActionWithProgress<TransferProgress> UpdateResourceAsync(Uri uri, SyndicationItem item)public IAsyncActionWithProgress<TransferProgress> UpdateResourceAsync(Uri uri, SyndicationItem item)Public Function UpdateResourceAsync(uri As Uri, item As SyndicationItem) As IAsyncActionWithProgress( Of TransferProgress )public IAsyncActionWithProgress<TransferProgress> UpdateResourceAsync(Uri uri, SyndicationItem item)

    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(SyndicationItem)
    UpdateResourceItemAsync(SyndicationItem)
    UpdateResourceItemAsync(SyndicationItem)
    UpdateResourceItemAsync(SyndicationItem)

    Updates an existing Entry or Media Link resource. This differs from the UpdateResourceAsync(Uri, 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(SyndicationItem item)public IAsyncActionWithProgress<TransferProgress> UpdateResourceItemAsync(SyndicationItem item)Public Function UpdateResourceItemAsync(item As SyndicationItem) As IAsyncActionWithProgress( Of TransferProgress )public IAsyncActionWithProgress<TransferProgress> UpdateResourceItemAsync(SyndicationItem item)

    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

privateNetworkClientServer
internetClient

Attributes

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

Details

Assembly

Windows.Web.AtomPub.dll