管理API - 请求体XML无效或者未正确指定 [英] Management API - The request body XML was invalid or not correctly specified

查看:383
本文介绍了管理API - 请求体XML无效或者未正确指定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从<跨发布href=\"http://social.msdn.microsoft.com/Forums/en-US/windowsazuretroubleshooting/thread/31b6aedc-c069-4e32-8e8f-2ff4b7c30793\" rel=\"nofollow\">http://social.msdn.microsoft.com/Forums/en-US/windowsazuretroubleshooting/thread/31b6aedc-c069-4e32-8e8f-2ff4b7c30793

我得到通过服务管理API更改配置此错误:请求主体的XML无效或不正确指定

I'm getting this error on changing configuration through the service management API: The request body XML was invalid or not correctly specified

请求体的有效载荷:

&LT;?XML版本=1.0编码=UTF-8&GT?;
&LT; ChangeConfiguration的xmlns =htt​​p://schemas.microsoft.com/windowsazu
重&GT;
  &lt;结构&GT; PD94bWwgdmVyc2lvbj0iMS4wIj8 + CjxTZXJ2aWNlQ29uZmlndX
JhdGlvbiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIi
B4bWxuczp4c2Q9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hIiB4bWxucz0iaHR0cDovL3
NjaGVtYXMubWljcm9zb2Z0LmNvbS9TZXJ2aWNlSG9zdGluZy8yMDA4LzEwL1NlcnZpY2VDb25maWd1cm
F0aW9uIiBzZXJ2aWNlTmFtZT0iIiBvc0ZhbWlseT0iMSIgb3NWZXJzaW9uPSIqIj4KICA8Um9sZSBuYW
1lPSJXZWJSb2xlMSI + CiAgICA8Q29uZmlndXJhdGlvblNldHRpbmdzPgogICAgICA8U2V0dGluZyBuYW
1lPSJNaWNyb3NvZnQuV2luZG93c0F6dXJlLlBsdWdpbnMuRGlhZ25vc3RpY3MuQ29ubmVjdGlvblN0cm
luZyIgdmFsdWU9IlVzZURldmVsb3BtZW50U3RvcmFnZT10cnVlIi8 + CiAgICA8L0NvbmZpZ3VyYXRpb2
5TZXR0aW5ncz4KICAgIDxJbnN0YW5jZXMgY291bnQ9IjIiLz4KICAgIDxDZXJ0aWZpY2F0ZXMvPgogID
wvUm9sZT4KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4K&LT; /结构&gt;
&LT; / ChangeConfiguration&GT;

我传递给它配置如下:

$配置='&LT; XML版本=1.0编码=UTF-8&GT?;
&LT; ServiceConfiguration的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instance的xmlns:XSD =htt​​p://www.w3.org/2001/XMLSchema中的xmlns =HTTP:// schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration服务名=osFamily =1OSVERSION =*&GT;
 &LT;角色名称=WebRole1&GT;
  &LT; ConfigurationSettings&GT;
   &lt;设定名=Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionStringVALUE =UseDevelopmentStorage =真正的/&GT;
  &LT; / ConfigurationSettings&GT;
  &LT;实例数=2/&GT;
  &LT;认证/&GT;
 &LT; /角色&GT;
&LT; / ServiceConfiguration&GT;';

有谁知道为什么会发生错误?我怀疑它是与编码,但不能肯定。

Does anyone know why this error occurs? I suspect it has something to do with encoding but not sure.

推荐答案

您直接从调用API得到这个?如果是这样,它应该与X-MS-的requestId头中回来

Are you getting this directly from the call to the API? If so, it should be coming back with a x-ms-requestid header.

如果你采取的,招呼一下,

If you take that and call out to

https://management.core.windows.net/<subscriptionID/operations/<requestId>

这应该给你到底是怎么回事,通常是告诉你到底是怎么回事在一个更详细的消息。

This should give you a much more detailed message about what is going on, usually telling you exactly what is going on.

以外的是,我会检查以下内容:

Outside of that, I'd check the following:

1)检查您的编码,然后再次检查。我只提到这一点,因为当我第一次缠绕我有我的地方被编码拧东西了一个问题API。因此,我最后做的是写一点code的,将读取该文件,连接code吧,去code那,那保存到一个新文件。然后二进制比较两个。我终于发现他们用一个字节不同,它打破了整个事情。

1.) Check your encoding, then check it again. I only mention this because when I first wrapped the API I had an issue where my encoding was screwing something up. So what I finally did was write a bit of code that would read the file, encode it, decode that, save that to a new file. Then binary compare the two. I finally found they were different by a single byte and it broke the whole thing.

2)检查你的配置。上传,准确的配置文件,以通过门户网站的作用,看看它的接受。

2.) Check your config. Upload that exact config file to your role via the portal and see if its accepted.

3。)检查API版本的标题。不知道该SDK的PHP的,但如果可能的话,你可以明确地检查/设置X-MS-版本头被发送到API?

3.) Check API version header. Not sure on the SDK for PHP, but if possible can you explicitly check/set the x-ms-version header being sent to the api?

4。)导致有效故障,并从那里反向工程。如果一切都失败了,传递一个空白或​​随机/ EN无效codeD字符串。然后使用GetOperationStatus端点,以确保你得到错误的配置无效的曲调。你知道你的请求,这种方式被接受,但编码/配置是抛出一个错误。

4.) Cause a valid failure, and reverse engineer from there. If all else fails, pass in a blank or random/invalid encoded string. Then use the GetOperationStatus endpoint to ensure you are getting errors to the tune of "Configuration is invalid". This way you know your request is being accepted, but the encoding/configuration is throwing an error.

修改:在这里你的答复和MSDN

EDIT: from your reply here and MSDN

5)尽量省略XML声明

<?xml version="1.0" encoding="utf-8"?>

请求主体。
当我运行的确切的请求VS我自己的.NET API创建的包装相同的请求,唯一的区别在于,XML声明不是在POST体。包装生成的类为我工作。

from the request body. When I run your exact request vs the same request created by my own .net api wrapper, the only difference is that XML declaration is not in the body of the POST. The wrapper-generated class works for me.

这篇关于管理API - 请求体XML无效或者未正确指定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