Author: channa Date: Sat Oct 18 02:14:01 2008 New Revision: 22552 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=22552
Log: completing the quick start guide. Added: trunk/mashup/java/xdocs/images/Currency_service_tryit.png (contents, props changed) trunk/mashup/java/xdocs/images/Currency_source.png (contents, props changed) trunk/mashup/java/xdocs/images/Editing_FeedDemo.png (contents, props changed) trunk/mashup/java/xdocs/images/Javascript_Stub_Generator.png (contents, props changed) trunk/mashup/java/xdocs/images/ScrapingAssistant_finish.png (contents, props changed) trunk/mashup/java/xdocs/images/Scraping_Assistant_result.png (contents, props changed) trunk/mashup/java/xdocs/images/Scraping_Assistant_start.png (contents, props changed) trunk/mashup/java/xdocs/images/TryIt_FeedDemo.png (contents, props changed) trunk/mashup/java/xdocs/images/helloworld_tryit_deft.png (contents, props changed) Removed: trunk/mashup/java/xdocs/images/mashup_details_hellow.png Modified: trunk/mashup/java/xdocs/images/helloworld_tryit.png trunk/mashup/java/xdocs/quickstart.html Added: trunk/mashup/java/xdocs/images/Currency_service_tryit.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/Currency_service_tryit.png?pathrev=22552 ============================================================================== Binary file. No diff available. Added: trunk/mashup/java/xdocs/images/Currency_source.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/Currency_source.png?pathrev=22552 ============================================================================== Binary file. No diff available. Added: trunk/mashup/java/xdocs/images/Editing_FeedDemo.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/Editing_FeedDemo.png?pathrev=22552 ============================================================================== Binary file. No diff available. Added: trunk/mashup/java/xdocs/images/Javascript_Stub_Generator.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/Javascript_Stub_Generator.png?pathrev=22552 ============================================================================== Binary file. No diff available. Added: trunk/mashup/java/xdocs/images/ScrapingAssistant_finish.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/ScrapingAssistant_finish.png?pathrev=22552 ============================================================================== Binary file. No diff available. Added: trunk/mashup/java/xdocs/images/Scraping_Assistant_result.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/Scraping_Assistant_result.png?pathrev=22552 ============================================================================== Binary file. No diff available. Added: trunk/mashup/java/xdocs/images/Scraping_Assistant_start.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/Scraping_Assistant_start.png?pathrev=22552 ============================================================================== Binary file. No diff available. Added: trunk/mashup/java/xdocs/images/TryIt_FeedDemo.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/TryIt_FeedDemo.png?pathrev=22552 ============================================================================== Binary file. No diff available. Modified: trunk/mashup/java/xdocs/images/helloworld_tryit.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/helloworld_tryit.png?rev=22552&r1=22551&r2=22552&view=diff ============================================================================== Binary files. No diff available. Added: trunk/mashup/java/xdocs/images/helloworld_tryit_deft.png URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/images/helloworld_tryit_deft.png?pathrev=22552 ============================================================================== Binary file. No diff available. Deleted: trunk/mashup/java/xdocs/images/mashup_details_hellow.png URL: http://wso2.org/svn/browse/wso2/None?pathrev=22551 Modified: trunk/mashup/java/xdocs/quickstart.html URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/xdocs/quickstart.html?rev=22552&r1=22551&r2=22552&view=diff ============================================================================== --- trunk/mashup/java/xdocs/quickstart.html (original) +++ trunk/mashup/java/xdocs/quickstart.html Sat Oct 18 02:14:01 2008 @@ -130,15 +130,15 @@ <p>Clicking on the name of the Mashup here will take you to the Mashup details page.</p> -<p><img alt="Mashup Details" src="images/mashup_details_hellow.png" -width="1007" height="513"></p> +<p><img alt="Mashup Details" src="images/helloworld_listing.png" width="1002" +height="996"></p> <p>Here you can start, stop, edit or delete the service using the options in the 'Management Tasks' pane. More importantly, you can try out your Service's single operation using the 'Try the Service' link.</p> -<p><img alt="TryIt HelloW" src="images/helloworld_tryit.png" height="300" -width="420"></p> +<p><img alt="TryIt HelloW" src="images/helloworld_tryit_deft.png" +height="300" width="420"></p> <p>If you get a response from the service when you try it, pat yourself on the back, you've written your first mashup!</p> @@ -146,9 +146,142 @@ <h2>Adding the Interesting Bits</h2> <p>Now that you've seen how easy it is to write a service, you can start on -getting it to actually do something. </p> +getting it to actually do something. The next few sections will show you how +to perform some actions that you can use as building blocks when creating +your own mashups.</p> +<br> -<p></p> + +<h3>Scraping a Web Page</h3> + +<p>While instructions for using the Scraper host object are included in the +user guide, this section shows you how to create a configuration file using +the 'Scraping Assistant', which is a tool that will help you write a scraper +configuration. </p> + +<p>The basic steps you need to follow to create a configuration that will get +the contents of a web page as an XML document would be:</p> + +<p>1) Open up the Scraper Tool, which will give you an empty config which we +will fill up.</p> + +<p><img alt="Scraping Assistant" +src="images/Scraping_Assistant_start.png"></p> + +<p>1) Add a line to retrieve a page available at a given URL, using the 'Add +HTTP request' menu option, which will insert the single line below into the +config:</p> + +<p><http url="url-to-fetch" method="post"/></p> + +<p>Replace the url-to-fetch with the URL of the page you want to fetch.</p> + +<p>2) Add instructions to convert this HTML to XML, by selecting the previous +line and the using 'Convert HTML to XML' menu option, which will surrounding +the above statement with this pair of tags:</p> + +<p><html-to-xml outputtype="pretty"></p> + +<p></html-to-xml></p> + +<p>3) Add instructions to put the result into a variable, which you can +access from your JavaScript mashup, by using the 'Convert to Variable' menu +option with the existing code block selected. This will surround the existing +code with the following:</p> + +<p><var-def name="variable_1"></p> + +<p></var-def></p> + +<p>Optionally, use a variable name that has some semantic value, to arrive at +a completed configuration as shown below.</p> + +<p><img alt="Finish" src="images/ScrapingAssistant_finish.png" width="513" +height="150"></p> + +<p>4) Now you have a scraper configuration that you can use in a mashup. +Paste it into your script and use it as shown below:</p> + +<p class="Code">function getString(){<br> +var config =<br> +<config><br> +<var-def name="response"><br> +<html-to-xml outputtype="pretty"><br> +<http url="http://wso2.org/projects/mashup" method="post"/><br> +</html-to-xml><br> +</var-def><br> +</config><br> +var scraper = new Scraper(config);<br> +var result = scraper.response;<br> +return result;<br> +}</p> + +<p>Use 'tryit to' test the operation; you should see the page content +displayed as the response. </p> + +<p><img alt="Result" src="images/Scraping_Assistant_result.png" width="1524" +height="271"></p> + +<p>You can now modify your configuration to filter out the information you +don't need from this page, or use logic within your mashup itself to extract +the bits you need.</p> +<br> + + +<h3>Accessing an External Web Service</h3> + +<p>The easiest way to access a web service hosted externally would be to +generate a stub for this service and include it in your mashup.</p> + +<p>1) Open up the 'JavaScript Stub Generator', paste the URL to the WSDL of +the service you want to access in the correct input field, select the +environment you will use it in (E4X) and select 'Generate from URL' to have +the stub code generated for you as shown below.</p> + +<p><img alt="Stub Generator" src="images/Javascript_Stub_Generator.png" +width="1017" height="778"></p> + +<p>2) Create a new Mashup, say 'Currency' and save it. You will find a +Currency.resources directory created in your personal scripts directory. +Create a new text file here for the stub and paste the generated code in it. +I've called it 'convertor.stub.js'.</p> + +<p>3) Edit the mashup and include an import statement to bring in your stub. +</p> + +<p><img alt="Source" src="images/Currency_source.png" width="611" +height="167"></p> + +<p>4) Call the Service.operation using the stub, to get the result shown +below:</p> + +<p><img alt="Tryit" src="images/Currency_service_tryit.png" width="705" +height="148"></p> +<br> + + +<h3>Reading a Feed</h3> + +<p>1) With the three lines of code shown below, you can get all the entries +of a given feed into an array. </p> + +<p class="Code">var feedReader = new FeedReader();<br> +var myFeed = feedReader.get(“feed-url”); <br> +var feedEntries = myFeed.getEntries();<br> +</p> + +<p>2) This can then be processed in a simple for-next loop as shown below.</p> + +<p><img alt="Feed Edit" src="images/Editing_FeedDemo.png" width="480" +height="315"></p> + +<p>3) It will return the contents of the feed as a string, as shown when +tried below.</p> + +<p><img alt="Try Feed" src="images/TryIt_FeedDemo.png" width="1535" +height="250">That concludes the 'Quick Start Guide'. Please refer to mashup +articles on the <a href="https://wso2.org/taxonomy/term/303/all">Oxygen Tank</a>, in addition to the samples and documentation +included with the product, for more on creating Mashups.</p> </div> <div id="main-content1"> _______________________________________________ Mashup-dev mailing list [email protected] http://mailman.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
