<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CEANSHw5eCp7ImA9WhBaEU8.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887</id><updated>2013-05-21T09:53:19.220+02:00</updated><category term="Activity" /><category term="body movement" /><category term="Queue" /><category term="decision tree" /><category term="Service" /><category term="android" /><category term="business" /><category term="data mining" /><category term="client" /><category term="Ethernet Shield" /><category term="neo4j" /><category term="acceleration" /><category term="concept" /><category term="churn" /><category term=".net json google location api mobile cellID base station" /><category term="inductive programming" /><category term="Netduino" /><category term="SD Card" /><category term=".net wcf android rest json" /><category term="architecture" /><title>My Pet Projects</title><subtitle type="html">Software Development Blog</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://mypetprojects.blogspot.com/" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/MyPetProjects" /><feedburner:info uri="mypetprojects" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;D04HQX44cSp7ImA9WhVaE0k.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-8268067267756124122</id><published>2012-06-10T18:31:00.001+02:00</published><updated>2012-06-10T18:32:10.039+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-10T18:32:10.039+02:00</app:edited><title>neo4j: Using Cypher Query Language with .NET</title><content type="html">&lt;br /&gt;
After reading the neo4j REST documentation I've created&amp;nbsp;&amp;nbsp;JSONCypherQuery class with&amp;nbsp;some custom methods in&amp;nbsp;in order to use custom Cypher queries in .NET application.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;







