<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pete Tracey &#187; Peter Tracey</title>
	<atom:link href="http://www.petetracey.com/tag/peter-tracey/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.petetracey.com</link>
	<description>A blog about music and technology and miscellaneous other things that make up my life</description>
	<lastBuildDate>Fri, 10 Jun 2011 15:53:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Card Swipe for BlackBerry</title>
		<link>http://www.petetracey.com/2009/12/card-swipe-for-blackberry/</link>
		<comments>http://www.petetracey.com/2009/12/card-swipe-for-blackberry/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 11:23:20 +0000</pubDate>
		<dc:creator>Pete Tracey</dc:creator>
				<category><![CDATA[Keyring Labs]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[BlackBerry Point of Sale]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Peter Tracey]]></category>

		<guid isPermaLink="false">http://www.petetracey.com/?p=73</guid>
		<description><![CDATA[It&#8217;s been a good morning. I took the code from the manufacturer&#8217;s website and hooked it all in so that a BlackBerry should theoretically connect to the device and read card information. Now that I know the code is, well, sane, I can actually get the device with no worry that it&#8217;ll be a nightmare [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a good morning. I took the code from the manufacturer&#8217;s website and hooked it all in so that a BlackBerry should theoretically connect to the device and read card information. Now that I know the code is, well, sane, I can actually get the device with no worry that it&#8217;ll be a nightmare to interface with it from Java code. When I have it working with the device I&#8217;ll post an update here.</p>
<p>Here&#8217;s what the BlackBerry will show when no P25M is connected:<br />
<img class="alignnone size-full wp-image-74" title="bbpointofsale.com P25M not connected" src="http://www.petetracey.com/wp-content/uploads/2009/12/cantconnect.jpg" alt="bbpointofsale.com P25M not connected" width="243" height="405" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.petetracey.com/2009/12/card-swipe-for-blackberry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KSoap with PHP Tutorial</title>
		<link>http://www.petetracey.com/2009/11/ksoap-with-php-tutorial/</link>
		<comments>http://www.petetracey.com/2009/11/ksoap-with-php-tutorial/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 09:21:52 +0000</pubDate>
		<dc:creator>Pete Tracey</dc:creator>
				<category><![CDATA[Keyring Labs]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[BlackBerry Point of Sale]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[KSoap]]></category>
		<category><![CDATA[Peter Tracey]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.petetracey.com/?p=43</guid>
		<description><![CDATA[This post is for:
You: developing a BlackBerry application in KSoap2 with PHP as the server
If that doesn&#8217;t describe you, don&#8217;t read this post!
If that does describe you, hope you enjoy!
The first step is to preverify your KSoap jar file. Copy ksoap2-j2me-core-2.1.2.jar to C:\Program Files\Eclipse\plugins\net.rim.eide.componentpack4.5.0_4.5.0.16\components\bin
Make sure the JDK is in your PATH environment varaible.
Then run:

preverify -classpath [...]]]></description>
			<content:encoded><![CDATA[<p>This post is for:<br />
You: developing a BlackBerry application in KSoap2 with PHP as the server</p>
<p>If that doesn&#8217;t describe you, don&#8217;t read this post!<br />
If that does describe you, hope you enjoy!</p>
<p>The first step is to preverify your KSoap jar file. Copy ksoap2-j2me-core-2.1.2.jar to C:\Program Files\Eclipse\plugins\net.rim.eide.componentpack4.5.0_4.5.0.16\components\bin</p>
<p>Make sure the JDK is in your PATH environment varaible.</p>
<p>Then run:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">preverify <span style="color: #339933;">-</span>classpath <span style="color: #0000ff;">&quot;JDE_PATH_HERE<span style="color: #000099; font-weight: bold;">\l</span>ib<span style="color: #000099; font-weight: bold;">\n</span>et_rim_api.jar&quot;</span> <span style="color: #0000ff;">&quot;ksoap2-j2me-core-2.1.2.jar&quot;</span></pre></div></div>

<p>Preverify put a new jar into an &#8220;output&#8221; directory in that folder. Copy that to where you put the original jar.</p>
<p>Now add that jar in your eclipse project by clicking on your project properties and going to &#8220;Java Build Path&#8221; &#8211; make sure you click on &#8220;Order and Export&#8221; and check the box that tells it to export it.</p>
<p>Well here&#8217;s where the rubber meets the road, you need KSoap to talk to PHP. I created a &#8220;Service&#8221; class which handles all the communication with the server:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ksoap2.SoapEnvelope</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ksoap2.SoapFault</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ksoap2.serialization.SoapObject</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ksoap2.serialization.SoapSerializationEnvelope</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.ksoap2.transport.HttpTransport</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.xmlpull.v1.XmlPullParserException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Service <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> action <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://keyringlabs.com/Login&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> namespaceRoot <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;keyringlabs.com&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> webroot <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://192.168.1.2/bbpointofsale.com/&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> errorMessage<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> key<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> transactionID<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> HttpTransport transport<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> SoapSerializationEnvelope envelope<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Service<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		transport <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpTransport<span style="color: #009900;">&#40;</span>webroot <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;bb/service/index.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		transport.<span style="color: #006633;">debug</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		envelope <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapSerializationEnvelope<span style="color: #009900;">&#40;</span>SoapEnvelope.<span style="color: #006633;">VER10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		key <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A request is made by setting parameters and getting back a parameter, getting back more than one parameter is left as an exercise for the reader. Here&#8217;s what I&#8217;ve done:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> ProcessLogin<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> email, <span style="color: #003399;">String</span> password<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ProcessLogin&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	errorMessage <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003399;">String</span> namespace <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;urn:&quot;</span> <span style="color: #339933;">+</span> namespaceRoot <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;:login&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	SoapObject message <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapObject<span style="color: #009900;">&#40;</span>namespace, <span style="color: #0000ff;">&quot;login&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	message.<span style="color: #006633;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;email&quot;</span>, email<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	message.<span style="color: #006633;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;password&quot;</span>, password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	envelope.<span style="color: #006633;">bodyOut</span> <span style="color: #339933;">=</span> message<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003399;">String</span> soapAction <span style="color: #339933;">=</span> namespace <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;#login&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
		transport.<span style="color: #006633;">call</span><span style="color: #009900;">&#40;</span>soapAction, envelope<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error: &quot;</span><span style="color: #339933;">+</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		errorMessage <span style="color: #339933;">=</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;response: &quot;</span><span style="color: #339933;">+</span>transport.<span style="color: #006633;">responseDump</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>XmlPullParserException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		errorMessage <span style="color: #339933;">=</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;response: &quot;</span><span style="color: #339933;">+</span>transport.<span style="color: #006633;">responseDump</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
		SoapObject result <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>SoapObject<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SoapObject<span style="color: #009900;">&#41;</span>envelope.<span style="color: #006633;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		key <span style="color: #339933;">=</span> hackToGetResponse<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;serviceToken&quot;</span>, result.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>key.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;KEY:&quot;</span> <span style="color: #339933;">+</span> key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>SoapFault e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		errorMessage <span style="color: #339933;">=</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;response: &quot;</span><span style="color: #339933;">+</span>transport.<span style="color: #006633;">responseDump</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		errorMessage <span style="color: #339933;">=</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;response: &quot;</span><span style="color: #339933;">+</span>transport.<span style="color: #006633;">responseDump</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>hackToGetResponse is necessary because the return of the PHP page the request is sent to is difficult to get at through KSoap. This is hackToGetResponse:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> hackToGetResponse<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> key, <span style="color: #003399;">String</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hackToGetResponse:&quot;</span> <span style="color: #339933;">+</span> response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> start <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;anyType{key=&quot;</span> <span style="color: #339933;">+</span> key <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;; value=&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> end <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;; }&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>start<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">||</span>
		response.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>end<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hackToGetResponse:&quot;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;response.substring(0, &quot;</span> <span style="color: #339933;">+</span> response.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>start<span style="color: #009900;">&#41;</span>  <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;).substring(0, &quot;</span> <span style="color: #339933;">+</span> response.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>end<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;);&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	response <span style="color: #339933;">=</span> response.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>start<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> start.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	response <span style="color: #339933;">=</span> response.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, response.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>end<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;anyType{}&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">return</span> response<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And finally, the PHP code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$server</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapServer<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'uri'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;urn:keyringlabs.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addFunction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;login&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> login<span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pass</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'serviceToken'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pass</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'serviceToken'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$objMerchant</span> <span style="color: #339933;">=</span> Merchant<span style="color: #339933;">::</span><span style="color: #004000;">LoadByEmailPassword</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$objMerchant</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$objMerchant</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Id</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'serviceToken'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #990000;">uniqid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$objSess</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Merchantsessions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$objSess</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">MerchantID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$objMerchant</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Id</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$objSess</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ServiceToken</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$objSess</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'serviceToken'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>That&#8217;s it, a BlackBerry application that communicates with a PHP application with very little legwork. I hope this is useful to some people, it was a long journey for me to arrive at this code.</p>
<p>When I have some time I will make the Service class multi-threaded (as it should be being that it does network connections), I will post an update here when I&#8217;ve done that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.petetracey.com/2009/11/ksoap-with-php-tutorial/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Coming Along Good!</title>
		<link>http://www.petetracey.com/2009/11/coming-along-good/</link>
		<comments>http://www.petetracey.com/2009/11/coming-along-good/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 12:57:16 +0000</pubDate>
		<dc:creator>Pete Tracey</dc:creator>
				<category><![CDATA[Keyring Labs]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[BlackBerry Point of Sale]]></category>
		<category><![CDATA[Peter Tracey]]></category>

		<guid isPermaLink="false">http://www.petetracey.com/?p=32</guid>
		<description><![CDATA[The new version of bbpointofsale.com is almost ready. It is now a java application instead of a web-based application. It integrates with a card swipe and receipt printer machine that doesn&#8217;t cost much. Besides those two things not much has changed.


]]></description>
			<content:encoded><![CDATA[<p>The new version of bbpointofsale.com is almost ready. It is now a java application instead of a web-based application. It integrates with a card swipe and receipt printer machine that doesn&#8217;t cost much. Besides those two things not much has changed.</p>
<p><img class="alignnone size-full wp-image-31" title="cardswipe" src="http://www.petetracey.com/wp-content/uploads/2009/11/cardswipe2.jpg" alt="cardswipe" width="148" height="116" /></p>
<p><img class="alignnone size-full wp-image-33" title="screen1" src="http://www.petetracey.com/wp-content/uploads/2009/11/screen1.jpg" alt="screen1" width="345" height="604" /><img class="alignnone size-full wp-image-34" title="screen2" src="http://www.petetracey.com/wp-content/uploads/2009/11/screen2.jpg" alt="screen2" width="345" height="604" /><img class="alignnone size-full wp-image-35" title="screen3" src="http://www.petetracey.com/wp-content/uploads/2009/11/screen3.jpg" alt="screen3" width="345" height="604" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.petetracey.com/2009/11/coming-along-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Card Swipe</title>
		<link>http://www.petetracey.com/2009/11/card-swipe/</link>
		<comments>http://www.petetracey.com/2009/11/card-swipe/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 12:15:44 +0000</pubDate>
		<dc:creator>Pete Tracey</dc:creator>
				<category><![CDATA[Keyring Labs]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[BlackBerry Point of Sale]]></category>
		<category><![CDATA[Peter Tracey]]></category>

		<guid isPermaLink="false">http://www.petetracey.com/?p=19</guid>
		<description><![CDATA[Hard at work on a new version of the BlackBerry Point of Sale system which will integrate with a mobile card swipe and receipt printer combination machine. Found a supplier that has good machines for a good price. I am thinking about posting a tutorial here on my experience developing a java application for the [...]]]></description>
			<content:encoded><![CDATA[<p>Hard at work on a new version of the BlackBerry Point of Sale system which will integrate with a mobile card swipe and receipt printer combination machine. Found a supplier that has good machines for a good price. I am thinking about posting a tutorial here on my experience developing a java application for the BlackBerry when it is complete.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.petetracey.com/2009/11/card-swipe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bbpointofsale.com</title>
		<link>http://www.petetracey.com/2009/09/bbpointofsale-com/</link>
		<comments>http://www.petetracey.com/2009/09/bbpointofsale-com/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 10:14:15 +0000</pubDate>
		<dc:creator>Pete Tracey</dc:creator>
				<category><![CDATA[Keyring Labs]]></category>
		<category><![CDATA[BlackBerry Point of Sale]]></category>
		<category><![CDATA[Peter Tracey]]></category>

		<guid isPermaLink="false">http://www.petetracey.com/?p=14</guid>
		<description><![CDATA[I&#8217;ve put the store system with click to chat on the back burner for a while. I developed a system that allows people to take credit card payments on their BlackBerry. I&#8217;ve launched it at www.bbpointofsale.com
The first sign up was last Wednesday, basically just a few days after there was any traffic going to the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve put the store system with click to chat on the back burner for a while. I developed a system that allows people to take credit card payments on their BlackBerry. I&#8217;ve launched it at <a title="BlackBerry Point of Sale" href="http://www.bbpointofsale.com" target="_blank">www.bbpointofsale.com</a></p>
<p>The first sign up was last Wednesday, basically just a few days after there was any traffic going to the site at all. If things keep going this way it could end up being successful.</p>
<p>I&#8217;m still planning to pursue my original strategy but this looked like an opportunity for a service that could have some activity right out of the gates.</p>
<p>I&#8217;ll post updates here as the service grows.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.petetracey.com/2009/09/bbpointofsale-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Post</title>
		<link>http://www.petetracey.com/2009/09/first-post/</link>
		<comments>http://www.petetracey.com/2009/09/first-post/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 17:45:03 +0000</pubDate>
		<dc:creator>Pete Tracey</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Peter Tracey]]></category>

		<guid isPermaLink="false">http://www.petetracey.com/?p=5</guid>
		<description><![CDATA[It’s 2009 and this is my first blog post. I’ve never really had much to say so I didn’t want to waste people’s time with rambling about nothing. However, I am currently in the process of (re)launching an application software provider company and would like to blog about the progress and the technology I am [...]]]></description>
			<content:encoded><![CDATA[<p>It’s 2009 and this is my first blog post. I’ve never really had much to say so I didn’t want to waste people’s time with rambling about nothing. However, I am currently in the process of (re)launching an application software provider company and would like to blog about the progress and the technology I am working on. That will not be my only topic, I am also a musician and will be writing about that relatively often. So I hope anyone reading this will check back every so often, I am very excited about what I am doing and promise not to bore.</p>
<p>So here is what I am working on. I’ve been a programmer for 10 years and during that time have put some work into my own software systems. The two systems I’m resurrecting are an online store system and a click to chat system. I plan to let people have an online store with click to chat at a very low (or free) price. I also will be launching a portal to all of the stores once critical mass is reached. I have started efforts of my own in the past and failed, so I am not getting my hopes up, but there is always the chance that this time will be different. If it bombs all I’ve lost is some spare time and gained invaluable experience. I will continue to post updates here as the launch approaches, stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.petetracey.com/2009/09/first-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

