Don't understand how I get back the XML from the ASP AWSQuerySigner

62 views
Skip to first unread message

Dave B

unread,
Sep 16, 2009, 3:45:38 PM9/16/09
to SowaCS Consulting
Hi,

I have downloaded the ASP version of your query designer and it seems
to sign my queries perfectly.

Trouble is am having problems understanding how I get the XML back
from Amazon.

If I do a href too call your code, the browser ends of at the
AmazonAWS URL and all the XML is displayed perfectly.

If I call your code using MSXML2.ServerXMLHTTP (Get) and then looking
at the Response.Text, I see information but it doesn't make a lot of
sense. It's simular to what I see when I run the example link on your
site.

Any ideas ?

Dave

C Sowa

unread,
Sep 16, 2009, 4:48:39 PM9/16/09
to SowaCS Consulting
Are your results similar to what is generated by the code below ? If
not, could you post the request that you are sending, and the response
that you are getting ? You may also want to try the tool from
http://fiddler2.com to help with your debugging, if you aren't already
using that or some other tracing tool.


---------------------------
---------------------------


Dim strMethod
Dim strQuery
Dim xh

strMethod = "GET"
strQuery = "http://awsqs.no-ip.org/awsquerysigner_asp/
AWSQuerySigner.asp?EndpointUri=ecs.amazonaws.com/onca/
xml&ItemId=B000X9FLKM&Service=AWSECommerceService&AWSAccessKeyId=16GM21EYQRT6QQWW05G2&Operation=ItemLookup"

Set xh = WScript.CreateObject( "MSXML2.ServerXMLHTTP" )
xh.open strMethod, strQuery, false
xh.send
WScript.echo xh.responseText


---------------------------
Windows Script Host
---------------------------
<?xml version="1.0" encoding="UTF-8"?><ItemLookupResponse
xmlns="http://webservices.amazon.com/AWSECommerceService/
2005-10-05"><OperationRequest><HTTPHeaders><Header Name="UserAgent"
Value="Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)"></
Header></HTTPHeaders><RequestId>1SEJPKA9F77JSA9BCTFY</
RequestId><Arguments><Argument Name="ItemId" Value="B000X9FLKM"></
Argument><Argument Name="Service" Value="AWSECommerceService"></
Argument><Argument Name="Operation" Value="ItemLookup"></
Argument><Argument Name="Timestamp" Value="2009-09-16T20:41:59Z"></
Argument><Argument Name="Signature"
Value="hg0iEOUMYUc6bmJNYRA2Ib1wIiS0kLnlPnmgE1DNLqU="></
Argument><Argument Name="AWSAccessKeyId"
Value="16GM21EYQRT6QQWW05G2"></Argument><Argument Name="EndpointUri"
Value="ecs.amazonaws.com/onca/xml"></Argument></
Arguments><RequestProcessingTime>0.0126891136169434</
RequestProcessingTime></
OperationRequest><Items><Request><IsValid>True</
IsValid><ItemLookupRequest><ItemId>B000X9FLKM</ItemId></
ItemLookupRequest></Request><Item><ASIN>B000X9FLKM</
ASIN><DetailPageURL>http://www.amazon.com/Lord-Rings-Picture-
Theatrical-Editions/dp/B000X9FLKM%3FSubscriptionId
%3D16GM21EYQRT6QQWW05G2%26tag%3Dws%26linkCode%3Dxm2%26camp
%3D2025%26creative%3D165953%26creativeASIN%3DB000X9FLKM</
DetailPageURL><ItemAttributes><Actor>Elijah Wood</Actor><Actor>Viggo
Mortensen</Actor><Actor>Ian McKellen</Actor><Director>Peter Jackson</
Director><Manufacturer>New Line</Manufacturer><ProductGroup>DVD</
ProductGroup><Title>The Lord of the Rings: The Motion Picture Trilogy
(Theatrical Editions) [Blu-ray]</Title></ItemAttributes></Item></
Items></ItemLookupResponse>
---------------------------
OK
---------------------------

Dave B

unread,
Sep 16, 2009, 5:47:43 PM9/16/09
to SowaCS Consulting
Hi,

If I use -

objHTTP.open "GET","http://www.caniplay.co.uk/aws/awsquerysigner.asp?
Service=AWSECommerceService&AWSAccessKeyId=[my access key]
&Operation=ItemLookup&ItemId=B001SEQMWM&EndPointUri=ecs.amazonaws.co.uk/
onca/xml",false

I get -

89cbea4d-f4ff-461f-bc1f-
f7ecc911809f0.0334750000000000TrueNewShipASINAmazon1B001SEQMWMSmall1B001SEQMWMhttp://
www.amazon.co.uk/Call-Juarez-Bound-Blood-Xbox/dp/B001SEQMWM%3FSubscriptionId%3D1D8R6E6SRZVC0CFMJDG2%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB001SEQMWMUbisoftVideo
Games

If I just call awsquerysigner as above with a href, I got a proper XML
response displayed in the browser.

Dave

Dave B

unread,
Sep 16, 2009, 6:23:52 PM9/16/09
to SowaCS Consulting
Hi,

Think I have got it now, am never gonna get XML back, I presume it
will always be text and I have too go through it.

On the above text I replaced some of the %3D etc... for the correct
characters and it makes more sense.

I just presumed I would be getting back a full formed XML document.

Another slightly annoying thing comes up every now and again. Instead
of display the result I get a page that says -

Object Moved

Try clicking here.

If you click it takes you too the Amazon XML feed, not sure why that
happens every now and again though.

Dave

C Sowa

