I am trying to register my Windows Universal App for notifications from the Azure Notification Hub through our Java backend service.
I debugged the app from Visual Studio, while it was running on my Windows Phone device. The app could properly get a ChannelUri and passed it along to our Java backend. (I ran the backend on my local PC.)
The Java backend generated the following request for a template registration and tried to send it to the Azure REST Api:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<content type="application/xml">
<WindowsTemplateRegistrationDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Tags>Windows,10204394042027091,broadcast</Tags>
<ChannelUri>https://db3.notify.windows.com/?token=AwYAAABXiUp%2bD8v1%2bVfWbWLr3FZ3rQcJtPkUgFwaiGZus4GbtkM8zbZ6uQt1NKXpC4FOtYWHDxXvBb3FkoefaozvCYTFiDjhdb3jDuORUDY8zBlkGw1MxY0QjrH7G0fFbW0RXgo%3d</ChannelUri>
<BodyTemplate><![CDATA[{...}]]></BodyTemplate>
<WNSHeaders>
<WNSHeader>
<Header>X-WNS-Type</Header>
<Value>wns/raw</Value>
</WNSHeader>
</WNSHeaders>
<TemplateName>geoinfo</TemplateName>
</WindowsTemplateRegistrationDescription>
</content>
</entry>
In my opinion this is according to the MS Azure REST reference: http://msdn.microsoft.com/en-us/library/azure/dn223265.aspx
Still, the response contains the following error:
<Error><Code>400</Code><Detail>The specified resource description is invalid..TrackingId:4ffaabcc-c7f8-4a6c-ab2f-4f65e94427df_G16,TimeStamp:10/21/2014 9:42:52 PM</Detail></Error>
Any ideas on what Azure's issue is around here?
Try this:
- Call Create Registration ID
- Store retrieved id in your DB
- Call Create or Update Registration to create registration
- Each time you want to update that registration in future (refresh channel, modify tags...) you just call Create or Update Registration again
I've just successfully played with payload bellow:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text"></title>
<updated>2014-10-21T23:57:08Z</updated>
<content type="application/atom+xml;type=entry;charset=utf-8">
<WindowsTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
<Tags>t1,t2</Tags>
<ChannelUri>https://db3.notify.windows.com/?token=AwYAAABXiUp%2bD8v1%2bVfWbWLr3FZ3rQcJtPkUgFwaiGZus4GbtkM8zbZ6uQt1NKXpC4FOtYWHDxXvBb3FkoefaozvCYTFiDjhdb3jDuORUDY8zBlkGw1MxY0QjrH7G0fFbW0RXgo%3d</ChannelUri>
<BodyTemplate><![CDATA[<?xml version="1.0" encoding="utf-16"?><root></root>]]></BodyTemplate>
<WnsHeaders>
<WnsHeader>
<Header>X-WNS-Type</Header>
<Value>wns/raw</Value>
</WnsHeader>
</WnsHeaders>
<TemplateName>MyTemplate</TemplateName>
</WindowsTemplateRegistrationDescription>
</content>
</entry>
The error message apparently means that the request is missing required XML elements. The problem in my case was the capitalization:
Both WNSHeader
and WNSHeaders
should be written in Pascal case instead: WnsHeader
and WnsHeaders
.
Unfortunately Microsoft's documentation on the API is misleading regarding this.
来源:https://stackoverflow.com/questions/26497103/what-does-the-following-azure-notification-hub-rest-response-mean-the-specifie