我正在尝试通过Java后端服务注册我的的通知。
当这个应用程序在我的Windows设备上运行时,我从Visual中调试了它。该应用程序可以正确地获得一个ChannelUri并将其传递给我们的Java后端。(我在本地PC上运行后端。)
Java后端生成了以下模板注册请求,并试图将其发送到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>在我看来,这是根据MS参考:http://msdn.microsoft.com/en-us/library/azure/dn223265.aspx
但是,响应仍然包含以下错误:
<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>对Azure的问题有什么想法吗?
发布于 2014-10-22 00:20:00
试试这个:
我刚刚成功地玩了有效载荷:
<?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>发布于 2014-10-22 15:03:44
错误消息显然意味着请求缺少所需的XML元素。就我的情况而言,问题是资本化:
WNSHeader和WNSHeaders都应该用Pascal写成:WnsHeader和WnsHeaders__.。
不幸的是,Microsoft关于API的文档在这方面有误导之嫌。
https://stackoverflow.com/questions/26497103
复制相似问题