共用方式為


建立註冊

 

要求

方法 要求 URI HTTP 版本
POST https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/?api-version=2015-01 HTTP/1.1

要求標頭

下表描述必要的和選用的要求標頭。

要求標頭 說明
Content-Type application/atom+xml;type=entry;charset=utf-8
授權 使用共用存取簽章驗證中所指定產生的語彙基元 服務匯流排, ,或 服務匯流排 利用驗證與授權 Microsoft Azure Active Directory 存取控制服務 (也稱為「存取控制服務」或 ACS)。
x-ms-version 2015-01

要求本文

Atom 項目,其描述內嵌於內容中。 以下是一些範例。

Windows 通知服務的原生註冊:

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <WindowsRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Tags>myTag, myOtherTag</Tags> <ChannelUri>{ChannelUri}</ChannelUri> </WindowsRegistrationDescription> </content> </entry>  

注意

Tags 是選擇性項目。

Windows 通知服務的範本註冊:

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <WindowsTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Tags>myTag, myOtherTag</Tags> <ChannelUri>{ChannelUri}</ChannelUri> <BodyTemplate><![CDATA[{Template for the body}]]></BodyTemplate> <WnsHeaders> <WnsHeader> <Header>X-WNS-Type</Header> <Value>wns/tile</Value> </WnsHeader> <WnsHeader> <Header>X-WNS-Tag</Header> <Value>myTag</Value> </WnsHeader> </WnsHeaders> </WindowsTemplateRegistrationDescription> </content> </entry>  

注意

BodyTemplate 項目是必要的就像 X-WNS-Type 標頭。

Apple 推播通知服務的原生註冊:

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <AppleRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Tags>myTag, myOtherTag</Tags> <DeviceToken>{DeviceToken}</DeviceToken> </AppleRegistrationDescription> </content> </entry>  

注意

Tags 是選擇性項目。

Apple 推播通知服務的範本註冊:

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <AppleTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Tags>myTag, myOtherTag</Tags> <DeviceToken>{DeviceToken}</DeviceToken> <BodyTemplate><![CDATA[{Template for the body}]]></BodyTemplate> <Expiry>{Template for Expiry in }</Expiry> </AppleTemplateRegistrationDescription> </content> </entry>  

注意

BodyTemplate 元素為必要。Expiry 是選擇性的。

Google 雲端訊息的原生註冊:

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <GcmRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Tags>myTag, myOtherTag</Tags> <GcmRegistrationId>{GCM Registration Id}</GcmRegistrationId> </GcmRegistrationDescription> </content> </entry>  

注意

Tags 是選擇性項目。

Google 雲端訊息的範本註冊:

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <GcmTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Tags>myTag, myOtherTag</Tags> <GcmRegistrationId>{GCM Registration Id}</GcmRegistrationId> <BodyTemplate><![CDATA[ {BodyTemplate}]]></BodyTemplate> </GcmTemplateRegistrationDescription> </content> </entry>  

注意

BodyTemplate 元素為必要。

Microsoft 推播通知服務的原生註冊:

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <MpnsRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Tags>myTag, myOtherTag</Tags> <ChannelUri>{ChannelUri}</ChannelUri> </MpnsRegistrationDescription> </content> </entry>  

注意

Tags 是選擇性項目。

Microsoft 推播通知服務的範本註冊:

<?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <MpnsTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <Tags>myTag, myOtherTag</Tags> <ChannelUri>{ChannelUri}</ChannelUri> <BodyTemplate><![CDATA[{Template for the body}]]></BodyTemplate> <MpnsHeaders> <MpnsHeader> <Header>X-WindowsPhone-Target</Header> <Value>toast</Value> </MpnsHeader> <MpnsHeader> <Header>X-NotificationClass</Header> <Value>[batching interval]</Value> </MpnsHeader> </MpnsHeaders> </MpnsTemplateRegistrationDescription> </content> </entry>  

注意

BodyTemplate 項目是必要的就像 X-WindowsPhone-Target 標頭。

回應

回應包括 HTTP 狀態碼和一組回應標頭。

回應碼

程式碼 說明
201 已成功建立註冊。
400 無效的要求內文。 無法建立註冊,因為要求格式錯誤。
401 授權失敗。 存取金鑰不正確。
403 配額已超過;此命名空間中有太多註冊。 並未建立註冊。
403 要求遭拒,因為註冊作業率過高。

如需狀態碼的相關資訊,請參閱 狀態和錯誤碼

回應標頭

回應標頭 說明
Content-type application/atom+xml;type=entry;charset=utf-8
ETag {weak ETag}

回應主體

成功時,會傳回已驗證的 Atom 項目。 這包含唯讀元素例如 ETag, ,RegistrationId, ,和 ExpirationTime。 例如:

<entry> <id>https://{tenant}.servicebus.windows.net/{NotificationHub}/registrations/{registrationId}</id> <title type="text"> /{NotificationHub}/registrations/{registrationId}</title> <updated>2012-08-17T17:32:00Z</updated> <metadata:etag>{weak Etag}</metadata:etag> <content type="application/xml"> <WindowsRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <ETag>{ETag}</ETag> <ExpirationTime>2012-07-16T19:20+01:00</ExpirationTime> <RegistrationId>{RegistrationId}</RegistrationId> <Tags>myTag, myOtherTag</Tags> <ChannelUri>{ChannelUri}</ChannelUri> </WindowsRegistrationDescription> </content> </entry>