2

An application of mine, interacting with the Amazon S3 server using REST API, performed a "Delete Multiple" operation against the server and encountered an error response:

<?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>

Quoting the Amazon documentation:

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."

Some of my app's deletion keys contain encoded characters that may be causing a problem. I would therefore like to see Amazon's published schema (XSD) file itself, running it through a validator to determine the problem.

Where can I find the Amazon XSD file?

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Moshe Rubin
  • 1,944
  • 1
  • 17
  • 37

2 Answers2

2

AmazonS3.xsd is available, but also consult the Amazon Simple Storage Service API Reference:

Finally, especially given your concern regarding encoded characters, note that there is a chance that your request is actually not even well-formed such that XSD validation isn't coming into play. (See Well-formed vs Valid XML.) Such is the case in the example provided in their API doc, which elicits the same error you're receiving:

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>
Community
  • 1
  • 1
kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Thank for the well thought-out post. As I wrote in a previous comment, my program (actually a regression test suite that consistently performs the same tests against Amazon S3) has worked successfully until this morning. I received the MalformedXML error repeatedly for about an hour, but now it's back up and running successfully like a champ. I have "battled" and won all encoding issues with Amazon S3, so I know the character encodings are correct. The XML is definitely well-formed, as it has passed several online XML validator apps. Thanks for the post! – Moshe Rubin Mar 20 '16 at 14:43
  • I see you edited my thanks out of my original post as per SO policy. I have no problem with that -- thanking people is just a weakness I have . What is the SO policy on such issues? – Moshe Rubin Mar 20 '16 at 14:47
  • You're welcome, and thanking in advance isn't a vice, really :-), just unnecessary noise. Mostly the edit was to add "S3" to the title, but while I was in there, I struck the closing thanks too. See [What should I keep out of my posts and titles?](http://meta.stackexchange.com/questions/131009/what-should-i-keep-out-of-my-posts-and-titles) – kjhughes Mar 20 '16 at 14:54
  • Back to the substance of your question: I'd recommend that you log the request anytime you receive an error response challenging well-formedness or validity of the request. Posting the request in your question would have made answering your question much easier (probably for you too as much as for us, in fact). – kjhughes Mar 20 '16 at 14:59
  • First, thanks for the link to SO policy (oops, there I go again ) -- interesting information. Second, and more important technically, I ascertained why my requests occasionally fail. This morning I worked from home and connected to the S3 server via my family's ISP. This ISP performs parental control content filtering (e.g., not appropriate for children), but they mess up their SSL/TLS certificate handling,causing TLS problems. When I connected via my unfiltered work ISP, everything worked like a charm. `Moral: don't do development work on a parental control internet connection!` – Moshe Rubin Mar 20 '16 at 15:37
  • Can't say I see how an ISP SSL/TLS certificate handling issue could manifest as a `MalformedXML` error response, but I'm glad you resolved your problem. – kjhughes Mar 20 '16 at 17:15
  • I believe packets or ACKs are getting dropped due to the filtering, resulting in malformed XML. – Moshe Rubin Mar 20 '16 at 17:43
1

It can be found here: http://doc.s3.amazonaws.com/2006-03-01/AmazonS3.xsd
(See also http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingSOAPOperations.html)

wero
  • 32,544
  • 3
  • 59
  • 84
  • I failed to mention I'm using AWS Authentication Signature version 4, not version 2. Is this schema applicable to both signature versions? I ask this because I ran my XML and the schema through xmlvalidation.com and no relevant errors were returned. Could there be another schema for version 4? – Moshe Rubin Mar 20 '16 at 12:45
  • The signature version doesn't change the XML requirements. Please consider editing the question to add an [MCVE](http://stackoverflow.com/help/mcve). – Michael - sqlbot Mar 20 '16 at 14:22
  • @Michael-sqlbot The plot thickens . My program worked correctly until this morning, when I got the MalformedXML error response. After several consecutive reruns and subsequent MalformedXML failures lasting about an hour, now everything is back to normal, with no XML errors. Therefore an MCVE will be difficult to reproduce. Should it recur, I will most certainly whittle the problem down to a minimal Amazon S3 request. Nonetheless, it is worrying that the S3 server can be fickle, failing on something like this for no apparent reason. – Moshe Rubin Mar 20 '16 at 14:37