我的一个应用程序使用 REST API 与 Amazon S3 服务器交互,对服务器执行了“删除多个”操作并遇到了错误响应:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>MalformedXML</Code>
<Message>The XML you provided was not well-formed or did not validate against our published schema</Message>
<RequestId>6FA...D61</RequestId>
<HostId>E5G...uhg=</HostId>
</Error>
This happens when the user sends malformed xml (xml that doesn't conform to the published xsd) for the configuration. The error message is, "The XML you provided was not well-formed or did not validate against our published schema."
我的应用程序的某些删除键包含可能会导致问题的编码字符。因此,我希望查看 Amazon 的已发布架构 (XSD) 文件本身,通过验证器运行它来确定问题。
在哪里可以找到 Amazon XSD 文件?
最佳答案
AmazonS3.xsd可用,还可咨询Amazon Simple Storage Service API Reference :
- Making Requests Using the REST API
- REST API
- Delete Multiple Objects
- Authenticating Requests (AWS Signature Version 4)
最后,特别是考虑到您对编码字符的担忧,请注意,您的请求实际上可能格式不正确,导致 XSD 验证无法发挥作用。 (参见 Well-formed vs Valid XML 。)他们的 API 文档中提供的示例就是这种情况,它引发了您收到的相同错误:
Example 3: Malformed XML in the Request
This example shows how Amazon S3 responds to a request that includes a malformed XML document.
Sample Request
The following requests sends a malformed XML document (missing the Delete end element).
POST /?delete HTTP/1.1 Host: bucketname.S3.amazonaws.com Accept: */* x-amz-date: Wed, 30 Nov 2011 03:39:05 GMT Content-MD5: p5/WA/oEr30qrEEl21PAqw== Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIee= Content-Length: 104 Connection: Keep-Alive <Delete> <Object> <Key>404.txt</Key> </Object> <Object> <Key>a.txt</Key> </Object>
Sample Response
The response returns the Error messages that describe the error.
HTTP/1.1 200 OK x-amz-id-2: P3xqrhuhYxlrefdw3rEzmJh8z5KDtGzb+/FB7oiQaScI9Yaxd8olYXc7d1111ab+ x-amz-request-id: 264A17BF16E9E80A Date: Wed, 30 Nov 2011 03:39:32 GMT Content-Type: application/xml Server: AmazonS3 Content-Length: 207 <?xml version="1.0" encoding="UTF-8"?> <Error> <Code>MalformedXML</Code> <Message>The XML you provided was not well-formed or did not validate against our published schema</Message> <RequestId>91F27FB5811111F</RequestId> <HostId>LCiQK7KbXyJ1t+tncmjRwmNoeeRNW1/ktJ61IC8kN32SFXJx7UBhOzseJCixAbcD</HostId> </Error>
关于xml - 在哪里可以找到 Amazon 发布的 S3 XSD(XML 架构定义)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36112946/