AtomPubClient
AtomPubClient
AtomPubClient
AtomPubClient
Class
Definition
Encapsulates the methods needed to implement the AtomPub protocol which enables HTTP CRUD access to Web resources using the Atom 1.0 wire format.
public : sealed class AtomPubClient : IAtomPubClient, ISyndicationClientpublic sealed class AtomPubClient : IAtomPubClient, ISyndicationClientPublic NotInheritable Class AtomPubClient Implements IAtomPubClient, ISyndicationClient// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
privateNetworkClientServer
internetClient
|
Remarks
For examples of how these class methods are implemented to create, retrieve, update, or delete syndicated content, see Quickstart: Managing Feed Entries.
Constructors
AtomPubClient() AtomPubClient() AtomPubClient() AtomPubClient()
Creates a new AtomPubClient object.
public : AtomPubClient()public AtomPubClient()Public Sub New()// You can use this method in JavaScript.
- See Also
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 AtomPubClient(PasswordCredential serverCredential)Public Sub New(serverCredential As PasswordCredential)// You can use this method in JavaScript.
- serverCredential
- PasswordCredential PasswordCredential PasswordCredential PasswordCredential
The specified security credentials.
Properties
BypassCacheOnRetrieve BypassCacheOnRetrieve BypassCacheOnRetrieve BypassCacheOnRetrieve
Gets or sets a Boolean value that specifies whether to bypass the cache when retrieving the feed.
public : PlatForm::Boolean BypassCacheOnRetrieve { get; set; }public bool BypassCacheOnRetrieve { get; set; }Public ReadWrite Property BypassCacheOnRetrieve As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean 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 : unsigned int MaxResponseBufferSize { get; set; }public uint MaxResponseBufferSize { get; set; }Public ReadWrite Property MaxResponseBufferSize As uint// You can use this property in JavaScript.
- Value
- unsigned int 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// You can use this property in JavaScript.
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// You can use this property in JavaScript.
Initially, this value is a username/password tuple. For domain credentials, the username is in domain\user form.
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 : unsigned int Timeout { get; set; }public uint Timeout { get; set; }Public ReadWrite Property Timeout As uint// You can use this property in JavaScript.
- Value
- unsigned int 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// You can use this method in JavaScript.
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, PlatForm::String mediaType, PlatForm::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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uniform Resource Identifier (URI) of the specified collection in which the new resource should be created.
- mediaType
- PlatForm::String String String String
The type for the media resource.
- description
- PlatForm::String String String String
The description of the new resource that is turned into the Slug: header of the POST request.
- mediaStream
- IInputStream IInputStream IInputStream IInputStream
Specifies the IInputStream to use as the media resource.
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 method.
public : IAsyncOperationWithProgress<SyndicationItem, TransferProgress> CreateResourceAsync(Uri uri, PlatForm::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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uri of the specified collection in which the new resource should be created.
- description
- PlatForm::String String String String
The description of the new resource that is turned into the Slug: header of the POST request.
The new resource to be created.
The object that is used to create the resource asynchronously and to report the progress and completion status of the operation.
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 for the code behind the findEditUri function called in this example.
- See Also
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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uri of the resource to be deleted.
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.
- See Also
DeleteResourceItemAsync(SyndicationItem) DeleteResourceItemAsync(SyndicationItem) DeleteResourceItemAsync(SyndicationItem) DeleteResourceItemAsync(SyndicationItem)
Deletes an existing Entry or Media Link resource. This differs from the DeleteResourceAsync method in that the SyndicationItem object that represents the resource to be deleted is specified instead of the Uri. The DeleteResourceItemAsync 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 )// You can use this method in JavaScript.
The resource to be deleted.
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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI from which the feed is downloaded.
Contains the results of the operation.
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>";
}
}
- See Also
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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uniform Resource Identifier (URI) for the media resource.
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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The specified Uniform Resource Identifier (URI).
The object that is used to retrieve the resource asynchronously and to report the progress and completion status of the operation.
- See Also
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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The specified Uri.
The object that is used to retrieve the service document asynchronously and to report the progress and completion status of the operation.
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;
});
}
- See Also
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(PlatForm::String name, PlatForm::String value)public void SetRequestHeader(String name, String value)Public Function SetRequestHeader(name As String, value As String) As void// You can use this method in JavaScript.
- name
- PlatForm::String String String String
The name of the header.
- value
- PlatForm::String String String 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, PlatForm::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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uniform Resource Identifier (URI) of the resource to be updated.
- mediaType
- PlatForm::String String String String
The media type of the resource.
- mediaStream
- IInputStream IInputStream IInputStream IInputStream
The IInputStream of the media that is updating the media resource.
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, CreateResourceAsync or a previous call to UpdateResourceAsync ), 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 )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uniform Resource Identifier (URI) of the resource to be updated.
The resource to be updated.
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.
- See Also
UpdateResourceItemAsync(SyndicationItem) UpdateResourceItemAsync(SyndicationItem) UpdateResourceItemAsync(SyndicationItem) UpdateResourceItemAsync(SyndicationItem)
Updates an existing Entry or Media Link resource. This differs from the UpdateResourceAsync 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 )// You can use this method in JavaScript.
The resource to be updated.
The object that is used to update the resource asynchronously and to report the progress and completion status of the operation.
- See Also