unread,
Sep 16, 2009, 8:26:52 PM9/16/09
to SowaCS Consulting
On Sep 16, 5:47 pm, Dave B <thedavebax...@gmail.com> wrote:
>
> I get -
>
> 89cbea4d-f4ff-461f-bc1f-
> f7ecc911809f0.0334750000000000TrueNewShipASINAmazon1B001SEQMWMSmall1B001SEQ­MWMhttp://www.amazon.co.uk/Call-Juarez-Bound-Blood-Xbox/dp/B001SEQMWM%3FSubscri...
> Games
>
> Dave


Have you tried using the objHTTP.responseXML property ? What it
*looks* like is happening is that you are getting is not
objHTTP.responseText, but instead objHTTP.responseXML.Text, which will
only return the (concatenated) text content of the XML document's
elements. If I use your example (but my signing service installation,
of course), I get:


---------------------------
Windows Script Host
---------------------------
1fdce979-db3a-458e-
bbcc-19cbe8b3cdde0.0181920000000000TrueNewShipASINAmazon1B001SEQMWMSmall1B001SEQMWMhttp://
www.amazon.co.uk/Call-Juarez-Bound-Blood-Xbox/dp/B001SEQMWM%3FSubscriptionId%3D16GM21EYQRT6QQWW05G2%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB001SEQMWMUbisoftVideo
GamesCall Of Juarez: Bound In Blood (Xbox 360)
---------------------------
OK
---------------------------


This is very close to what you are seeing in your own results. Have
you looked at the HTTP request & response with a trace tool ? This
could help you isolate exactly what is happening where.




On Sep 16, 6:23 pm, Dave B <thedavebax...@gmail.com> wrote:
>
> Another slightly annoying thing comes up every now and again. Instead
> of display the result I get a page that says -
>
> Object Moved
>
> Try clicking here.
>
> If you click it takes you too the Amazon XML feed, not sure why that
> happens every now and again though.
>
> Dave


The signing service approach relies on using an HTTP 302 redirect to
send the signed request to AWS. What you're seeing may be the result
of a failure of some piece of code or client software to follow the
redirect. Or, it could be a problem at Amazon's end. This is another
case where an HTTP tracing tool will help narrow down the issue. You
may want to see some of the items from this search:
http://www.google.com/search?q=serverxmlhttp+redirect . It does seem
odd that this happens only sporadically; perhaps the trace details
will help to identify a pattern.

You could try the techniques mentioned at
http://stackoverflow.com/questions/161343/how-do-i-prevent-serverxmlhttp-from-automatically-following-redirects-http-303-s
and http://support.microsoft.com/kb/308607 , i.e., using the
WinHttpRequest component directly, and see if the increase in control
that that gives you will help.

I'm really curious about this redirect issue. I'd be happy to look at
additional details if you want to provide them.

Dave B

unread,
Sep 17, 2009, 3:17:01 AM9/17/09
to SowaCS Consulting
Hi,

The objHTTP.responseXML property is always empty but the response.Text
has the info I posted above.

I will take a look at your other suggestions later, am in the UK and
have to goto my day job now so will be about 10 hours before I look at
it again.

What am actually trying todo is get reviews and the editorial review
for a video game but could really do with that in XML and the
response.text version of it doesn't seem to want to hold enough data,
it gets cut off half way through a review.

Too bring back the reviews I added
ResponseGroup=EditorialReview,Reviews to the end of my query and that
seemed to work but only in text not XML.


Thanks very much for taking the time too reply though.

Dave

C Sowa

unread,
Sep 17, 2009, 12:01:28 PM9/17/09
to SowaCS Consulting
What you're getting is what I'd expect if the XML text was embedded in
an HTML document, which is what I've done here:
http://awsqs.no-ip.org/awsquerysigner_asp/test01.asp . There seems to
be some MIME type confusion somewhere in the processing. Are there
any proxy servers anywhere ? Are the responseStream and responseBody
properties also stripped of XML markup ?

In any case, you are getting results from AWS/PAA, so the signing
service is working. I can only guess at what happens after that point
without more code and environment details.

Some of the techniques here may be of use:
http://stackoverflow.com/questions/1331303/parse-server-xmlhttp-youtube-response-with-asp-classic/1334393#1334393
.

Dave B

unread,
Sep 17, 2009, 2:20:21 PM9/17/09
to SowaCS Consulting
Hi,

http://awsqs.no-ip.org/awsquerysigner_asp/test01.asp is exactly what
am seeing in the browser when I run my query.

The environment am testing on is FireFox 3.5.2 on OSX 10.4.11

The Server that is hosting the ASP is Windows 2008 but I have no idea
on exact versions. It's running on www.cyberhostpro.com

I will spend some time on it now and post and findings.

Thanks,

Dave

Dave B

unread,
Sep 18, 2009, 10:02:24 PM9/18/09
to SowaCS Consulting
Hi,

I finally got it working.

Firstly the "Object has moved" error pops up if the XML Status is 302,
the status should be 200 for a normal response. This isn't related the
my problem or the stuff below but thought I would mention it.

Right I think the XML was coming back all the time but one thing I
didn't notice is that the first element (ItemLookupResponse) has a
name space attached to it.

As soon as I referenced the same NS in my XSLT file and used that
reference throughtout the file it all started working. I added
xmlns:aws="http://webservices.amazon.com/AWSECommerceService/
2005-10-05" and then all elements are referenced as aws:elementname.

I can't believe it was just that one line in the XML file causing me
all this hassle.

Thanks very much for firstly making the ASP signer and also helping me
with this problem.

Dave

C Sowa

unread,
Sep 19, 2009, 7:24:03 AM9/19/09
to SowaCS Consulting
Glad you got it working, and I'm glad I could be of some assistance.

Yes, it's always the little things that we get snagged on ;-)
Reply all
Reply to author
Forward
0 new messages