Hi,
I'm a novice developer, currently trying out the Amazon Webservices (www.amazon.com/webservices). A sample Amazon Client that I have found (
http://developers.sun.com/dev/edu/camps/demos/snc_web/download.html), generates a
RAW Soap response onto a browser, as shown below.
******************
Request
Content-Type: text/xml; charset="utf-8"
Content-Length: 956
SOAPAction: "http://soap.amazon.com"
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://soap.amazon.com" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><env:Body><ns0:KeywordSearchRequest><KeywordSearchRequest href="#ID1"/></ns0:KeywordSearchRequest><ns0:KeywordRequest id="ID1" xsi:type="ns0:KeywordRequest"><keyword xsi:type="xsd:string">cats</keyword><page xsi:type="xsd:string">1</page><mode xsi:type="xsd:string">books</mode><tag xsi:type="xsd:string">webservices-20</tag><type xsi:type="xsd:string">heavy</type><devtag xsi:type="xsd:string">D11ZG20ADM4S1A</devtag><sort xsi:type="xsd:string" xsi:nil="1"/><variations xsi:type="xsd:string" xsi:nil="1"/><locale xsi:type="xsd:string" xsi:nil="1"/></ns0:KeywordRequest></env:Body></env:Envelope>
Response
Content-Type: text/xml; charset="utf-8"
Content-Length: 956
SOAPAction: "http://soap.amazon.com" <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:amazon="http://soap.amazon.com"><SOAP-ENV:Body><namesp721:KeywordSearchRequestResponse xmlns:namesp721="http://soap.amazon.com"><return xsi:type="amazon
roductInfo"><TotalResults xsi:type="xsd:string">11518</TotalResults><TotalPages xsi:type="xsd:string">1152</TotalPages><Details SOAP-ENC:arrayType="amazon
etails[10]" xsi:type="SOAP-ENC:Array"><Details xsi:type="amazon
etails"><Url xsi:type="xsd:string">
http://www.amazon.com/exec/obidos/ASIN/039480001X/webservices-20?dev-t=D11ZG20ADM4S1A%26camp=2025%26link_code=sp1</Url><Asin xsi:type="xsd:string">039480001X</Asin><ProductName xsi:type="xsd:string">The Cat in the Hat</ProductName><Catalog xsi:type="xsd:string">Book</Catalog><Authors SOAP-ENC:arrayType
.......
Product xsi:type="xsd:string">0836217357</Product></SimilarProducts></Details></Details></return></namesp721:KeywordSearchRequestResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
****************** The
JSP code (KeywordSearchRequest_SOAP.jsp) that generates the above raw SOAP response is as follows:
<html>
<head>
<%@ page contentType="text/html; charset=UTF-8" %>
<title>KeywordSearchRequest</title>
</head>
<center><h2>KeywordSearchRequest</h2></center>
<%
boolean useProxy = false;
if (useProxy) {
System.setProperty("http.proxyHost", "proxy.ntu.edu.sg");
System.setProperty("http.proxyPort", "8080");
}
// Get our port interface
myamazonclient.AmazonClientGenClient.AmazonSearchService service = new myamazonclient.AmazonClientGenClient.AmazonSearchService_Impl();
myamazonclient.AmazonClientGenClient.AmazonSearchPort port = service.getAmazonSearchPort();
// Get the stub and set it to save the HTTP log.
myamazonclient.AmazonClientGenClient.AmazonSearchPort_Stub stub = (myamazonclient.AmazonClientGenClient.AmazonSearchPort_Stub) port;
java.io.ByteArrayOutputStream httpLog = new java.io.ByteArrayOutputStream();
stub._setTransportFactory(new com.sun.xml.rpc.client.http.HttpClientTransportFactory(httpLog));
// Get the end point address and save it for the error page.
String endPointAddress = (String) stub._getProperty(stub.ENDPOINT_ADDRESS_PROPERTY);
request.setAttribute("ENDPOINT_ADDRESS_PROPERTY", endPointAddress);
%>
<%
// Make it so that multibyte characters can be used
request.setCharacterEncoding("UTF-8");
// Get parameters
myamazonclient.AmazonClientGenClient.KeywordRequest p_keywordSearchRequest = new myamazonclient.AmazonClientGenClient.KeywordRequest();
if (!"".equals(request.getParameter("keywordSearchRequest.keyword")))
p_keywordSearchRequest.setKeyword(request.getParameter("keywordSearchRequest.keyword"));
if (!"".equals(request.getParameter("keywordSearchRequest.page")))
p_keywordSearchRequest.setPage(request.getParameter("keywordSearchRequest.page"));
if (!"".equals(request.getParameter("keywordSearchRequest.mode")))
p_keywordSearchRequest.setMode(request.getParameter("keywordSearchRequest.mode"));
if (!"".equals(request.getParameter("keywordSearchRequest.tag")))
p_keywordSearchRequest.setTag(request.getParameter("keywordSearchRequest.tag"));
if (!"".equals(request.getParameter("keywordSearchRequest.type")))
p_keywordSearchRequest.setType(request.getParameter("keywordSearchRequest.type"));
if (!"".equals(request.getParameter("keywordSearchRequest.devtag")))
p_keywordSearchRequest.setDevtag(request.getParameter("keywordSearchRequest.devtag"));
if (!"".equals(request.getParameter("keywordSearchRequest.sort")))
p_keywordSearchRequest.setSort(request.getParameter("keywordSearchRequest.sort"));
if (!"".equals(request.getParameter("keywordSearchRequest.locale")))
p_keywordSearchRequest.setLocale(request.getParameter("keywordSearchRequest.locale"));
if (!"".equals(request.getParameter("keywordSearchRequest.price")))
p_keywordSearchRequest.setPrice(request.getParameter("keywordSearchRequest.price"));
// Call the web service
myamazonclient.AmazonClientGenClient.ProductInfo result = port.keywordSearchRequest(p_keywordSearchRequest);
String httpLogString = httpLog.toString("UTF-8"); %>
<code>
<%
// Display the results
for (int ii = 0; ii < httpLogString.length(); ++ii) {
char c = httpLogString.charAt(ii);
if (c == '&') out.write("&");
else if (c == '<') out.write("<");
else if (c == '>') out.write(">");
else if (c == '\n') out.write("<br/>\n");
else out.write(c);
}
%>
</code>
</html>
I was wondering how to modify the JSP code (esp the JSP code bold,italic), so as to perform a XSLT on the information stored within the String "httpLogString".
Do I need to create an .xml file before performing XSLT with a XSL?
-- if yes, how do I create a .xml file which excludes the headers (Request, Response headers), astericks at beginning and end of the string "httpLogString", and SOAP tags such as xsi:type="xsd:string".
E.g.
<?xml version="1.0" encoding="UTF-8"?>
<ProductInfo>
<Details url="http://www.amazon.com/exec/obidos/ASIN/039480001X">
<Asin>039480001X</Asin>
<ProductName>The Cat in the Hat</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Seuss</Author>
<Author>Theodor Seuss Geisel</Author>
<Author>Dr. Seuss</Author>
</Authors>
<ReleaseDate>June 1957</ReleaseDate>
<Manufacturer>Random House</Manufacturer>
<ListPrice>$8.99</ListPrice>
<OurPrice>$8.99</OurPrice>
<UsedPrice>$6.95</UsedPrice>
<ImageUrlSmall>
http://images.amazon.com/images/P/039480001X.01.THUMBZZZ.jpg</ImageUrlSmall>
<ImageUrlMedium>
http://images.amazon.com/images/P/039480001X.01.MZZZZZZZ.jpg</ImageUrlMedium>
<ImageUrlLarge>
http://images.amazon.com/images/P/039480001X.01.LZZZZZZZ.jpg</ImageUrlLarge>
</Details>
</ProductInfo>
Or is it possible to simply perform a XSLT on the information stored within the String "httpLogString", without any coding. For example, modify XSL?
Sorry for the lengthy message. I was trying to make the point clear.
Thanks.