Creating Classes for Serialization&lt;/h2&gt;
&lt;br /&gt;
Below is an example request and response from ne04j &lt;a href="http://docs.neo4j.org/chunked/snapshot/rest-api-cypher.html"&gt;REST API documentation&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: 'Lucida Bright', Cambria, serif; font-size: 0.9375em; line-height: 1.6em; margin-bottom: 1em; max-width: 45em;"&gt;
&lt;span class="emphasis"&gt;&lt;em&gt;Example request&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="itemizedlist" style="font-family: 'Lucida Bright', Cambria, serif; line-height: 19px; margin: 0px;"&gt;
&lt;ul class="itemizedlist" style="line-height: 1.2; list-style-position: outside; margin-bottom: 1em; margin-top: 0px; max-width: 38em;" type="disc"&gt;
&lt;li class="listitem" style="font-size: 0.9375em; line-height: 1.3em; margin-left: -0.8em; margin-top: 0.5em;"&gt;&lt;span class="strong" style="font-weight: bold;"&gt;&lt;strong&gt;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;POST&lt;/code&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;http://localhost:7474/db/data/cypher&lt;/code&gt;&lt;/li&gt;
&lt;li class="listitem" style="font-size: 0.9375em; line-height: 1.3em; margin-left: -0.8em; margin-top: 0.5em;"&gt;&lt;span class="strong" style="font-weight: bold;"&gt;&lt;strong&gt;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;Accept:&lt;/code&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;application/json&lt;/code&gt;&lt;/li&gt;
&lt;li class="listitem" style="font-size: 0.9375em; line-height: 1.3em; margin-left: -0.8em; margin-top: 0.5em;"&gt;&lt;span class="strong" style="font-weight: bold;"&gt;&lt;strong&gt;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;Content-Type:&lt;/code&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;application/json&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="font-family: 'Lucida Bright', Cambria, serif; line-height: 19px; margin: 0px;"&gt;
&lt;div class="syntaxhighlighter nogutter  javascript" id="highlighter_671690" style="background-color: white !important; font-size: 1em !important; margin: 1em 0px !important; overflow: auto !important; position: relative !important; width: 800px;"&gt;
&lt;table border="0" cellpadding="0" cellspacing="0" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px !important; height: auto !important; left: auto !important; line-height: 18px !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 800px;"&gt;&lt;tbody style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="code" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 800px;"&gt;&lt;div class="container" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;div class="line number1 index0 alt2" style="background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;"&gt;
&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;{&lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"query"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;: &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"start x&amp;nbsp; = node(27) match x -[r]-&amp;gt; n return type(r), n.name?, n.age?"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;,&lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"params"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;: {}},&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="font-family: 'Lucida Bright', Cambria, serif; font-size: 0.9375em; line-height: 1.6em; margin-bottom: 1em; max-width: 45em;"&gt;
&lt;span class="emphasis"&gt;&lt;em&gt;Example response&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="itemizedlist" style="font-family: 'Lucida Bright', Cambria, serif; line-height: 19px; margin: 0px;"&gt;
&lt;ul class="itemizedlist" style="line-height: 1.2; list-style-position: outside; margin-bottom: 1em; margin-top: 0px; max-width: 38em;" type="disc"&gt;
&lt;li class="listitem" style="font-size: 0.9375em; line-height: 1.3em; margin-left: -0.8em; margin-top: 0.5em;"&gt;&lt;span class="strong" style="font-weight: bold;"&gt;&lt;strong&gt;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;200:&lt;/code&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;OK&lt;/code&gt;&lt;/li&gt;
&lt;li class="listitem" style="font-size: 0.9375em; line-height: 1.3em; margin-left: -0.8em; margin-top: 0.5em;"&gt;&lt;span class="strong" style="font-weight: bold;"&gt;&lt;strong&gt;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;Content-Type:&lt;/code&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;code class="literal" style="color: navy; font-family: Consolas, Monaco, monospace; font-size: 0.9375em;"&gt;application/json&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style="font-family: 'Lucida Bright', Cambria, serif; line-height: 19px; margin: 0px;"&gt;
&lt;div class="syntaxhighlighter nogutter  javascript" id="highlighter_162514" style="background-color: white !important; font-size: 1em !important; margin: 1em 0px !important; overflow: auto !important; position: relative !important; width: 800px;"&gt;
&lt;table border="0" cellpadding="0" cellspacing="0" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px !important; height: auto !important; left: auto !important; line-height: 18px !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 800px;"&gt;&lt;tbody style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="code" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 800px;"&gt;&lt;div class="container" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;div class="line number1 index0 alt2" style="background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;"&gt;
&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class="line number2 index1 alt1" style="background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;"&gt;
&lt;code class="javascript spaces" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"data"&lt;/code&gt; &lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;: [ [ &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"know"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;, &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"him"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;, 25 ], [ &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"know"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;, &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"you"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;, &lt;/code&gt;&lt;code class="javascript keyword" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(127, 0, 85) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;null&lt;/code&gt; &lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;] ],&lt;/code&gt;&lt;/div&gt;
&lt;div class="line number3 index2 alt2" style="background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;"&gt;
&lt;code class="javascript spaces" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"columns"&lt;/code&gt; &lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;: [ &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"type(r)"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;, &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"n.name?"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;, &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;"n.age?"&lt;/code&gt; &lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;]&lt;/code&gt;&lt;/div&gt;
&lt;div class="line number4 index3 alt1" style="background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;"&gt;
&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; height: auto !important; left: auto !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
To create a request string formatted the same way as&lt;br /&gt;
&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; white-space: pre; width: auto !important;"&gt;{&lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; white-space: pre; width: auto !important;"&gt;"query"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; white-space: pre; width: auto !important;"&gt;: &lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; white-space: pre; width: auto !important;"&gt;"start x&amp;nbsp; = node(27) match x -[r]-&amp;gt; n return type(r), n.name?, n.age?"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; white-space: pre; width: auto !important;"&gt;,&lt;/code&gt;&lt;code class="javascript string" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(42, 0, 255) !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; white-space: pre; width: auto !important;"&gt;"params"&lt;/code&gt;&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; white-space: pre; width: auto !important;"&gt;: {}},&lt;/code&gt;
&lt;br /&gt;
&lt;code class="javascript plain" style="background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace !important; font-size: 14px; height: auto !important; left: auto !important; line-height: 18px; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left; top: auto !important; vertical-align: baseline !important; white-space: pre; width: auto !important;"&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-size: 14px; line-height: 18px; white-space: pre;"&gt;&lt;span style="font-family: inherit;"&gt;we can create a class&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', monospace;"&gt;&lt;span style="font-size: 14px; line-height: 18px; white-space: pre;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;code&gt;
class JSONQueryCommand&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [JsonProperty("query")]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public string Query { get; set; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [JsonProperty("params")]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public string Parameters { get; set; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
and method which posts a request and gets a response as string.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;







Handling Requests and Responses&lt;/h2&gt;
&lt;div&gt;
The method below transforms the Cypher query string into appropriate web request:&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
private static string CreateRequest(string query)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string response = "";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Connect&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //http://localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; req.Method = "POST";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; req.ContentType = "application/json";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string parameters = null;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JSONQueryCommand cmd = new JSONQueryCommand();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.Query = query;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.Parameters = parameters;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string json = JsonConvert.SerializeObject(cmd);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (var streamWriter = new StreamWriter(req.GetRequestStream()))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; streamWriter.Write(json);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var httpResponse = (HttpWebResponse)req.GetResponse();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var responseText = streamReader.ReadToEnd();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response = responseText;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Now you have your response.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //or false depending on information in the response &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception ex)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return response;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
In order to handle the received string and extract the data we need additional methods. Below is the simple method that extracts scalar value:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public static object GetScalar(string request)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string response = CreateRequest(request);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var joResponse = JObject.Parse(response);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var jaData = (JArray)joResponse["data"];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var dataArray = jaData.First();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var firstDataElement = dataArray.First();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JValue jResult = (JValue)firstDataElement;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; object result = jResult.Value;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return result;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;h2&gt;







Example&lt;/h2&gt;
After creating these methods we can simply use custom Cypher queries.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
object response = JSONCypherQuery.GetScalar("start a = node(1) MATCH (a)--(b) return count(b);");&lt;br /&gt;
int neighborsCount= Convert.ToInt32(response);&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;
The code block&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
&amp;nbsp;req.Method = "POST";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; req.ContentType = "application/json";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string parameters = null;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JSONQueryCommand cmd = new JSONQueryCommand();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.Query = query;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.Parameters = parameters;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string json = JsonConvert.SerializeObject(cmd);&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;
creates a web rquest with content&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
{"query":"start a = node(1) MATCH (a)--(b) return count(b);","params":null}&lt;br /&gt;
&lt;br /&gt;
&lt;/code&gt;
which is sent to server and if we know what kind of data are we expecting to receive from server, we can create an appropriate parsing/deserializing method. For the example query the result is scalar and the method GetScalar extracts it from response string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/4zRkUc6EWzs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/8268067267756124122/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2012/06/neo4j-using-cypher-query-language-with.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/8268067267756124122?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/8268067267756124122?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/4zRkUc6EWzs/neo4j-using-cypher-query-language-with.html" title="neo4j: Using Cypher Query Language with .NET" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2012/06/neo4j-using-cypher-query-language-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUICRno5eyp7ImA9WhVaE0k.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-9207995418218018983</id><published>2012-06-10T15:23:00.000+02:00</published><updated>2012-06-10T17:52:47.423+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-10T17:52:47.423+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="neo4j" /><title>Social Network Analysis with neo4j: Graphs</title><content type="html">I have been analyzing social networks and recently switched the database from standard relational to neo4j. The latter is much more appropriate for working with graphs and some basic insights about nodes and edges can be calculated in an instant.&lt;br /&gt;
&lt;br /&gt;
The difference is obvious while dealing with big dataset. Below is an example SQL query for retrieving all connections among users in selected distance:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
with recursive cluster (party, path, depth)&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;as (
                              select cast(@userId as character varying), cast(@userId as character varying), 1&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;union&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;(&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;select (case&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;when this.party = amc.userA then amc.userB&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;when this.party = amc.userB then amc.userA&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;end), (this.path || '.' || (case&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;when this.party = amc.userA then amc.userB&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;when this.party = amc.userB then amc.userA&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;end)), this.depth + 1&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;from cluster this, chat amc&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;where ((this.party = amc.userA and position(amc.userB in this.path) = 0)&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;or (this.party = amc.userB and position(amc.userA in this.path) = 0)) AND this.depth &amp;lt; @depth + 1
                              )
                            )&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;select party, path&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;from cluster&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;where not exists (&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;select *&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;from cluster c2
                              where cluster.party = c2.party&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;and (&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;char_length(cluster.path) &amp;gt; char_length(c2.path)&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;or (char_length(cluster.path) = char_length(c2.path)) and (cluster.path &amp;gt; c2.path)&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;)&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;)&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;order by party, path;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Running such query on database with several million users and connections takes very long time (talking in hours on proprietary PC).&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-Xjw3EntKC7I/T9SjeMdLKiI/AAAAAAAAAlA/e9Q1e-V3_NY/s1600/22EEA5F381F403B41E6A8F8EEBB9432812283146-big.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/-Xjw3EntKC7I/T9SjeMdLKiI/AAAAAAAAAlA/e9Q1e-V3_NY/s320/22EEA5F381F403B41E6A8F8EEBB9432812283146-big.png" width="311" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Below is the Cypher query for neo4j database which counts all friends of friends (equivalent to above one in case of depth = 2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;neo4j-sh (0)$ start b = node:User(UserId='9F56478E6CAFB9CFF8C720C5DFC392C49495C582') MATCH (b) --(friend)--(friendoffriend) RETURN count(friendoffriend)&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;==&amp;gt; +-----------------------+&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;==&amp;gt; | count(friendoffriend) |&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;==&amp;gt; +-----------------------+&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;==&amp;gt; | 131457 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;==&amp;gt; +-----------------------+&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;==&amp;gt; 1 row, 635 ms&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The advantage in performance and simplicity is obvious.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;










&lt;a href="http://console.neo4j.org/?init=(A)%0A(B)%0A(C)%0A(D)%0A(E)%0A(F)%0A(G)%0A(0)-%5B%3AROOT%5D-%3E(A)%0A(A)-%5B%3AKNOWS%5D-%3E(B)%0A(A)-%5B%3AKNOWS%5D-%3E(C)%0A(A)-%5B%3AKNOWS%5D-%3E(D)%0A(A)-%5B%3AKNOWS%5D-%3E(E)%0A(B)-%5B%3AKNOWS%5D-%3E(F)%0A(B)-%5B%3AKNOWS%5D-%3E(G)%0A(C)-%5B%3AKNOWS%5D-%3E(D)%0A(E)-%5B%3AKNOWS%5D-%3E(F)&amp;amp;query=start%20a%3Dnode(1)%20match%20a-%5Br%3F%5D-other%20return%20a%2Ctype(r)%2C%20other%0A&amp;amp;version="&gt;Running queries in neo4j console&lt;/a&gt;&lt;/h2&gt;
&lt;br /&gt;
&lt;br /&gt;
Below are some more example Cypher queries for working with graphs. you can try out these and other on simple example network on&lt;a href="http://console.neo4j.org/?init=(A)%0A(B)%0A(C)%0A(D)%0A(E)%0A(F)%0A(G)%0A(0)-%5B%3AROOT%5D-%3E(A)%0A(A)-%5B%3AKNOWS%5D-%3E(B)%0A(A)-%5B%3AKNOWS%5D-%3E(C)%0A(A)-%5B%3AKNOWS%5D-%3E(D)%0A(A)-%5B%3AKNOWS%5D-%3E(E)%0A(B)-%5B%3AKNOWS%5D-%3E(F)%0A(B)-%5B%3AKNOWS%5D-%3E(G)%0A(C)-%5B%3AKNOWS%5D-%3E(D)%0A(E)-%5B%3AKNOWS%5D-%3E(F)&amp;amp;query=start%20a%3Dnode(1)%20match%20a-%5Br%3F%5D-other%20return%20a%2Ctype(r)%2C%20other%0A&amp;amp;version="&gt; this website.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/--j5tI-eRi_k/T9TCfU5WOII/AAAAAAAAAlM/5QUZeYd2wk0/s1600/neo4jConsoleExample.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="304" src="http://2.bp.blogspot.com/--j5tI-eRi_k/T9TCfU5WOII/AAAAAAAAAlM/5QUZeYd2wk0/s320/neo4jConsoleExample.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Graph Screenshot from neo4j Console&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Find Neighbors&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
start a=node(*)&lt;br /&gt;
match (a)--&amp;gt;(b)&lt;br /&gt;
return a, b;&lt;br /&gt;
&lt;code&gt;
+-----------------------+&lt;br /&gt;
| a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | b &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-----------------------+&lt;br /&gt;
| Node[0]{} | Node[1]{} |&lt;br /&gt;
| Node[1]{} | Node[2]{} |&lt;br /&gt;
| Node[1]{} | Node[3]{} |&lt;br /&gt;
| Node[1]{} | Node[4]{} |&lt;br /&gt;
| Node[1]{} | Node[5]{} |&lt;br /&gt;
| Node[2]{} | Node[6]{} |&lt;br /&gt;
| Node[2]{} | Node[7]{} |&lt;br /&gt;
| Node[3]{} | Node[4]{} |&lt;br /&gt;
| Node[5]{} | Node[6]{} |&lt;br /&gt;
+-----------------------+&lt;br /&gt;
9 rows&lt;br /&gt;
0 ms&lt;br /&gt;
&lt;br /&gt;
&lt;/code&gt;&lt;b&gt;
Find Mutual Connections&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
start a=node(*), b=node(*)&lt;br /&gt;
match (a)--(x)--(b)&lt;br /&gt;
return a, b, x&lt;br /&gt;
+-----------------------------------+&lt;br /&gt;
| a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | b &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-----------------------------------+&lt;br /&gt;
| Node[0]{} | Node[2]{} | Node[1]{} |&lt;br /&gt;
| Node[0]{} | Node[3]{} | Node[1]{} |&lt;br /&gt;
| Node[0]{} | Node[4]{} | Node[1]{} |&lt;br /&gt;
| Node[0]{} | Node[5]{} | Node[1]{} |&lt;br /&gt;
| Node[1]{} | Node[3]{} | Node[4]{} |&lt;br /&gt;
| Node[1]{} | Node[4]{} | Node[3]{} |&lt;br /&gt;
| Node[1]{} | Node[6]{} | Node[2]{} |&lt;br /&gt;
| Node[1]{} | Node[6]{} | Node[5]{} |&lt;br /&gt;
| Node[1]{} | Node[7]{} | Node[2]{} |&lt;br /&gt;
| Node[2]{} | Node[0]{} | Node[1]{} |&lt;br /&gt;
| Node[2]{} | Node[3]{} | Node[1]{} |&lt;br /&gt;
| Node[2]{} | Node[4]{} | Node[1]{} |&lt;br /&gt;
| Node[2]{} | Node[5]{} | Node[6]{} |&lt;br /&gt;
| Node[2]{} | Node[5]{} | Node[1]{} |&lt;br /&gt;
| Node[3]{} | Node[0]{} | Node[1]{} |&lt;br /&gt;
| Node[3]{} | Node[1]{} | Node[4]{} |&lt;br /&gt;
| Node[3]{} | Node[2]{} | Node[1]{} |&lt;br /&gt;
| Node[3]{} | Node[4]{} | Node[1]{} |&lt;br /&gt;
| Node[3]{} | Node[5]{} | Node[1]{} |&lt;br /&gt;
| Node[4]{} | Node[0]{} | Node[1]{} |&lt;br /&gt;
| Node[4]{} | Node[1]{} | Node[3]{} |&lt;br /&gt;
| Node[4]{} | Node[2]{} | Node[1]{} |&lt;br /&gt;
| Node[4]{} | Node[3]{} | Node[1]{} |&lt;br /&gt;
| Node[4]{} | Node[5]{} | Node[1]{} |&lt;br /&gt;
| Node[5]{} | Node[0]{} | Node[1]{} |&lt;br /&gt;
| Node[5]{} | Node[2]{} | Node[6]{} |&lt;br /&gt;
| Node[5]{} | Node[2]{} | Node[1]{} |&lt;br /&gt;
| Node[5]{} | Node[3]{} | Node[1]{} |&lt;br /&gt;
| Node[5]{} | Node[4]{} | Node[1]{} |&lt;br /&gt;
| Node[6]{} | Node[1]{} | Node[2]{} |&lt;br /&gt;
| Node[6]{} | Node[1]{} | Node[5]{} |&lt;br /&gt;
| Node[6]{} | Node[7]{} | Node[2]{} |&lt;br /&gt;
| Node[7]{} | Node[1]{} | Node[2]{} |&lt;br /&gt;
| Node[7]{} | Node[6]{} | Node[2]{} |&lt;br /&gt;
+-----------------------------------+&lt;br /&gt;
34 rows&lt;br /&gt;
0 ms&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;b&gt;Count Mutual Connections&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
start a=node(*), b=node(*)&lt;br /&gt;
match (a)--(x)--(b)&lt;br /&gt;
where id(a) &amp;lt; id(b)&lt;br /&gt;
return a, b, count(distinct x)&lt;br /&gt;
+-------------------------------------------+&lt;br /&gt;
| a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | b &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | count(distinct x) |&lt;br /&gt;
+-------------------------------------------+&lt;br /&gt;
| Node[0]{} | Node[5]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[2]{} | Node[5]{} | 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[3]{} | Node[4]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[6]{} | Node[7]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[1]{} | Node[4]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[0]{} | Node[3]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[4]{} | Node[5]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[1]{} | Node[6]{} | 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[0]{} | Node[4]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[1]{} | Node[7]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[0]{} | Node[2]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[1]{} | Node[3]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[2]{} | Node[3]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[2]{} | Node[4]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| Node[3]{} | Node[5]{} | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-------------------------------------------+&lt;br /&gt;
15 rows&lt;br /&gt;
0 ms&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;b&gt;Calculate Clustering Coefficient&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
start a = node(1) &lt;br /&gt;
match (a)--(b) &lt;br /&gt;
with a, b as neighbours &lt;br /&gt;
match (a)--()-[r]-()--(a)&lt;br /&gt;
where id(a) &amp;lt;&amp;gt; id(neighbours) and id(neighbours) &amp;lt;&amp;gt; 0 &lt;br /&gt;
return count(distinct neighbours), count(distinct r)&lt;br /&gt;
+------------------------------------------------+&lt;br /&gt;
| count(distinct neighbours) | count(distinct r) |&lt;br /&gt;
+------------------------------------------------+&lt;br /&gt;
| 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+------------------------------------------------+&lt;br /&gt;
1 row&lt;br /&gt;
0 ms&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
The clustering coefficient of a selected node is defined as probability that two randomly selected neighbors are connected to each other. So once having number of neighbors and number of mutual connections we can calculate:&lt;br /&gt;
&lt;br /&gt;
1. The number of possible connections between two neighbors = n!/(2!(n-2)!) = 4!/(2!(4-2)!) = 24/4 = 6&lt;br /&gt;
where n is the number of neighbors n = 4&lt;br /&gt;
&lt;br /&gt;
and the actual number of connections is 1,&lt;br /&gt;
&lt;br /&gt;
therefore the clustering coefficient of node 1 is 1/6&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;References&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://docs.neo4j.org/chunked/1.7/cypher-query-lang.html"&gt;Cypher Query Language&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;big&gt;&lt;big&gt;&lt;span style="font-size: small;"&gt;Networks, Crowds, and Markets:&lt;/span&gt;&amp;nbsp;&lt;/big&gt;&lt;/big&gt;Reasoning About a Highly Connected World&amp;nbsp;&lt;span style="background-color: white; font-family: 'Lucida Grande'; text-align: -webkit-center;"&gt;By&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.arts.cornell.edu/econ/deasley/" style="color: blue; font-family: 'Lucida Grande'; text-align: -webkit-center; text-decoration: none;"&gt;David Easley&lt;/a&gt;&lt;span style="background-color: white; font-family: 'Lucida Grande'; text-align: -webkit-center;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; font-family: 'Lucida Grande'; text-align: -webkit-center;"&gt;and&lt;/span&gt;&lt;span style="background-color: white; font-family: 'Lucida Grande'; text-align: -webkit-center;"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.cs.cornell.edu/home/kleinber/" style="color: blue; font-family: 'Lucida Grande'; text-align: -webkit-center; text-decoration: none;"&gt;Jon Kleinberg&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/bPM_fXyfoNo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/9207995418218018983/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2012/06/social-network-analysis-with-neo4j.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/9207995418218018983?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/9207995418218018983?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/bPM_fXyfoNo/social-network-analysis-with-neo4j.html" title="Social Network Analysis with neo4j: Graphs" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-Xjw3EntKC7I/T9SjeMdLKiI/AAAAAAAAAlA/e9Q1e-V3_NY/s72-c/22EEA5F381F403B41E6A8F8EEBB9432812283146-big.png" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2012/06/social-network-analysis-with-neo4j.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYAQ3g9eyp7ImA9WhVaEks.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-8077480834158713435</id><published>2012-06-09T19:32:00.000+02:00</published><updated>2012-06-09T19:32:22.663+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-09T19:32:22.663+02:00</app:edited><title>neo4j: Creating .NET REST API</title><content type="html">After spending several days trying to implement some of the existing &lt;a href="http://neo4j.org/"&gt;neo4j&lt;/a&gt; libraries for .NET without success, I've decided to create a library on my own.&lt;br /&gt;
&lt;br /&gt;
Personally I prefer Cypher query language over Gremlin so I went through official neo4j documentation and started with development of REST client, based on Newtonsoft.NET.&lt;br /&gt;
&lt;br /&gt;
Below is the code for adding node to index:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
public string AddNodeToIndex(int nodeReference, string key, string value, string indexName)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string response = "";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JSONAddNodeToIndex jsonObj = new JSONAddNodeToIndex();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jsonObj.Uri = "http://localhost:7474/db/data/node/" + nodeReference.ToString();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jsonObj.Value = value;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jsonObj.Key = key;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string json = JsonConvert.SerializeObject(jsonObj);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //index name:favorites : ttp://localhost:7474/db/data/index/node/favorites&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost:7474/db/data/index/node/" + indexName);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; req.Method = "POST";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; req.ContentType = "application/json";&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (var streamWriter = new StreamWriter(req.GetRequestStream()))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; streamWriter.Write(json);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var httpResponse = (HttpWebResponse)req.GetResponse();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var responseText = streamReader.ReadToEnd();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response = responseText; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return response;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;
Hopefully soon there will be more code clean enough to share.&lt;span style="font-family: monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/rk5UOqF_-qM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/8077480834158713435/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2012/06/neo4j-creating-net-rest-api.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/8077480834158713435?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/8077480834158713435?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/rk5UOqF_-qM/neo4j-creating-net-rest-api.html" title="neo4j: Creating .NET REST API" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2012/06/neo4j-creating-net-rest-api.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYFQn44fip7ImA9WhVXF0g.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-5954330172379152069</id><published>2012-04-18T15:35:00.000+02:00</published><updated>2012-04-18T15:35:13.036+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-18T15:35:13.036+02:00</app:edited><title>Detecting Influential Figures During the General Strike of the Public Sector in Slovenia</title><content type="html">Creating a program that captures all the tweets that contain the selected keyword or hashtag I was able to retrieve the tweets about the General Public Strike in Slovenia.&lt;br /&gt;
&lt;br /&gt;
By using Gephi I speeded up the sequence of posts for the last two days and recorded the evolution of social network. Once having all the data it is possible to detect the most influential people and communities as well.&lt;br /&gt;
&lt;br /&gt;
Here is the snapshot of the network, created in last two days: &lt;a href="http://pdfcast.org/pdf/public-strike-on-twitter" target="_blank" title="Public Strike on Twitter (pdf)"&gt;Public Strike on Twitter&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object width="320" height="266" class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://i.ytimg.com/vi/vE9p7GS6z_k/0.jpg"&gt;&lt;param name="movie" value="http://www.youtube.com/v/vE9p7GS6z_k?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata" /&gt;
&lt;param name="bgcolor" value="#FFFFFF" /&gt;
&lt;embed width="320" height="266"  src="http://www.youtube.com/v/vE9p7GS6z_k?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp; 
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-r_fM5RnC1oM/T47CzBfYhhI/AAAAAAAAAiE/-mzs4Uv8XpI/s1600/application-snapshot.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="193" src="http://3.bp.blogspot.com/-r_fM5RnC1oM/T47CzBfYhhI/AAAAAAAAAiE/-mzs4Uv8XpI/s320/application-snapshot.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/TJOaKOHMmHY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/5954330172379152069/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2012/04/detecting-influential-figures-during.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/5954330172379152069?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/5954330172379152069?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/TJOaKOHMmHY/detecting-influential-figures-during.html" title="Detecting Influential Figures During the General Strike of the Public Sector in Slovenia" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-r_fM5RnC1oM/T47CzBfYhhI/AAAAAAAAAiE/-mzs4Uv8XpI/s72-c/application-snapshot.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2012/04/detecting-influential-figures-during.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUICRXc4cCp7ImA9WhdaFkw.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-3867270438629626909</id><published>2011-10-23T11:40:00.011+02:00</published><updated>2011-10-26T10:26:04.938+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-26T10:26:04.938+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SD Card" /><category scheme="http://www.blogger.com/atom/ns#" term="Ethernet Shield" /><category scheme="http://www.blogger.com/atom/ns#" term="Netduino" /><title>Netduino: Using Ethernet Shield to Read/Write to SD Card</title><content type="html">After successfully running a program that writes a file to SD card and then reads the content I've decided to summarize all the steps required in order to use Netduino with Ethernet Shield and SD card.&lt;br /&gt;&lt;br /&gt;First, you have to upgrade the firmware (I used v4.1.1.0 Beta 1 which can be found &lt;a href="http://forums.netduino.com/index.php?showtopic=1592"&gt;here&lt;/a&gt;. The detailed instructions about firmware upgrade are available at the same address.&lt;br /&gt;&lt;br /&gt;Next, you have to solder ICSP pin on your Netduino board and connect D4 with D10 with jumper wire as it is shown on pictures below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/-mJGEz1eqwN8/TqPj_EnRZ7I/AAAAAAAAAXA/CwcZw4IEHX4/s1600/Drawing1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 267px;" src="http://3.bp.blogspot.com/-mJGEz1eqwN8/TqPj_EnRZ7I/AAAAAAAAAXA/CwcZw4IEHX4/s400/Drawing1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5666623428871940018" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-771gH0vn8wI/TqPkb03_tVI/AAAAAAAAAXM/kd9fKeCCG6g/s1600/Drawing2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 267px;" src="http://4.bp.blogspot.com/-771gH0vn8wI/TqPkb03_tVI/AAAAAAAAAXM/kd9fKeCCG6g/s400/Drawing2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5666623922863322450" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After adding the ICSP header and jumper wire, the hardware is ready and you can write a program to use the SD card reader.  Below is the example I used for test and it worked fine.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Threading;&lt;br /&gt;using Microsoft.SPOT;&lt;br /&gt;using Microsoft.SPOT.Hardware;&lt;br /&gt;using SecretLabs.NETMF.Hardware;&lt;br /&gt;using SecretLabs.NETMF.Hardware.Netduino;&lt;br /&gt;using SecretLabs.NETMF.IO;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;namespace NetduinoSD&lt;br /&gt;{&lt;br /&gt;    public class Program&lt;br /&gt;    {&lt;br /&gt;        public static void Main()&lt;br /&gt;        {&lt;br /&gt;            StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);&lt;br /&gt;            using (var filestream = new FileStream(@"SD\dontpanic.txt", FileMode.Create))&lt;br /&gt;            {&lt;br /&gt;                StreamWriter streamWriter = new StreamWriter(filestream);&lt;br /&gt;                streamWriter.WriteLine("This is a test of the SD card support on the netduino...This is only a test...");&lt;br /&gt;                streamWriter.Close();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            using (var filestream = new FileStream(@"SD\dontpanic.txt", FileMode.Open))&lt;br /&gt;            {&lt;br /&gt;                StreamReader reader = new StreamReader(filestream);&lt;br /&gt;                Debug.Print(reader.ReadToEnd());&lt;br /&gt;                reader.Close();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            StorageDevice.Unmount("SD");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The whole solution for Visual Studio 2010 can be found &lt;a href="http://www.2shared.com/file/mma_0y5m/HelloNetduinoSD.html"&gt;here&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/LWrMjyae-mI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/3867270438629626909/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2011/10/netduino-using-ethernet-shield-to.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/3867270438629626909?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/3867270438629626909?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/LWrMjyae-mI/netduino-using-ethernet-shield-to.html" title="Netduino: Using Ethernet Shield to Read/Write to SD Card" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-mJGEz1eqwN8/TqPj_EnRZ7I/AAAAAAAAAXA/CwcZw4IEHX4/s72-c/Drawing1.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2011/10/netduino-using-ethernet-shield-to.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4NQXg9fyp7ImA9WhZWF0Q.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-4714955791261146576</id><published>2011-05-19T09:06:00.011+02:00</published><updated>2011-05-19T09:43:10.667+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-19T09:43:10.667+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".net json google location api mobile cellID base station" /><title>Retrieving Cell Informations using Google Location API</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-qOb_0PTcLtk/TdTIQCVSRuI/AAAAAAAAAPs/lUa08NAoHPk/s1600/lokacije%2Bklicev.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 269px;" src="http://1.bp.blogspot.com/-qOb_0PTcLtk/TdTIQCVSRuI/AAAAAAAAAPs/lUa08NAoHPk/s400/lokacije%2Bklicev.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5608327613812721378" /&gt;&lt;/a&gt;&lt;br /&gt;Recently I examined the records of events stored on my phone. The list contained the informations about MCC (Mobile Country Code), MNC (Mobile Network Code), LAC (Location Area Code) and CellID from which it is possible to get the informations about the mobile cell's location.&lt;br /&gt;&lt;br /&gt;Below is the code that retrieves the data from Google Location API with JSON.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using Newtonsoft.Json;&lt;br /&gt;using System.Net;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;namespace CellLocations&lt;br /&gt;{&lt;br /&gt;    public class GoogleService&lt;br /&gt;    {&lt;br /&gt;        public GoogleCell GetCellInfo(string lac, string mnc, string mcc, string cellID)&lt;br /&gt;        {&lt;br /&gt;            HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("https://www.google.com/loc/json");&lt;br /&gt;            myReq.Method = "POST";&lt;br /&gt;            myReq.ContentType = "application/jsonrequest";&lt;br /&gt;            string postData = "{\"cell_towers\": [{\"location_area_code\": \"" + lac +"\", \"mobile_network_code\": \"" + mnc + "\", \"cell_id\": \"" + cellID + "\", \"mobile_country_code\": \"" + mcc + "\"}], \"version\": \"1.1.0\", \"request_address\": \"true\"}";&lt;br /&gt;            myReq.ContentLength = postData.Length;&lt;br /&gt;&lt;br /&gt;            StreamWriter stOut = new StreamWriter(myReq.GetRequestStream(), System.Text.Encoding.ASCII);&lt;br /&gt;            stOut.Write(postData);&lt;br /&gt;            stOut.Close();&lt;br /&gt;&lt;br /&gt;            HttpWebResponse webresponse;&lt;br /&gt;            webresponse = (HttpWebResponse)myReq.GetResponse();&lt;br /&gt;            Encoding enc = System.Text.Encoding.UTF8;&lt;br /&gt;            StreamReader loResponseStream = new StreamReader(webresponse.GetResponseStream(), enc);&lt;br /&gt;&lt;br /&gt;            string Response = loResponseStream.ReadToEnd();&lt;br /&gt;            loResponseStream.Close();&lt;br /&gt;            webresponse.Close();&lt;br /&gt;&lt;br /&gt;            GoogleCell cell = JsonConvert.DeserializeObject&lt;GoogleCell&gt;(Response);&lt;br /&gt;            return cell;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In order to deserialize the received data an appropriate class has to be created:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class GoogleCell&lt;br /&gt;    {&lt;br /&gt;        public GoogleCell() { }&lt;br /&gt;        public GoogleCell(string mnc, string mcc, string lac)&lt;br /&gt;        {&lt;br /&gt;            this.Mnc = mnc;&lt;br /&gt;            this.Mcc = mcc;&lt;br /&gt;            this.Lac = lac;&lt;br /&gt;        }&lt;br /&gt;        public string Mnc { get; set; }&lt;br /&gt;        public string Mcc { get; set; }&lt;br /&gt;        public string Lac { get; set; }&lt;br /&gt;        public string CellID { get; set; }&lt;br /&gt;        public Location location { get; set; }&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;        public class Location&lt;br /&gt;        {&lt;br /&gt;            public Location() { }&lt;br /&gt;            public Location(string latitude, string longitude, string accuracy)&lt;br /&gt;            {&lt;br /&gt;                this.latitude = latitude;&lt;br /&gt;                this.longitude = longitude;&lt;br /&gt;                this.accuracy = accuracy;&lt;br /&gt;            }&lt;br /&gt;            public string latitude { get; set; }&lt;br /&gt;            public string longitude { get; set; }&lt;br /&gt;            public string accuracy { get; set; }&lt;br /&gt;            public Address address { get; set; }&lt;br /&gt;&lt;br /&gt;            public class Address&lt;br /&gt;            {&lt;br /&gt;                public Address() { }&lt;br /&gt;                public string country { get; set; }&lt;br /&gt;                public string country_code { get; set; }&lt;br /&gt;                public string city { get; set; }&lt;br /&gt;                public string street { get; set; }&lt;br /&gt;                public string street_number { get; set; }&lt;br /&gt;                public string postal_code { get; set; }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The JSON library for .NET is available &lt;a href="http://james.newtonking.com/pages/json-net.aspx"&gt;here&lt;/a&gt;.&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/yq0hzxY8a7A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/4714955791261146576/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2011/05/retrieving-cell-informations-using.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/4714955791261146576?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/4714955791261146576?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/yq0hzxY8a7A/retrieving-cell-informations-using.html" title="Retrieving Cell Informations using Google Location API" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-qOb_0PTcLtk/TdTIQCVSRuI/AAAAAAAAAPs/lUa08NAoHPk/s72-c/lokacije%2Bklicev.jpg" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2011/05/retrieving-cell-informations-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0EGQn46eCp7ImA9WhZWGEU.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-7899740917566564093</id><published>2010-05-29T12:22:00.022+02:00</published><updated>2011-05-20T12:00:23.010+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-20T12:00:23.010+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="decision tree" /><category scheme="http://www.blogger.com/atom/ns#" term="inductive programming" /><category scheme="http://www.blogger.com/atom/ns#" term="churn" /><category scheme="http://www.blogger.com/atom/ns#" term="data mining" /><category scheme="http://www.blogger.com/atom/ns#" term="business" /><title>Constructing Decision Tree using WEKA</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/TAJ0WmYb04I/AAAAAAAAANk/MuZfcgdu6BM/s1600/Information-Gain.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;span style="font-size:180%;"&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Decision tree learning is a method for assessing the most likely outcome value by taking into account the known values of the stored data instances. This learning method is among the most popular of inductive inference algorithms and has been successfully applied in broad range of tasks such as assessing the credit risk of applicants and improving loyality of regular customers.&lt;/div&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;Information, Entropy and Information Gain&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;There are several software tools already available which implement various algorithms for constructing decision trees which optimally fit the input dataset. Nevertheless it is useful to clarify the underlying principle.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Information&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;First let's briefly discuss the concept of information. In simplified form we could say that the information is a measure of uncertainty or surprise; the more we are surprised about the news the bigger is the information. If there was a newspaper which pubblished a news about the morning sunrise certainly none of the readers would be interested in such story because it doesn't hold any information - the sunrise is a fact and we know it will happen tomorrow again. On the other hand if a story in a newspaper is about something noone expected it's a big news. An example is Michael Jackson's death. It happened during the time of one of the worst recessions which affected the whole world but according to the statistics the news about Michael Jackson were far more interesting than the economic facts of the time.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:130%;"&gt;Entropy&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In General entropy is the measure of the uncertainty associated with random variable. In case of stored instances entropy is the measure of the uncertainty associated with the selected attribute.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:180%;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();}  catch(e) {}" href="http://3.bp.blogspot.com/_5IscwJQSAUY/TAD9CwI9FJI/AAAAAAAAAM8/m3w8fsVD9y8/s1600/entropy.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 244px; height: 48px;" src="http://3.bp.blogspot.com/_5IscwJQSAUY/TAD9CwI9FJI/AAAAAAAAAM8/m3w8fsVD9y8/s400/entropy.png" alt="" id="BLOGGER_PHOTO_ID_5476655370606548114" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;where &lt;img class="tex" alt="p(x_i)\," src="http://upload.wikimedia.org/math/e/d/9/ed9e3ca7c710634c58ba420d673aa72b.png" /&gt;  is the probability mass function of  outcome &lt;img class="tex" alt="x_i\," src="http://upload.wikimedia.org/math/a/c/8/ac840fba3ce6957bef1a8b6fd5044da3.png" /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;Information Gain&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Information gain is the expected reduction in entropy caused by partitioning the examples according to the attribute. In machine learning this concept can be used to define a preferred  sequence of attributes to investigate to most rapidly narrow down the  state of &lt;i&gt;the selected attribute&lt;/i&gt;. Such a sequence (which depends on the outcome of the  investigation of previous attributes at each stage) forms a decision tree. Usually an attribute  with high information gain should be preferred to other attributes.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/TAJ0WmYb04I/AAAAAAAAANk/MuZfcgdu6BM/s1600/Information-Gain.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 59px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/TAJ0WmYb04I/AAAAAAAAANk/MuZfcgdu6BM/s400/Information-Gain.jpg" alt="" id="BLOGGER_PHOTO_ID_5477068028444922754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:180%;"&gt;An Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The process of decision tree construction is described by the following example: There are 14 instances stored in the database described with 6 attributes: day, outlook, temperature, humidity, wind and playTennis. Each instance describes the facts of the day and the action of the observed person (played or not played tennis). Based on the given record we can assess which factors affected the person's decision about playing tennis.&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;a onblur="try  {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5IscwJQSAUY/TAENHMPBDuI/AAAAAAAAANU/2g6s6GVU9xI/s1600/WEKA-classify.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;a onblur="try  {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/TAECFg4suTI/AAAAAAAAANE/TcQrvrLJRmk/s1600/tennis-table.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 219px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/TAECFg4suTI/AAAAAAAAANE/TcQrvrLJRmk/s400/tennis-table.jpg" alt="" id="BLOGGER_PHOTO_ID_5476660915609581874" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;For the root element an attribute with the highest entropy is selected. In the case of this example it is the outlook because it is the most uncertain parameter.&lt;br /&gt;After the root parameter is selected the information gain for every possible combination of pair is calculated and then the branches are selected upon the information gain value; the higher is the information gain the more reliable the branch is.&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/TAJ1_hw_7EI/AAAAAAAAAN0/uLQzlV8JDNU/s1600/Entropy.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 49px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/TAJ1_hw_7EI/AAAAAAAAAN0/uLQzlV8JDNU/s400/Entropy.jpg" alt="" id="BLOGGER_PHOTO_ID_5477069831092038722" border="0" /&gt;&lt;/a&gt;Entropy(S) is the entropy of classificator PlayTennis - there are 14 instances stored in the dataset from which a person decides do play tennis 9 times (9+) and not to play 5 times (5-).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5IscwJQSAUY/TAJ3sHZLMwI/AAAAAAAAAN8/Z1i5wMiVjXw/s1600/values.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 198px; height: 96px;" src="http://4.bp.blogspot.com/_5IscwJQSAUY/TAJ3sHZLMwI/AAAAAAAAAN8/Z1i5wMiVjXw/s400/values.jpg" alt="" id="BLOGGER_PHOTO_ID_5477071696618533634" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5IscwJQSAUY/TAJ4LIS0YnI/AAAAAAAAAOE/Wm0jAVzwar0/s1600/gaincalc.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 100px;" src="http://1.bp.blogspot.com/_5IscwJQSAUY/TAJ4LIS0YnI/AAAAAAAAAOE/Wm0jAVzwar0/s400/gaincalc.jpg" alt="" id="BLOGGER_PHOTO_ID_5477072229436252786" border="0" /&gt;&lt;/a&gt;The above example shows the calculation of the information gain value of classificator Wind: There are 8 instances of value Weak. In case of weak wind a person decides to play tennis 6 times and not to play 2 times [6+, 2-]. In case of strong wind (6 instances) the user decides to play 3 times and not to play 3 times as well. Considering the given instances the calculated value of information gain of attribute wind is 0.48.&lt;br /&gt;&lt;br /&gt;Information gain values of all attributes are calculated in the same way and the results are the following:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Gain(S, Outlook) = 0.246&lt;br /&gt;Gain(S, Humidity) = 0.151&lt;br /&gt;Gain(S, Wind) = 0.048&lt;br /&gt;Gain(S, Temperature) = 0.029&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Using WEKA&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The example is taken from the Book &lt;a href="http://www.amazon.com/Data-Mining-Practical-Techniques-Management/dp/0120884070/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1275135833&amp;amp;sr=1-1"&gt;Data  Mining: Practical Machine Learning Tools and Techniques, Second Edition  (Morgan Kaufmann Series in Data Management Systems)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;The .arff file&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One of possible options for importing the record in WEKA tool is writing records in .arff file format. In this example the file looks like the following:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;@relation PlayTennis&lt;/span&gt;  &lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;@attribute day numeric&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;@attribute outlook {Sunny, Overcast, Rain}&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;@attribute temperature {Hot, Mild, Cool}&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;@attribute humidity {High, Normal}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;@attribute wind {Weak, Strong}&lt;/span&gt; &lt;br /&gt;&lt;span style="font-style: italic;"&gt;@attribute playTennis {Yes, No}&lt;/span&gt;  &lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;@data&lt;/span&gt;  &lt;br /&gt;&lt;span style="font-style: italic;"&gt;1,Sunny,Hot,High,Weak,No,?&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;2,Sunny,Hot,High,Strong,No,?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;3,Overcast,Hot,High,Weak,Yes,?&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;4,Rain,Mild,High,Weak,Yes,?&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;5,Rain,Cool,Normal,Weak,Yes,?&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;6,Rain,Cool,Normal,Strong,No,?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;7,Overcast,Cool,Normal,Strong,Yes,?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;8,Sunny,Mild,High,Weak,No,?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;9,Sunny,Cool,Normal,Weak,Yes,?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;10,Rain,Mild,Normal,Weak,Yes,?&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;11,Sunny,Mild,Normal,Strong,Yes,?&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;12,Overcast,Mild,High,Strong,Yes,?&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;13,Overcast,Hot,Normal,Weak,Yes,?&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;14,Rain,Mild,High,Strong,No,?&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The file can  then be imported using WEKA explorer. When the above file is imported the interface looks like the following:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:180%;"&gt;&lt;a onblur="try  {parent.deselectBloggerImageGracefully();}  catch(e) {}" href="http://1.bp.blogspot.com/_5IscwJQSAUY/TAEF0QII6AI/AAAAAAAAANM/okcrhhQqDvc/s1600/WEKA-explorer.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 299px;" src="http://1.bp.blogspot.com/_5IscwJQSAUY/TAEF0QII6AI/AAAAAAAAANM/okcrhhQqDvc/s400/WEKA-explorer.jpg" alt="" id="BLOGGER_PHOTO_ID_5476665017099675650" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;Figure: Available attributes (left) and graphical representation (right) from the file data&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;after the data is imported there is a set of classification methods available under the classification tab&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-style: italic;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt; In this case the c4.5 algorithm has been chosen which is entitled as j48 in Java and can be selected by clicking the button choose and select trees-&gt;j48.&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;a onblur="try  {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5IscwJQSAUY/TAENHMPBDuI/AAAAAAAAANU/2g6s6GVU9xI/s1600/WEKA-classify.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_5IscwJQSAUY/TAENHMPBDuI/AAAAAAAAANU/2g6s6GVU9xI/s400/WEKA-classify.jpg" alt="" id="BLOGGER_PHOTO_ID_5476673039053688546" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;Figure: after running Start The decision tree is created in this case using&lt;a href="http://en.wikipedia.org/wiki/C4.5_algorithm"&gt; c4.5 algorithm&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span&gt;The tree is then created by selecting start and can be displayed by selecting the output from the result list with the right-mouse button choosing the option "Visualize Tree"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:100%;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/TAEP2TKtnBI/AAAAAAAAANc/f3kYf6vcuxo/s1600/WEKA-tree.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 321px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/TAEP2TKtnBI/AAAAAAAAANc/f3kYf6vcuxo/s400/WEKA-tree.jpg" alt="" id="BLOGGER_PHOTO_ID_5476676047391792146" border="0" /&gt;&lt;/a&gt;Figure: The decision tree constructed by using the implemented &lt;a href="http://en.wikipedia.org/wiki/C4.5_algorithm"&gt;C4.5 algorithm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;The algorithm implemented in WEKA constructs the tree which is consistent with the information gain values calculated above: the attribute Outlook has the highest information gain thus it is the root attribute. Attributes Humidity and Wind have lower information gain than Outlook and higher than Temperature and thus are placed below Outlook. The information gain of a specific branch can be calculated the same way as the example above. For example if we were interested what is the information gain of branch (Outlook, Temperature) the attributes Outlook and Temperature should be placed in the equation for calculating the information gain.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;References&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Data Mining and KnowledgeDiscovery; Prof. Dr. Nada Lavrač&lt;span style="font-size:100%;"&gt;&lt;span id="btAsinTitle" style=""&gt;&lt;br /&gt;&lt;br /&gt;Data Mining:  Practical Machine Learning Tools and Techniques, Second Edition; &lt;/span&gt;&lt;span class="h3color"&gt;Ian H. Witten, &lt;/span&gt;&lt;span class="h3color"&gt;Eibe Frank&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/x1XR6g2c4JQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/7899740917566564093/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2010/05/decision-tree-with-weka-part-i.html#comment-form" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/7899740917566564093?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/7899740917566564093?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/x1XR6g2c4JQ/decision-tree-with-weka-part-i.html" title="Constructing Decision Tree using WEKA" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_5IscwJQSAUY/TAD9CwI9FJI/AAAAAAAAAM8/m3w8fsVD9y8/s72-c/entropy.png" height="72" width="72" /><thr:total>9</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2010/05/decision-tree-with-weka-part-i.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQCSHo6fip7ImA9WxFXFk4.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-1829191833114962424</id><published>2010-05-23T17:45:00.006+02:00</published><updated>2010-05-23T18:32:49.416+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-23T18:32:49.416+02:00</app:edited><title>LDPC Block Code Simulator: GUI Preview</title><content type="html">&lt;div style="text-align: justify;"&gt;In the past days I've created a &lt;a href="http://en.wikipedia.org/wiki/Low-density_parity-check_code"&gt;LDPC &lt;/a&gt;Block Code Simulator in Matlab. It is possible to enter the parity matrix H, the information sequence D which is encoded into codeword C and then add &lt;a href="http://en.wikipedia.org/wiki/Additive_white_Gaussian_noise"&gt;Gaussian Noise&lt;/a&gt; of a chosen variance which simulates the transmission channel charcteristics.&lt;br /&gt;&lt;br /&gt;The simulator then calculates the original codeword and enables user to switch between the steps of the iterative decoding process. Each step displays the current message values that are passed between symbol and parity nodes and the next step operation.&lt;br /&gt;&lt;br /&gt;Below are the screenshots of three steps. In this example H is 4 x 8 parity-check matrix ([1 0 1 0 1 0 0 0; 0 0 0 1 0 1 0 0; 1 0 0 1 0 0 1 0; 0 1 1 0 0 0 0 1]). The information sequence D ([1 0 1 1]) is encoded into codeword C (1  0  1  1  0  1  0  1). The original unipolar codeword is  transformed to bipolar code (1 is transformed to -1 and 0 is transformed to 1) and the noise of variance 0.5 is added to the transformed code which results Y (-1.0371     0.12971     -1.1976      -1.808      1.3784     -1.3998      1.0451     -1.2452), the simulated received sequence. After 5 steps the algorithm determines the codeword C' (1  0  1  1  0  1  0  1) which is equal to the original codeword.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/S_lSjqyUXqI/AAAAAAAAAMI/GVnHPVW1Ty4/s1600/LDPCSim1.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 238px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/S_lSjqyUXqI/AAAAAAAAAMI/GVnHPVW1Ty4/s400/LDPCSim1.jpg" alt="" id="BLOGGER_PHOTO_ID_5474497594779786914" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/S_lT51I3a5I/AAAAAAAAAMQ/6VOEU-GHYq4/s1600/LDPCSim2.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 238px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/S_lT51I3a5I/AAAAAAAAAMQ/6VOEU-GHYq4/s400/LDPCSim2.jpg" alt="" id="BLOGGER_PHOTO_ID_5474499075027463058" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/S_lUOFS601I/AAAAAAAAAMY/N26g5_z5U9w/s1600/LDPCSim3.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 238px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/S_lUOFS601I/AAAAAAAAAMY/N26g5_z5U9w/s400/LDPCSim3.jpg" alt="" id="BLOGGER_PHOTO_ID_5474499422961980242" border="0" /&gt;&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/kBv7paWMYto" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/1829191833114962424/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2010/05/ldpc-block-code-simulator-gui-preview.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/1829191833114962424?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/1829191833114962424?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/kBv7paWMYto/ldpc-block-code-simulator-gui-preview.html" title="LDPC Block Code Simulator: GUI Preview" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_5IscwJQSAUY/S_lSjqyUXqI/AAAAAAAAAMI/GVnHPVW1Ty4/s72-c/LDPCSim1.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2010/05/ldpc-block-code-simulator-gui-preview.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEGRHk5cSp7ImA9WxJSFE0.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-7408580327357107813</id><published>2009-05-03T20:45:00.019+02:00</published><updated>2009-05-04T04:37:05.729+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-04T04:37:05.729+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".net wcf android rest json" /><title>Communication Between WCF Service and Android Client</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5IscwJQSAUY/Sf3zGLltL4I/AAAAAAAAAJI/VLDKAA-Bm_M/s1600-h/data+exchange.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 342px; height: 400px;" src="http://1.bp.blogspot.com/_5IscwJQSAUY/Sf3zGLltL4I/AAAAAAAAAJI/VLDKAA-Bm_M/s400/data+exchange.jpg" alt="" id="BLOGGER_PHOTO_ID_5331684821392240514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;Overview of REST in WCF&lt;/span&gt;&lt;br /&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;Windows Communication Foundation (WCF), part of the .NET Framework, provides the first unified programming model for rapidly building service-oriented applications. It enables the development of secure, reliable, transacted services that interoperate with current Microsoft investments and non-Microsoft platforms.&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;With the .NET Framework 3.5 release, WCF added support for building REST style services. REST, an architectural style for building distributed hypermedia driven applications, involves building resource-oriented services by defining resources that implement uniform interfaces using standard HTTP verbs (GET, POST, PUT, and DELETE), and that can be located/identified by a URI.&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;REST support within WCF was enhanced with the release of .NET Framework 3.5 SP1 to add make REST development easier and to support the ADO.NET Entity Framework entities in WCF contracts. Improvements were made around UriTemplate flexibility and the Visual Studio tooling to increase developer productivity.&lt;/p&gt;&lt;p style="font-weight: bold; font-family: verdana;"&gt;Code example&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify;"&gt;A good tutorial on how to create RESTful Service using Visual Studio can be found &lt;a href="http://msdn.microsoft.com/en-us/library/dd203052.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p style="text-align: justify;"&gt;First we need to define the structure (class) which will be used for data exchange between server and client. In this case I created a base class named Response and extended classes named ActivityStatusResponse and ConnectionStatusResponse:&lt;/p&gt;&lt;div id="iframeDiveb7b9e73-4512-4666-ba7b-0d9fcc4cc610" style="margin: 0px; display: none;"&gt;&lt;iframe id="iframeeb7b9e73-4512-4666-ba7b-0d9fcc4cc610" src="http://www.blogtrog.com/code.aspx?id=eb7b9e73-4512-4666-ba7b-0d9fcc4cc610" style="border: 1px solid rgb(224, 224, 224); margin: 0px; width: 600px; height: 200px;" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id="noIframeDiveb7b9e73-4512-4666-ba7b-0d9fcc4cc610" style="margin: 0px; display: block;"&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; comment;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Successful&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;  successful &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; value;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Comment&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; comment;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;  comment &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; value;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language="javascript" src="http://www.blogtrog.com/scripts/bt_code.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript"&gt;bt_code_init('eb7b9e73-4512-4666-ba7b-0d9fcc4cc610');&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id="iframeDiv7be2fc22-46f6-4bea-8dc0-8d2928563a10" style="margin: 0px; display: none;"&gt;&lt;iframe id="iframe7be2fc22-46f6-4bea-8dc0-8d2928563a10" src="http://www.blogtrog.com/code.aspx?id=7be2fc22-46f6-4bea-8dc0-8d2928563a10" style="border: 1px solid rgb(224, 224, 224); margin: 0px; width: 600px; height: 200px;" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id="noIframeDiv7be2fc22-46f6-4bea-8dc0-8d2928563a10" style="margin: 0px; display: block;"&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ActivityStatusResponse : Response&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; activity;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Activity&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; activity;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;  activity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; value;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language="javascript" src="http://www.blogtrog.com/scripts/bt_code.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript"&gt;bt_code_init('7be2fc22-46f6-4bea-8dc0-8d2928563a10')&lt;/script&gt;&lt;br /&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;Next we need to define the methods, message formats and URI templates in the interface:&lt;/p&gt;&lt;div id="iframeDivee2665bb-d6d3-4970-8f1b-19472ba93eb7" style="margin: 0px; display: none;"&gt;&lt;iframe id="iframeee2665bb-d6d3-4970-8f1b-19472ba93eb7" src="http://www.blogtrog.com/code.aspx?id=ee2665bb-d6d3-4970-8f1b-19472ba93eb7" style="border: 1px solid rgb(224, 224, 224); margin: 0px; width: 600px; height: 200px;" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id="noIframeDivee2665bb-d6d3-4970-8f1b-19472ba93eb7" style="margin: 0px; display: block;"&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[OperationContract]&lt;br /&gt;[WebGet(ResponseFormat &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; WebMessageFormat.Json, UriTemplate &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;/{strSessionString}/activityStatus&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)]&lt;br /&gt;ActivityStatusResponse GetActivityStatus(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strSessionString);&lt;br /&gt;&lt;br /&gt;[OperationContract]&lt;br /&gt;[WebGet(ResponseFormat &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; WebMessageFormat.Json,&lt;br /&gt;UriTemplate &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;/{strSessionString}/time={time}&amp;amp;lat={latitude}&amp;amp;long={longitude}&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)]&lt;br /&gt;Response StoreLocation(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strSessionString, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; time, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; latitude, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; longitude);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language="javascript" src="http://www.blogtrog.com/scripts/bt_code.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript"&gt;bt_code_init('ee2665bb-d6d3-4970-8f1b-19472ba93eb7&lt;/script&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;WebMessageFormat parameter defines the data exchange format. In this example JSON format is used.&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;UriTemplate parameter defines the URI template.&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;The parameters within curly braces represent variable values. Everything else in the URI (not enclosed within curly braces) is considered a static part of the URI.&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;After the definition we have to implement the methods. The following code shows the implementation of StoreAcceleration method:&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div id="iframeDivd000962f-ccca-4659-961e-f8202bcdc0cd" style="margin: 0px; display: none; text-align: justify;"&gt;&lt;iframe id="iframed000962f-ccca-4659-961e-f8202bcdc0cd" src="http://www.blogtrog.com/code.aspx?id=d000962f-ccca-4659-961e-f8202bcdc0cd" style="border: 1px solid rgb(224, 224, 224); margin: 0px; width: 600px; height: 200px;" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id="noIframeDivd000962f-ccca-4659-961e-f8202bcdc0cd" style="margin: 0px; display: block;"&gt;&lt;pre&gt;&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response StoreAcceleration(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strSessionString, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strMeasurementTime, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strAccelerationX, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strAccelerationY, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strAccelerationZ)&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;      {&lt;br /&gt;SQLWorks sqlWorks &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; SQLWorks();&lt;br /&gt;Response response &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strTime &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strMeasurementTime.Replace(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;_&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;  DateTime measurementTime &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; DateTime.ParseExact(strTime, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;yyyy-MM-dd HH:mm:ss:fff&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; accelerationX &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Convert.ToDouble(strAccelerationX.Replace(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;));&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; accelerationY &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Convert.ToDouble(strAccelerationY.Replace(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;));&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; accelerationZ &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Convert.ToDouble(strAccelerationZ.Replace(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;));&lt;br /&gt;&lt;br /&gt;  sqlWorks.StoreAcceleration(strSessionString, measurementTime, accelerationX, accelerationY, accelerationZ);&lt;br /&gt;&lt;br /&gt;  response.Successful &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;  response.Comment &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Stored!&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(Exception ex)&lt;br /&gt;{&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; sDummy &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ex.ToString();&lt;br /&gt;  response.Comment &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;an error occured!&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;  response.Successful &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; response;&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language="javascript" src="http://www.blogtrog.com/scripts/bt_code.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript"&gt;bt_code_init('d000962f-ccca-4659-961e-f8202bcdc0cd');&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The service Endpoint and other properties are defined in .config file:&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&lt;div&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;configuration&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;system.web&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;compilation &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="true"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;compilation&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;system.servicemodel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;bindings&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;webhttpbinding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;binding &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="DefaultBinding"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;binding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;webhttpbinding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;behaviors&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;endpointbehaviors&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;behavior &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="RESTFriendly"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;webhttp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;webhttp&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;behavior &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="RESTServer.JsonServiceAspNetAjaxBehavior"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;enablewebscript&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;enablewebscript&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;behavior&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;servicebehaviors&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;behavior &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="RESTFriendly"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;servicemetadata &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;httpgetenabled&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="true"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;servicedebug &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;includeexceptiondetailinfaults&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="false"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;servicedebug&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;servicemetadata&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;behavior&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;services&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;service &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="RESTServer.GaitLinkService"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;endpoint &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;address&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=""&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; behaviorconfiguration&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="RESTFriendly"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; binding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="webHttpBinding"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; bindingconfiguration&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="DefaultBinding"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; contract&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="RESTServer.IGaitLinkService"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;identity&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;dns &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;value&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="localhost"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;dns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;identity&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;endpoint&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;service&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;servicehostingenvironment &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;aspnetcompatibilityenabled&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="true"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;servicehostingenvironment&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;services&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;servicebehaviors&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;behavior&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;endpointbehaviors&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;behaviors&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;bindings&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;system.servicemodel&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;system.web&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;configuration&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;script language="javascript" src="http://www.blogtrog.com/scripts/bt_code.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript"&gt;bt_code_init('c85a3db3-2dce-47c7-a915-0788b46a1d9a');&lt;/script&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: verdana;"&gt;At this point everything is ready to host the service in the windows application:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id="iframeDiv8126d1ef-b3a3-4da9-b8e6-1f234f92ba57" style="margin: 0px; display: none;"&gt;&lt;iframe id="iframe8126d1ef-b3a3-4da9-b8e6-1f234f92ba57" src="http://www.blogtrog.com/code.aspx?id=8126d1ef-b3a3-4da9-b8e6-1f234f92ba57" style="border: 1px solid rgb(224, 224, 224); margin: 0px; width: 600px; height: 200px;" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id="noIframeDiv8126d1ef-b3a3-4da9-b8e6-1f234f92ba57" style="margin: 0px; display: block;"&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; StartRestService()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;   WebHttpBinding binding &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; WebHttpBinding();&lt;br /&gt;   RESTServiceHost &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ServiceHost(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(GaitLinkService), &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Uri(&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;http://localhost:8000/GaitLink&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;));&lt;br /&gt;   RESTServiceHost.AddServiceEndpoint(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(IGaitLinkService), binding, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;GaitLink&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;   RESTServiceHost.Open();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(Exception ex)&lt;br /&gt;{&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; sDummy &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ex.ToString();&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;TODO: notify user about the error!&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;            }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language="javascript" src="http://www.blogtrog.com/scripts/bt_code.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript"&gt;bt_code_init('8126d1ef-b3a3-4da9-b8e6-1f234f92ba57');&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style="font-weight: bold; font-family: verdana;"&gt;Client application&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;On client side there is a service called CommunicationService and additional class RestClient. Function arguments are sent to the server by generating the url address which has to be the same format as the template specified in the service interface on the server side.&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify; font-family: verdana;"&gt;Class RestClient.java:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id="iframeDiv8f7cb0a7-2065-4e23-9781-96e90d4f5780" style="margin: 0px; display: none;"&gt;&lt;iframe id="iframe8f7cb0a7-2065-4e23-9781-96e90d4f5780" src="http://www.blogtrog.com/code.aspx?id=8f7cb0a7-2065-4e23-9781-96e90d4f5780" style="border: 1px solid rgb(224, 224, 224); margin: 0px; width: 600px; height: 200px;" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id="noIframeDiv8f7cb0a7-2065-4e23-9781-96e90d4f5780" style="margin: 0px; display: block;"&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;package&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; com.client.gaitlink;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; java.io.BufferedReader;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; java.io.IOException;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; java.io.InputStream;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; java.io.InputStreamReader;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.apache.http.HttpEntity;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.apache.http.HttpResponse;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.apache.http.client.ClientProtocolException;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.apache.http.client.HttpClient;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.apache.http.client.methods.HttpGet;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.apache.http.impl.client.DefaultHttpClient;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.json.JSONArray;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.json.JSONException;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; org.json.JSONObject;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;import&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; android.util.Log;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; RestClient {&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String loginParameters;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String accelerationParameters;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String activityRequestParameters;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String locationParameters;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String serviceAddress &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;http://testserver:8000/GaitLink/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String convertStreamToString(InputStream is) {&lt;br /&gt;BufferedReader reader &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; BufferedReader(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; InputStreamReader(is));&lt;br /&gt;StringBuilder sb &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; StringBuilder();&lt;br /&gt;&lt;br /&gt;String line &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;while&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ((line &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; reader.readLine()) &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;) {&lt;br /&gt;  sb.append(line &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;\n&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;}&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; (IOException e) {&lt;br /&gt;e.printStackTrace();&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;finally&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; {&lt;br /&gt;  is.close();&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; (IOException e) {&lt;br /&gt;  e.printStackTrace();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; sb.toString();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; connect(String url) {&lt;br /&gt;&lt;br /&gt;HttpClient httpclient &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; DefaultHttpClient();&lt;br /&gt;&lt;br /&gt;HttpGet httpget &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; HttpGet(url);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;HttpPost httppost = new HttpPost(url);&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;HttpResponse response;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; {&lt;br /&gt;&lt;br /&gt;response &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; httpclient.execute(httpget);&lt;br /&gt;&lt;br /&gt;Log.i(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;REST:Response Status line&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, response.getStatusLine().toString());&lt;br /&gt;&lt;br /&gt;HttpEntity entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; response.getEntity();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; (entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;) {&lt;br /&gt;&lt;br /&gt;  InputStream instream &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; entity.getContent();&lt;br /&gt;  String result &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; convertStreamToString(instream);&lt;br /&gt;  Log.i(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;REST: result&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, result);&lt;br /&gt;&lt;br /&gt;  JSONObject json &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; JSONObject(result);&lt;br /&gt;  Log.i(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;REST&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;lt;jsonobject&amp;gt;\n&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.toString()&lt;br /&gt;          &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;\n&amp;lt;/jsonobject&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Parsing&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                JSONArray nameArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.names();&lt;br /&gt;  JSONArray valArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.toJSONArray(nameArray);&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;for&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; i &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;; i &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; valArray.length(); i&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;++&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;) {&lt;br /&gt;      Log&lt;br /&gt;              .i(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;REST&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;lt;jsonname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; i &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;gt;\n&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;                      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; nameArray.getString(i) &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;\n&amp;lt;/jsonname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;                      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; i &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;gt;\n&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;lt;jsonvalue&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; i &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;gt;\n&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;                      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; valArray.getString(i) &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;\n&amp;lt;/jsonvalue&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;                      &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; i &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  json.put(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;sample key&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;sample value&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;  Log.i(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;REST&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;lt;jsonobject&amp;gt;\n&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.toString()&lt;br /&gt;          &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;\n&amp;lt;/jsonobject&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  instream.close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; (ClientProtocolException e) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; TODO Auto-generated catch block&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;            e.printStackTrace();&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; (IOException e) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; TODO Auto-generated catch block&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;            e.printStackTrace();&lt;br /&gt;} &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; (JSONException e) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; TODO Auto-generated catch block&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;            e.printStackTrace();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;boolean&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; isSuccessful() {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; setSuccessful(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;boolean&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.successful &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String getComment() {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; comment;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; setComment(String comment) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.comment &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; comment;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;boolean&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String comment;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;boolean&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful, String comment)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.successful &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.comment &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; comment;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; LoginResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;extends&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String strSessionString;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; LoginResponse()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;LoginFailed&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; LoginResponse(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;boolean&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successful, String strSessionString, String comment)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;super&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(successful, comment);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.strSessionString &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strSessionString;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String getStrSessionString() {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strSessionString;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; setStrSessionString(String strSessionString) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.strSessionString &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strSessionString;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ActivityStatusResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;extends&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String activity;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; String getActivity() {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; activity;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; setActivity(String activity) {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.activity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; activity;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ActivityStatusResponse(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;boolean&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; successfull, String activity, String comment)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;super&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(successfull, comment);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.activity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; activity;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ActivityStatusResponse()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;activity request failed&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; SetLoginParameters(String username, String password)&lt;br /&gt;{&lt;br /&gt;loginParameters &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Login?username=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; username &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;amp;password=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; password;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; LoginResponse Login(String username, String password)&lt;br /&gt;{&lt;br /&gt;SetLoginParameters(username, password);&lt;br /&gt;&lt;br /&gt;HttpClient httpclient &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; DefaultHttpClient();&lt;br /&gt;HttpGet httpget &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; HttpGet(serviceAddress &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; loginParameters);&lt;br /&gt;&lt;br /&gt;HttpResponse response;&lt;br /&gt;&lt;br /&gt;LoginResponse loginResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;response &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; httpclient.execute(httpget);&lt;br /&gt;&lt;br /&gt;HttpEntity entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; response.getEntity();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;{&lt;br /&gt;  InputStream instream &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; entity.getContent();&lt;br /&gt;  String result &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; convertStreamToString(instream);&lt;br /&gt;  JSONObject json &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; JSONObject(result);&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Parsing&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                JSONArray nameArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.names();&lt;br /&gt;  JSONArray valArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.toJSONArray(nameArray);&lt;br /&gt;&lt;br /&gt;  loginResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; LoginResponse(valArray.getBoolean(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;), valArray.getString(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;), valArray.getString(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  instream.close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(Exception e)&lt;br /&gt;{&lt;br /&gt;loginResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; LoginResponse();&lt;br /&gt;String sDummy &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; e.toString();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; loginResponse;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response SendAccelerations(String sSession, String measurementTime, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ax, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ay, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; az)&lt;br /&gt;{&lt;br /&gt;setAccelerationParameters(sSession, measurementTime, ax, ay, az);&lt;br /&gt;&lt;br /&gt;HttpClient httpclient &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; DefaultHttpClient();&lt;br /&gt;HttpGet httpget &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; HttpGet(serviceAddress &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; accelerationParameters);&lt;br /&gt;&lt;br /&gt;HttpResponse response;&lt;br /&gt;&lt;br /&gt;Response accelerationResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;response &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; httpclient.execute(httpget);&lt;br /&gt;&lt;br /&gt;HttpEntity entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; response.getEntity();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;{&lt;br /&gt;  InputStream instream &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; entity.getContent();&lt;br /&gt;  String result &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; convertStreamToString(instream);&lt;br /&gt;  JSONObject json &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; JSONObject(result);&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Parsing&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                JSONArray nameArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.names();&lt;br /&gt;  JSONArray valArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.toJSONArray(nameArray);&lt;br /&gt;&lt;br /&gt;  accelerationResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response(valArray.getBoolean(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;), valArray.getString(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  instream.close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(Exception e)&lt;br /&gt;{&lt;br /&gt;accelerationResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response();&lt;br /&gt;String sDummy &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; e.toString();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; accelerationResponse;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; setAccelerationParameters(String sSession, String measurementTime, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ax, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ay, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; az)&lt;br /&gt;{&lt;br /&gt;accelerationParameters &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; sSession &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;/measurementTime=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; measurementTime &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;amp;accelerationX=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ax &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;amp;accelerationY=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ay &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;amp;accelerationZ=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; az;&lt;br /&gt;accelerationParameters &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; accelerationParameters.replaceAll(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;_&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response SendLocation(String sSession, String locationTime, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; latitude, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; longitude)&lt;br /&gt;{&lt;br /&gt;setLocationParameters(sSession, locationTime, latitude, longitude);&lt;br /&gt;&lt;br /&gt;HttpClient httpclient &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; DefaultHttpClient();&lt;br /&gt;HttpGet httpget &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; HttpGet(serviceAddress &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; locationParameters);&lt;br /&gt;&lt;br /&gt;HttpResponse response;&lt;br /&gt;&lt;br /&gt;Response locationResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;response &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; httpclient.execute(httpget);&lt;br /&gt;&lt;br /&gt;HttpEntity entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; response.getEntity();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;{&lt;br /&gt;  InputStream instream &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; entity.getContent();&lt;br /&gt;  String result &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; convertStreamToString(instream);&lt;br /&gt;  JSONObject json &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; JSONObject(result);&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Parsing&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                JSONArray nameArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.names();&lt;br /&gt;  JSONArray valArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.toJSONArray(nameArray);&lt;br /&gt;&lt;br /&gt;  locationResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response(valArray.getBoolean(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;), valArray.getString(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  instream.close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(Exception e)&lt;br /&gt;{&lt;br /&gt;locationResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; Response();&lt;br /&gt;String sDummy &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; e.toString();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; locationResponse;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; setLocationParameters(String sSession, String locationTime, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; latitude, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; longitude)&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;/{strSessionString}/time={time}&amp;amp;lat={latitude}&amp;amp;long={longitude}&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;        locationParameters &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; sSession &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;/time=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; locationTime &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;amp;lat=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; latitude &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;amp;long=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; longitude;&lt;br /&gt;locationParameters &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; locationParameters.replaceAll(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;_&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ActivityStatusResponse GetActivity(String sSession)&lt;br /&gt;{&lt;br /&gt;setActivityRequestParameters(sSession);&lt;br /&gt;&lt;br /&gt;HttpClient httpclient &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; DefaultHttpClient();&lt;br /&gt;HttpGet httpget &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; HttpGet(serviceAddress &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; activityRequestParameters);&lt;br /&gt;&lt;br /&gt;HttpResponse response;&lt;br /&gt;&lt;br /&gt;ActivityStatusResponse activityStatusResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;response &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; httpclient.execute(httpget);&lt;br /&gt;&lt;br /&gt;HttpEntity entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; response.getEntity();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(entity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;{&lt;br /&gt;  InputStream instream &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; entity.getContent();&lt;br /&gt;  String result &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; convertStreamToString(instream);&lt;br /&gt;  JSONObject json &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; JSONObject(result);&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Parsing&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                JSONArray nameArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.names();&lt;br /&gt;  JSONArray valArray &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; json.toJSONArray(nameArray);&lt;br /&gt;&lt;br /&gt;  activityStatusResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ActivityStatusResponse(valArray.getBoolean(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;), valArray.getString(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;), valArray.getString(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  instream.close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(Exception e)&lt;br /&gt;{&lt;br /&gt;activityStatusResponse &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; ActivityStatusResponse();&lt;br /&gt;String sDummy &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; e.toString();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; activityStatusResponse;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; setActivityRequestParameters(String sSession)&lt;br /&gt;{&lt;br /&gt;activityRequestParameters &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; sSession &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;/activityStatus&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language="javascript" src="http://www.blogtrog.com/scripts/bt_code.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript"&gt;bt_code_init('8f7cb0a7-2065-4e23-9781-96e90d4f5780')&lt;/script&gt;RestClient methods are called from CommunicationService class. The following example shows the method which retrieves the activity status:&lt;div id="iframeDivd8aa0914-6572-4e43-b18e-8f2c4ed392db" style="margin: 0px; display: none;"&gt;&lt;iframe id="iframed8aa0914-6572-4e43-b18e-8f2c4ed392db" src="http://www.blogtrog.com/code.aspx?id=d8aa0914-6572-4e43-b18e-8f2c4ed392db" style="border: 1px solid rgb(224, 224, 224); margin: 0px; width: 600px; height: 200px;" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id="noIframeDivd8aa0914-6572-4e43-b18e-8f2c4ed392db" style="margin: 0px; display: block;"&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; requestActivity()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(strSessionString &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;{&lt;br /&gt;  ActivityStatusResponse response &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; restClient.GetActivity(strSessionString);&lt;br /&gt;  connectionAvailable &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; response.isSuccessful();&lt;br /&gt;  strActivity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; response.getActivity();&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(strActivity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; strActivity &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;  {&lt;br /&gt;      announceActivityStatus();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;catch&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(Exception e)&lt;br /&gt;{&lt;br /&gt;connectionAvailable &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language="javascript" src="http://www.blogtrog.com/scripts/bt_code.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script language="javascript" type="text/javascript"&gt;bt_code_init('d8aa0914-6572-4e43-b18e-8f2c4ed392db');&lt;/script&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: verdana; font-style: italic;"&gt;The example above is just a brief overview of practical RESTful service realization using WCF and data exchange with Android client. More detailed explanations of each segment could be found at the given addresses.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;References&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a style="font-family: verdana;" href="http://msdn.microsoft.com/en-us/library/dd203052.aspx"&gt;A Guide to Designing and Building RESTful Web Services with WCF 3.5&lt;/a&gt;&lt;br /&gt;&lt;a style="font-family: verdana;" href="http://msdn.microsoft.com/en-us/library/ms733128.aspx"&gt;Windows Communication Foundation Architecture&lt;/a&gt;&lt;br /&gt;&lt;a style="font-family: verdana;" href="http://msdn.microsoft.com/en-us/library/ms731082.aspx"&gt;What Is Windows Communication Foundation?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/eFqrBlQsS6o" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/7408580327357107813/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2009/05/communication-between-wcf-service-and.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/7408580327357107813?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/7408580327357107813?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/eFqrBlQsS6o/communication-between-wcf-service-and.html" title="Communication Between WCF Service and Android Client" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_5IscwJQSAUY/Sf3zGLltL4I/AAAAAAAAAJI/VLDKAA-Bm_M/s72-c/data+exchange.jpg" height="72" width="72" /><thr:total>6</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2009/05/communication-between-wcf-service-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8DR34ycSp7ImA9WxJTF0g.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-3769468344642833975</id><published>2009-04-26T04:46:00.014+02:00</published><updated>2009-04-26T16:57:56.099+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-26T16:57:56.099+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Activity" /><category scheme="http://www.blogger.com/atom/ns#" term="Queue" /><category scheme="http://www.blogger.com/atom/ns#" term="Service" /><category scheme="http://www.blogger.com/atom/ns#" term="concept" /><category scheme="http://www.blogger.com/atom/ns#" term="architecture" /><category scheme="http://www.blogger.com/atom/ns#" term="android" /><category scheme="http://www.blogger.com/atom/ns#" term="client" /><title>Client Architecture: Conceptual Overview</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5IscwJQSAUY/SfR1Pk7z3bI/AAAAAAAAAJA/UnD7Wt-AkUk/s1600-h/client+architecture+overview.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 229px;" src="http://4.bp.blogspot.com/_5IscwJQSAUY/SfR1Pk7z3bI/AAAAAAAAAJA/UnD7Wt-AkUk/s400/client+architecture+overview.jpg" alt="" id="BLOGGER_PHOTO_ID_5329013169559166386" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify; font-family: verdana;"&gt;The client application is the part of &lt;a href="http://mypetprojects.blogspot.com/2009/04/determining-body-movement-with-mobile.html"&gt;solution&lt;/a&gt; which runs on mobile devices. In general Android applications consit of the following elements:&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify; font-family: verdana;"&gt;&lt;li&gt;Foreground Activity (Class with processes wihich run in the foreground and enable user interaction - User Interface)&lt;/li&gt;&lt;li&gt;Background Service (Class with processes which run in the background and exchange data with foreground activity and other services)&lt;/li&gt;&lt;li&gt;Intermittent Activity (The processes which can be modified directly by user and run in the background after user's modifications)&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family:verdana;"&gt;In case of &lt;a href="http://mypetprojects.blogspot.com/2009/04/determining-body-movement-with-mobile.html"&gt;solution for motion determination&lt;/a&gt; the main client's task is to retrieve the values from acceleration sensor. Optionally, in case we want to enable automatic emergency call with location report, the client has to determine the location by simply reading GPS values or getting the information from available web services which are able to determine the approximate location by base station the phone currently uses.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;In order to enable storing informations for later motion analysis in case the internet connection is unavailable, we can add the database and the logic for data storing and later retrieval before sending.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The picture represents the client application concept. The red rectangles represent activities and blue are the services.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;The application consits of three dialogs: main dialog, login and settings. The main dialog displays current activity status, acceleration values and location informations. On application start the user has to sign-in to the server with username and password so at the beginning the login dialog appears. Some options modifications such as enable/disable location report are possible by using Settings dialog.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;There are four services running&lt;/span&gt;&lt;span style="font-family:verdana;"&gt; in the background . The Location Service retrieves the location informations and broadcasts the location data which are received at main (GaitLink) activity, Communication Service and optionally at Database Service. The Acceleration Service retrieves the data from accelerometers and also broadcasts the data which are received by the same components.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;The Database Service listens for the broadcasted messages which can represent the data that have to be stored or the commands for data reading and sending to Communication Service.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Communication Service implements multiple threads. Broadcast Receivers for acceleration and location messages run in separate thread. Every received message is sent to queue. Another thread is periodically retrieving the messages from queues and send the messages to the server. In order to prevent queue congestion the reading frequency has to be higher than queue writing frequency.&lt;/span&gt; &lt;span style="font-family:verdana;"&gt;The main reason for using queues are possible transitory network delays or drops. Without intermediate measurements storing to the queue every value would have to be successfully sent before reading next values from the sensors which is certainly fair too unreliable.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/PNuWjTXF31w" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/3769468344642833975/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2009/04/client-architecture-conceptual-overview.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/3769468344642833975?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/3769468344642833975?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/PNuWjTXF31w/client-architecture-conceptual-overview.html" title="Client Architecture: Conceptual Overview" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_5IscwJQSAUY/SfR1Pk7z3bI/AAAAAAAAAJA/UnD7Wt-AkUk/s72-c/client+architecture+overview.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2009/04/client-architecture-conceptual-overview.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUUCSXc4fSp7ImA9WxJTF0g.&quot;"><id>tag:blogger.com,1999:blog-5507856583232570887.post-458235411986157166</id><published>2009-04-25T06:23:00.010+02:00</published><updated>2009-04-26T16:47:48.935+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-26T16:47:48.935+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="body movement" /><category scheme="http://www.blogger.com/atom/ns#" term="acceleration" /><category scheme="http://www.blogger.com/atom/ns#" term="android" /><title>Determining Body Movement with Mobile Phone</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/SfR0BIkPYLI/AAAAAAAAAIw/4D-dYTlQr-E/s1600-h/solution+overview.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 173px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/SfR0BIkPYLI/AAAAAAAAAIw/4D-dYTlQr-E/s400/solution+overview.jpg" alt="" id="BLOGGER_PHOTO_ID_5329011821914316978" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify; font-family: verdana;"&gt;Currently I'm trying to develop a solution which would determine the type of movement by measuring accelerations with mobile phone.&lt;br /&gt;&lt;br /&gt;By reading acceleration data many things can be discovered. The persons's walk pattern is almost as unique as fingerprint. By reading the walk (movement) patterns early stages of a possible disease could be recognized as well. Another thing that could be implemented is fall/collision detection and automatic emergency call. These are just a few of the possible uses of the solution.&lt;br /&gt;&lt;br /&gt;So far the mobile devices haven't been powerful enough to perform all the required processes independently, but luckily the data transmission is cheap and fast enough so the main analysis can be performed on the server.&lt;br /&gt;&lt;br /&gt;The accelerometers are cheap so almost every new phone have built-in sensors. Currently I'm using HTC Dream G1 (Android) phone and developing client application in Java. The server-side application has been built in C# .NET.&lt;br /&gt;&lt;br /&gt;So far I have established the connection between the phone and server. The phone sends the location data and acceleration measurements to the server which runs the analysis.&lt;br /&gt;I've managed to determine some simple user behaviour patterns such as walk, run and rest by measuring the frequency components of the pattern.&lt;br /&gt;&lt;br /&gt;Below there are the charts for collision and walk in time and frequency domain.&lt;br /&gt;&lt;br /&gt;These are the acceleration values of simulated collision:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/SfKZHvW_ZVI/AAAAAAAAAIA/AJV6M0fbtNM/s1600-h/collision.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/SfKZHvW_ZVI/AAAAAAAAAIA/AJV6M0fbtNM/s400/collision.jpg" alt="" id="BLOGGER_PHOTO_ID_5328489667383747922" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_5IscwJQSAUY/SfKZHyzfvNI/AAAAAAAAAII/1Fh7W0TuXbU/s1600-h/collision-fft.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 214px;" src="http://3.bp.blogspot.com/_5IscwJQSAUY/SfKZHyzfvNI/AAAAAAAAAII/1Fh7W0TuXbU/s400/collision-fft.jpg" alt="" id="BLOGGER_PHOTO_ID_5328489668308614354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;and these are the accelerations of walk:&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_5IscwJQSAUY/SfKZHwRm9pI/AAAAAAAAAIQ/3kBJKOkJxQs/s1600-h/walk.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 215px;" src="http://2.bp.blogspot.com/_5IscwJQSAUY/SfKZHwRm9pI/AAAAAAAAAIQ/3kBJKOkJxQs/s400/walk.jpg" alt="" id="BLOGGER_PHOTO_ID_5328489667629610642" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_5IscwJQSAUY/SfKZICOIupI/AAAAAAAAAIY/qCUsGJo2ghM/s1600-h/walk-fft.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 213px;" src="http://1.bp.blogspot.com/_5IscwJQSAUY/SfKZICOIupI/AAAAAAAAAIY/qCUsGJo2ghM/s400/walk-fft.jpg" alt="" id="BLOGGER_PHOTO_ID_5328489672446884498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In both cases The DFT has been performed on 32 sample points at sampling frequency 2.5 Hz.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_5IscwJQSAUY/SfKa5otpaHI/AAAAAAAAAIg/w1onC5cXTWE/s1600-h/walk+screen.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 267px; height: 400px;" src="http://4.bp.blogspot.com/_5IscwJQSAUY/SfKa5otpaHI/AAAAAAAAAIg/w1onC5cXTWE/s400/walk+screen.png" alt="" id="BLOGGER_PHOTO_ID_5328491624104814706" border="0" /&gt;&lt;/a&gt;This is the phone screen (any suggestion about the design is more than welcome). The phone gets the location address by performing reverse geocoding (part of the existing framework) and the activity status by questioning the server.&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MyPetProjects/~4/lvTYPcdA5Z8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://mypetprojects.blogspot.com/feeds/458235411986157166/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://mypetprojects.blogspot.com/2009/04/determining-body-movement-with-mobile.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/458235411986157166?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5507856583232570887/posts/default/458235411986157166?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MyPetProjects/~3/lvTYPcdA5Z8/determining-body-movement-with-mobile.html" title="Determining Body Movement with Mobile Phone" /><author><name>Niko</name><uri>http://www.blogger.com/profile/03549314951981089987</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://3.bp.blogspot.com/-TyNjUGuEqGc/Ts86N6EC4YI/AAAAAAAAAbo/1nROuqUI-3s/s220/gamulin.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_5IscwJQSAUY/SfR0BIkPYLI/AAAAAAAAAIw/4D-dYTlQr-E/s72-c/solution+overview.jpg" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://mypetprojects.blogspot.com/2009/04/determining-body-movement-with-mobile.html</feedburner:origLink></entry></feed>
