<?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>Adam Trachtenberg &#187; soap</title>
	<atom:link href="http://www.trachtenberg.com/blog/tag/soap/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trachtenberg.com/blog</link>
	<description>Thoughts on PHP, eBay, and too many technical topics for my family's liking.</description>
	<lastBuildDate>Tue, 24 Aug 2010 21:39:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>REST vs HTTP+POX vs SOAP</title>
		<link>http://www.trachtenberg.com/blog/2006/11/06/rest-vs-httppox-vs-soap/</link>
		<comments>http://www.trachtenberg.com/blog/2006/11/06/rest-vs-httppox-vs-soap/#comments</comments>
		<pubDate>Mon, 06 Nov 2006 08:29:34 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[pox]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[soap]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/11/06/rest-vs-httppox-vs-soap/</guid>
		<description><![CDATA[<a href="http://www.intertwingly.net/blog/2006/11/05/POX-and-SOAP">Sam</a> and <a href="http://www.crummy.com/2006/11/05/2">Leonard</a> ponder the differences among them. Here's the deal:

<ol>
<li>REST == HTTP GET</li>
<li>HTTP+POX == HTTP GET &#038; POST</li>
<li>SOAP == HTTP POST, with interop issues</li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.intertwingly.net/blog/2006/11/05/POX-and-SOAP">Sam</a> and <a href="http://www.crummy.com/2006/11/05/2">Leonard</a> ponder the differences among them. Here&#8217;s the deal:</p>
<ol>
<li>REST == HTTP GET</li>
<li>HTTP+POX == HTTP GET &#038; POST</li>
<li>SOAP == HTTP POST, with interop issues</li>
</ol>
<p><span id="more-665"></span><br />
When I&#8217;m talking to people about web services, and I hear them use various terms, this is what I feel they&#8217;re talking about most of the time.</p>
<p><strong>REST</strong></p>
<p>REST almost always indicates HTTP GET with a query string. The results are probably XML, but lately they could also be JSON.</p>
<p>No other HTTP verbs are used (especially PUT and DELETE), and it&#8217;s highly likely that all requests are routed through the same URI.</p>
<p>For example:</p>
<p>http://api.example.org/rest?action=search&#038;query=trachtenberg</p>
<p><strong>HTTP+POX</strong></p>
<p>Nobody uses this term. However, there are some web services that, while not &#8220;true REST,&#8221; use more than HTTP GET. I place them in this category.</p>
<p>These likely exist because the service allows you to submit a large quantity of data that is not human readable, so it does not make sense to place as part of a query string. Blobs of HTML and pictures come to mind.</p>
<p>For example, the eBay &#8220;XML API&#8221;. You can submit items over eBay web services. Since the item description is pure HTML, it exceeded the maximum query string length our web server would accept at the time.</p>
<p>Thus, the eBay XML API was invented: you HTTP POST an XML document, we return an XML document.</p>
<p>Again, like REST, there&#8217;s no concept of resources. Everything goes through the same URI. The action is indicated either as part of the query string or in POST body. (Or both, as in the eBay case.)</p>
<p><strong>SOAP</strong></p>
<p>SOAP is identical to HTTP+POX, except that you&#8217;re required to use XML Namespaces and XML Schema.</p>
<p>You are also going to have interop issues when trying to generate the SOAP envelope to send or parse the SOAP envelope that&#8217;s returned.</p>
<p>XML Namespaces and XML Schema are minor headaches, but people are willing to deal with them. People understand that, in theory, namespaces are good, even if XML Namespaces are a little funky.</p>
<p>XML Schema can be confusing. However, it does allow you to validate the response, which most people find to be somewhat useful. The fact that XML Schema may not be the best way to describe XML data is a different issue.</p>
<p>If SOAP merely had these two issues, people would work through it. The real problem with SOAP is that the specification is so confusing, people can&#8217;t build interoperable clients and servers. This drives people mad.</p>
<p>People know how to generate arbitrary XML (it&#8217;s just text after all) and send a HTTP POST request. They also know how to parse XML, particularly when they know ahead of time what they should expect. (That&#8217;s why PHP 5&#8217;s SimpleXML extension is a great web services client.)</p>
<p>What they cannot do is decipher a WSDL file to determine what crazy combination of XML the server is expecting (especially when the server is not following the standard). And, assuming they can get through that, they cannot figure out how to repeatedly hammer their SOAP client into producing the magical combination of XML necessary to placate the SOAP server.</p>
<p>That&#8217;s the difference between HTTP+POX and SOAP.</p>
<p>It&#8217;s not the complexity. Well, it&#8217;s not complexity in terms of needing to build up a large document. It&#8217;s complexity in terms of trying to understand the hundreds of pages of XML specifications to generate the request and not having good examples of working XML documents to crib off of.</p>
<p>As to whether the message name should go in the URI? Nobody cares.</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=665&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/11/06/rest-vs-httppox-vs-soap/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Imitation == Flattery</title>
		<link>http://www.trachtenberg.com/blog/2006/10/21/imitation-flattery/</link>
		<comments>http://www.trachtenberg.com/blog/2006/10/21/imitation-flattery/#comments</comments>
		<pubDate>Sun, 22 Oct 2006 04:52:29 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[speaking]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/10/21/imitation-flattery/</guid>
		<description><![CDATA[As most of you know, I work in the cut-throat world of web services. Us evangelists are always jockeying for the best developers, and we'll take any advantage we can. No holds are <a href="http://www.syndic8.com/weblog/">(Jeff) barred</a>. If you come up with a good edge, you better use it before someone tries to take it away.]]></description>
			<content:encoded><![CDATA[<p>As most of you know, I work in the cut-throat world of web services. Us evangelists are always jockeying for the best developers, and we&#8217;ll take any advantage we can. No holds are <a href="http://www.syndic8.com/weblog/">(Jeff) barred</a>. If you come up with a good edge, you better use it before someone tries to take it away.</p>
<p>For example, at this year&#8217;s ETech, I broke through with a killer presentation titled: &#8220;<a href="http://conferences.oreillynet.com/cs/et2006/view/e_sess/8513">eBay Web Services: A Marketplace Platform <em>for Fun and Profit</em></a>.&#8221;</p>
<p>Knowing a good thing when he sees it, <a href="http://blog.chanezon.com/">Patrick</a> from Google tries to respond at this month&#8217;s <a href="http://zendcon.com/speakers_list.php">ZendCon</a> with: &#8220;Scrub (Ajax), Wash (SOAP) and REST: use Google Checkout and AdWords APIs with PHP <em>for fun and profit</em>.&#8221;<br />
<span id="more-657"></span><br />
Mixed metaphors and the ugly imagery of Patrick in the shower aside, I am not put off in even a small way by his outright thievery. For I am already sixteen steps ahead.</p>
<p>I am proud to introduce, coming on October 31th, for the very first time, my latest and greatest talk: &#8220;eBay Web services: Great platform or greatest platform?&#8221;</p>
<p>Truly <a href="http://www.colbertnation.com/">Lincolnish</a>.</p>
<p><em>PS: You are only allowed to read this if you have a sense of humor. This is meant to be funny. I don&#8217;t think Patrick is going around stealing all my talk titles, or even just my good talk titles. Besides, I am stealing my most recent one from Stephen Cobert, so I can&#8217;t really claim ownership to that now can I?</em></p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=657&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/10/21/imitation-flattery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP SOAP vs. SDO</title>
		<link>http://www.trachtenberg.com/blog/2006/10/12/php-soap-vs-sdo/</link>
		<comments>http://www.trachtenberg.com/blog/2006/10/12/php-soap-vs-sdo/#comments</comments>
		<pubDate>Thu, 12 Oct 2006 22:21:29 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[speaking]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/10/12/php-soap-vs-sdo/</guid>
		<description><![CDATA[In my role as eBay Platform Evangelist, I spend a lot of time exploring different XML technologies.
SOAP is obviously the big one. I use the PHP 5 ext/soap extension, which is great, but there&#8217;s actually another PHP SOAP extension that might be even better. No, it&#8217;s not PEAR::SOAP or NuSOAP; it&#8217;s axis2.

If you haven&#8217;t heard [...]]]></description>
			<content:encoded><![CDATA[<p>In my role as eBay Platform Evangelist, I spend a lot of time exploring different XML technologies.</p>
<p>SOAP is obviously the big one. I use the PHP 5 ext/soap extension, which is great, but there&#8217;s actually another PHP SOAP extension that might be even better. No, it&#8217;s not PEAR::SOAP or NuSOAP; it&#8217;s <a href="http://pecl.php.net/package/axis2">axis2</a>.<br />
<span id="more-654"></span><br />
If you haven&#8217;t heard of axis2, you&#8217;re not alone. That&#8217;s because it&#8217;s a pecl extension that&#8217;s still in beta, so there aren&#8217;t a lot of people using it yet. However, it&#8217;s a PHP version of the <a href="http://ws.apache.org/axis2/">Apache Axis 2.0</a> SOAP stack.</p>
<p>Unlike ext/soap, which is recreating SOAP one feature at a time, Axis 2.0 already supports a good portion of the WS-* specifications. So all that needs to happen is for someone to write the hooks between PHP and Axis 2.0, which is far easier than actually writing the features themselves.</p>
<p>I met a number of people from WSO2, the company that&#8217;s writing Axis 2.0, and they&#8217;re quite excited about the extension. However, they did mention it&#8217;s still in beta, so I haven&#8217;t actually spent any time using it yet.</p>
<p>The other PHP XML extension I&#8217;ve been hearing a lot about is SDO. SDO is an attempt to provide a standard data interface regardless of the backend datasource. So, for example, you can interact with XML data in the exact same manner as information pulled from your database.</p>
<p>At OSCON and ApacheCon, I&#8217;ve run into a couple of people from IBM who have been doing the heavy lifting on this extension, and we&#8217;ve had a number of interesting chats with them about eBay Web services and SDO, but I hadn&#8217;t had any free time at work to install the extension.</p>
<p>Therefore, when I had a little free time today between the end of my session and lunch, I sat down and reproduced a short code example that I had wrote using ext/soap with SDO instead.</p>
<p>Here&#8217;s the key portion of the original code:</p>
<pre><code>// Print Titles and Mileage
if (isset($response->SearchResultItemArray)) {
    foreach($response->SearchResultItemArray as $item) {
        printf(&quot;%s\n\t%d miles\n&quot;, $item, $item->ItemSpecific['Mileage']);
    }
}</code></pre>
<p>This iterates through a search result for eBay Motors listings and prints out the title and the mileage for each individual item.</p>
<p>Normally the code would be far more complex, but through a series of ext/soap class mappings I wrote that implement the IteratorAggregate and ArrayAccess interfaces, along with the __toString() magic method, I&#8217;ve managed to abstract away a number of the complexities.</p>
<p>Best I can tell, SDO doesn&#8217;t give me quite the same level of control, but it does implement a number of these features for me out-of-the-box.</p>
<p>Here&#8217;s my rewrite using SDO:</p>
<pre><code>foreach ($root->SearchResultItemArray->SearchResultItem as $item) {
    $title = $item->Item->Title;
    $mileage = $item->ItemSpecific[&quot;NameValueList[Name='Mileage']&quot;]->Value[0];
    printf(&quot;%s\n\t%d miles\n&quot;, $title, $mileage);
}</code></pre>
<p>It&#8217;s not quite as brief, but I do get this nice XPath-like filtering that lets me pull out the the value of the car&#8217;s Mileage in one line. Pretty handy.</p>
<p>I had to implement the ArrayAccess interface to get this to work under ext/soap, which included this method:</p>
<pre><code>public function offsetGet($name) {
	if (! is_array($this->NameValueList)) {
		$this->NameValueList = array($this->NameValueList);
	}

	foreach ($this->NameValueList as $NameValueList) {
		if ($NameValueList->Name == $name) {
			return $NameValueList->Value;
		}
	}

	return null;
}</code></pre>
<p>Not the hardest thing in the world to write, but this is just one of the custom class maps that will arise in our data schema, and SDO takes care of them all automatically.</p>
<p>Still, right now I think I prefer my ability the greater control I have over the interface with ext/soap. Our SOAP schema isn&#8217;t that pretty since there are lots of list, array, and hash wrappers. Through classmaps and interfaces I can turn these into native-looking PHP arrays and hashes.</p>
<p>I may be introducing a leaky abstraction, but I think this is better than exposing a NameValueListArrayType for people to wrangle with.</p>
<p>Like ext/soap, SDO requires you to define your data using an XML Schema. While we actually publish a stand alone XML Schema file, SDO will also happily parse a WSDL file, too, which is nice.</p>
<p>However, it will not directly consume a SOAP message because the WSDL doesn&#8217;t include any mention of the SOAP envelope wrapper. I needed to rip out the contents of the SOAP body into a separate XML document in order to get SDO to parse my data. Oddly, this corresponds perfectly with our &#8220;XML API,&#8221; so I could use that to retrieve properly formatted data that I can pass directly to SDO.</p>
<p>Where SDO really falls down for me is performance. Admittedly, eBay is a pathological case, but our WSDL file is 2.94 Megs in size. When I feed that to SDO, it takes 8.5 seconds to process the XML Schema data. Yikes!</p>
<p>I don&#8217;t mind a one-time start up hit, but it doesn&#8217;t appear that SDO can cache a parsed version of the schema. In contrast, ext/soap has both an on-disk and in-memory WSDL cache.</p>
<p>This means it takes SDO about 8.7 seconds to process the schema, load in data, and print out the information &#8212; and all with locally stored files.</p>
<p>In contrast, ext/soap takes as little as 0.55 seconds to pull in a cached version of the WSDL from the disk, go out over the network to query eBay via SOAP, wait for eBay&#8217;s SOAP server to run a database query on its end and send back a SOAP response, parse the SOAP envelope, and print out the exact same data. If I was using the in-memory cache, I think it&#8217;d be even faster, and I&#8217;m sure the big bottleneck here is talking to eBay.</p>
<p>Now, I&#8217;ve spent all of 60 minutes playing with SDO, so it&#8217;s quite possible that I&#8217;m missing some obvious configuration flag. If not, I hope IBM can do something to help speed up the performance, since while I could probably write a script to break apart our schema to create individual files that contain all the possible types on a per-call basis, I am hoping I don&#8217;t need to.</p>
<p>In the meantime, I&#8217;m going to continue exploring SDO to see what else I can do with it because I&#8217;ve sure I&#8217;ve only grazed its surface.</p>
<p><em>[Update: I cannot get the axis2 extension to compile, despite trying a number of different versions of Axis2c and both Linux and Mac OS X. I may try again tomorrow.]</em></p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=654&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/10/12/php-soap-vs-sdo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fall 2006 PHP Speaking Calendar</title>
		<link>http://www.trachtenberg.com/blog/2006/09/08/php-speaking-calendar/</link>
		<comments>http://www.trachtenberg.com/blog/2006/09/08/php-speaking-calendar/#comments</comments>
		<pubDate>Fri, 08 Sep 2006 21:58:58 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Working]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[speaking]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/09/08/php-speaking-calendar/</guid>
		<description><![CDATA[I have a number of PHP related speaking gigs coming up:

DC PHP
ApacheCon
Zend/PHP Conference


I think I submitted a slightly different abstract for each conference, but the main core of all the presentations is the same: a case study of Dude, Where&#8217;s My Used Car, my eBay Motors / Google Maps mashup.
In particular, I show how I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I have a number of PHP related speaking gigs coming up:</p>
<ul>
<li><a href="http://www.dcphpconference.com/schedule.php">DC PHP</a></li>
<li><a href="http://www.us.apachecon.com/">ApacheCon</a></li>
<li><a href="http://zendcon06.kbconferences.com/">Zend/PHP Conference</a></li>
</ul>
<p><span id="more-640"></span><br />
I think I submitted a slightly different abstract for each conference, but the main core of all the presentations is the same: a case study of <a href="http://www.dudewheresmyusedcar.com">Dude, Where&#8217;s My Used Car</a>, my eBay Motors / Google Maps mashup.</p>
<p>In particular, I show how I&#8217;m using the PHP 5 SOAP extension alongside magical methods and other PHP 5 goodness to provide a simple interface into eBay Web services. If you&#8217;ve never played with either ext/soap, the new OOP features, or SPL, then my goal is to introduce you to all the cool things they enable &#8212; things you cannot do in PHP 4.</p>
<p>If I get a chance to rewrite the front end AJAX code using a nice library, such as Dojo or YUI, I&#8217;ll show how I bind the data between the client and the server. Right now, the that particular code is handrolled, and totally sucks, so I won&#8217;t be showing that off. :)</p>
<p>If you&#8217;re going to ApacheCon, I am looking to roadtrip to <a href="http://www.texasbbqtrail.com/lockhart.php">Lockhart, TX</a> for a little bit of BBQ. Let me know if you&#8217;re interesting in coming along, of if you can suggest someplace else to go instead.</p>
<p>All three conferences have posted their schedules and all three look great! With one of the east coast, one in the middle of the US, and one on the west coast, there&#8217;s bound to be a show close to you. Sign up, come on by, and say hello!</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=640&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/09/08/php-speaking-calendar/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dirty Secrets of OSCON 2006</title>
		<link>http://www.trachtenberg.com/blog/2006/08/07/dirty-secrets-of-oscon-2006/</link>
		<comments>http://www.trachtenberg.com/blog/2006/08/07/dirty-secrets-of-oscon-2006/#comments</comments>
		<pubDate>Mon, 07 Aug 2006 23:17:47 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Working]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[oscon]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[speaking]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/08/07/dirty-secrets-of-oscon-2006/</guid>
		<description><![CDATA[Under the heading of better two weeks late than never, here are my slides for my OSCON talk Dirty Secrets of PHP 5&#8217;s ext/soap Extension.
As usual, I had a great time at the show. It was fun to see all my old friends and make new ones.
]]></description>
			<content:encoded><![CDATA[<p>Under the heading of better two weeks late than never, here are <a href="http://www.trachtenberg.com/talks/dirtysecretssoap.pdf">my slides</a> for my OSCON talk <a href="http://conferences.oreillynet.com/cs/os2006/view/e_sess/8655">Dirty Secrets of PHP 5&#8217;s ext/soap Extension</a>.</p>
<p>As usual, I had a great time at the show. It was fun to see all my old friends and make new ones.</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=617&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/08/07/dirty-secrets-of-oscon-2006/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OSCON 2006 Proposal Accepted</title>
		<link>http://www.trachtenberg.com/blog/2006/03/27/oscon-2006-proposal-accepted/</link>
		<comments>http://www.trachtenberg.com/blog/2006/03/27/oscon-2006-proposal-accepted/#comments</comments>
		<pubDate>Tue, 28 Mar 2006 00:56:12 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Working]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[oscon]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[speaking]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/03/27/oscon-2006-proposal-accepted/</guid>
		<description><![CDATA[This year&#8217;s OSCON isn&#8217;t until July, but I&#8217;m ready to book my tickets because my proposal on &#8220;Dirty secrets of PHP 5&#8217;s ext/soap extension&#8221; was accepted today.
I&#8217;ve spent many months using ext/soap with eBay&#8217;s WSDL writing sample code and testing out various functions. Bit-by-bit I&#8217;ve picked up a number of tricks and discovered quite a [...]]]></description>
			<content:encoded><![CDATA[<p>This year&#8217;s <a href="http://conferences.oreilly.com/oscon/">OSCON</a> isn&#8217;t until July, but I&#8217;m ready to book my tickets because my proposal on &#8220;Dirty secrets of PHP 5&#8217;s ext/soap extension&#8221; was accepted today.</p>
<p>I&#8217;ve spent many months using ext/soap with eBay&#8217;s WSDL writing sample code and testing out various functions. Bit-by-bit I&#8217;ve picked up a number of tricks and discovered quite a few un- (or mis- or poorly) documented features. Thanks to this talk, I will finally have the excuse to put them all together in one place.</p>
<p>Here&#8217;s the official description:</p>
<blockquote><p>PHP 5&#8217;s ext/soap extension is an excellent Web services client. However, while the easy things are easy, lack of documentation means the hard things can appear downright impossible. Starting with SOAPClient basics and building upwards, learn the hidden secrets necessary to conquer even the strangest WSDL.</p></blockquote>
<p>The one bad part about this talk is that I won&#8217;t be giving &#8220;Abracadabra and hocus pocus: Magical methods and PHP 5&#8243; or &#8220;Consuming Web Services Using PHP 5.&#8221; Of the two, the first would have been a blast to give, but I already have slides for the second, which is nice. (Well, I haven&#8217;t heard one way or another about those talks, but I&#8217;m assuming they were rejected. That&#8217;s fine, since I only have time to prepare one talk.)</p>
<p>See you in Portland!</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=472&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/03/27/oscon-2006-proposal-accepted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSCON + NYPHPCon Call For Papers</title>
		<link>http://www.trachtenberg.com/blog/2006/02/12/oscon-nyphpcon-call-for-papers/</link>
		<comments>http://www.trachtenberg.com/blog/2006/02/12/oscon-nyphpcon-call-for-papers/#comments</comments>
		<pubDate>Sun, 12 Feb 2006 18:24:14 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Working]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[nyphp]]></category>
		<category><![CDATA[oscon]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[speaking]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/02/12/oscon-nyphpcon-call-for-papers/</guid>
		<description><![CDATA[ ]]></description>
			<content:encoded><![CDATA[<p>I just submitted by proposals for <a href="http://conferences.oreillynet.com/os2006/">OSCON</a> and <a href="http://www.nyphpcon.com/">NYPHPCon</a>. I hope they get accepted, as I&#8217;m quite excited about both shows.</p>
<p>OSCON is my favorite conference of the year. There&#8217;s nothing else that provides such a wide range of interesting speakers and topics. I love learning about PHP, but I find it even more fascinating to see what the Perl and Python and Ruby guys are hacking on, or pick up JavaScript and AJAX tips, or heckle the Java programmers. :)</p>
<p>The past two years, I&#8217;ve been on the OSCON PHP track conference committee, so it was my job to write friendly reminders in my blog. I&#8217;m not doing that this year, so you can count on this as a unbiased plug for the show.</p>
<p>There are lots of topic areas beyond PHP, such as Web applications and Security, so you don&#8217;t need to be a PHP guru to submit. You just need to be doing something  that other people will find interesting that you can share in an interesting way. The key is that when a conference attendee reads the description of your talk in the program that they say: &#8220;Cool! That sounds neat. I think I&#8217;ll go hear this talk.&#8221;</p>
<p>Last year, I wrote a short post about <a href="http://www.trachtenberg.com/blog/2005/10/07/how-to-speak-at-technical-conferences/">getting your conference proposal accepted</a>. That&#8217;s just my personal philosophy, but I think it holds mostly true for all good conferences. There&#8217;s always the &#8220;I want the biggest names I can get&#8221; philosophy, but if that&#8217;s the case, then there&#8217;s nothing you can do about that anyway.</p>
<p>Proposals are due Monday, so hurry up and <a href="http://conferences.oreillynet.com/cs/os2006/create/e_sess/">submit</a>.</p>
<p>It&#8217;s the first year for NYPHPCon, but Hans and the whole NYPHP crew are great guys, so I know they&#8217;ll put on a teriffic show. When I still lived in NYC, I attended NYPHP user group meetings on a semi-regular basis, and they were even kind enough to let me present once or twice.</p>
<p>In fact, I gave my very first Web services presentation to NYPHP back in February of 2003. I don&#8217;t know if eBay would have hired me as a Web service evangelist if I hadn&#8217;t started down the path of learning about Web services for NYPHP. So, I owe them a big debt of thanks.</p>
<p>Besides, New York City is the best city in the world. Sorry Bay Area neighbors. Although, I certainly don&#8217;t miss the <del datetime="2006-02-12T14:52:3608:00">22.8</del> <ins datetime="2006-02-12T14:52:3608:00">26.9</ins> inches, or <del>.58</del> <ins datetime="2006-02-12T14:52:3608:00">.68</ins> meters for my non-US readers, of snow that got dumped on the city last night. Have I mentioned it&#8217;s 65 degrees (18 celcius) today in San Francisco?</p>
<p>Oh, I almost forgot to mention what talks I submitted. All of them will have an eBay theme, but none of them are 100% eBay advertisements:</p>
<ul>
<li>Consuming Web Services Using PHP 5</li>
<li>Dirty secrets of PHP 5&#8217;s ext/soap extension</li>
<li>Abracadabra and hocus pocus: Magical methods and PHP 5</li>
</ul>
<p>I really like my abstract for the that last talk:</p>
<blockquote><p>PHP 5 provides a number of so-called &#8220;magical methods,&#8221; methods that are automagically invoked to secretly manipulate objects. These __methods() are cool, but when, if ever, are they actually useful? Using an eBay Web services SOAP client as my example, I&#8217;ll demonstrate how a little slight-of-hand and misdirection leads to shorter and more intuitive code.</p></blockquote>
<p>Right now, my eBaySOAP code uses __construct(), __set()/__get(), __call(), __isset(), __toString(), and the IteratorAggregate and ArrayAccess interfaces. If I can get Dmitry to add the hook he promised to ext/soap, I&#8217;ll also add __wakeup(). I&#8217;m sure there are a few more things I can do, but the trick is to only implement useful and intuitive methods, so we&#8217;ll see.</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=453&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/02/12/oscon-nyphpcon-call-for-papers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My eBay Motors Maps Mashup</title>
		<link>http://www.trachtenberg.com/blog/2005/12/19/my-ebay-motors-maps-mashup/</link>
		<comments>http://www.trachtenberg.com/blog/2005/12/19/my-ebay-motors-maps-mashup/#comments</comments>
		<pubDate>Mon, 19 Dec 2005 22:34:12 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2005/12/19/my-ebay-motors-maps-mashup/</guid>
		<description><![CDATA[In my copious free time, I have been writing a little mashup using eBay Motors and Google Maps. This is equal parts eBay Web services marking, a learning exercize, and an excuse to code.
Like all Web 2.0 concepts, it&#8217;s in perpetual beta. (Why does &#8220;perpetual beta&#8221; seem like the Web 2.0 phrase for Web 1.0&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>In my copious free time, I have been writing a little mashup using <a href="http://www.trachtenberg.com/emgm/">eBay Motors and Google Maps</a>. This is equal parts <a href="http://developer.ebay.com">eBay Web services</a> marking, a learning exercize, and an excuse to code.</p>
<p>Like all Web 2.0 concepts, it&#8217;s in perpetual beta. (Why does &#8220;perpetual beta&#8221; seem like the Web 2.0 phrase for Web 1.0&#8217;s &#8220;<a href="http://images.google.com/images?q=this+page+is+under+construction&#038;imgsz=icon">Under Construction</a>&#8221; image?) Thanks to a helpful prod, I sat down this morning and fixed the outstanding IE bugs, so now it works in IE, Firefox, and Safari. That means I can officially blog about it.</p>
<p>For those of you interested in the technical details, the backend code is written in PHP 5. I&#8217;m using the ext/soap extension to talk with eBay Web services and PEAR&#8217;s HTML_QuickForm, HTML_Javascript, and Date packages. I tried to use HTML_AJAX, but it was buggy when I first tried it; I see there have been many recent updates, so I should look again.</p>
<p>Not surprisingly, writing the PHP part was pretty easy. It was the JavaScript code that took forever and a day to write and debug. Many thanks to the <a href="http://www.quirksmode.org/">QuirksMode</a> Web site for documenting cross-browser woes.</p>
<p>Please <a href="http://www.trachtenberg.com/emgm/">check out the site</a> and let me know what you think.</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=418&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2005/12/19/my-ebay-motors-maps-mashup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>eBay SOAP Update: Syntax Matters</title>
		<link>http://www.trachtenberg.com/blog/2005/10/24/ebay-soap-update/</link>
		<comments>http://www.trachtenberg.com/blog/2005/10/24/ebay-soap-update/#comments</comments>
		<pubDate>Mon, 24 Oct 2005 07:04:48 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[upgrading to php 5]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2005/10/23/ebay-soap-update/</guid>
		<description><![CDATA[I saw a request for some actual SOAP code, so I will try and oblige. I don&#8217;t want to publish the entire code because there&#8217;s lots of messy stuff that&#8217;s specific to eBay&#8217;s SOAP API. I&#8217;ll talk about that some other time, but for now, those details just get in the way.
Therefore, I&#8217;ll pull out [...]]]></description>
			<content:encoded><![CDATA[<p>I saw <a href="http://www.phpdeveloper.org/news/4128">a request for some actual SOAP code</a>, so I will try and oblige. I don&#8217;t want to publish the entire code because there&#8217;s lots of messy stuff that&#8217;s specific to eBay&#8217;s SOAP API. I&#8217;ll talk about that some other time, but for now, those details just get in the way.</p>
<p>Therefore, I&#8217;ll pull out a few lines, combine that with some hand waving, and just hope for the best. Here&#8217;s the before:</p>
<pre><code>
$wsdl = 'http://developer.ebay.com/webservices/latest/eBaySvc.wsdl';
$client = new SoapClient($wsdl);

$params = array('Query' => 'ipod');
$results = $client->GetSearchResults($params);

foreach ($results->SearchResultItemArray->SearchResultItem as $item) {
  print $item->Item->Title . &quot;\n&quot;;
}
</code></pre>
<p>Without the <tt>classmap</tt> option, I create a <tt>SoapClient</tt>, make my request, and then iterate through the results to print out the titles of the matching items. This isn&#8217;t complex; however, the iteration is a little klunky due to limitations of SOAP and the design of eBay&#8217;s Web service.</p>
<p>For example, the <tt>SearchResultItemArray</tt> only contains <tt>SearchResultItem</tt>, so it&#8217;s kludgy to reference <tt>SearchResultItemArray->SearchResultItem</tt>. Likewise, when I&#8217;m just getting a quick dump of <tt>Item</tt> information, it&#8217;s not so nice to specifically access the <tt>Title</tt> element.</p>
<p>By defining a couple of classes and telling the SoapClient object map them to the return data, I can clean this up:</p>
<pre><code>
class eBaySearchResultItemArrayType implements IteratorAggregate {
  public function getIterator( ) {
    return new ArrayObject($this->SearchResultItem);
  }
}

class eBaySearchResultItemType {
  public function __toString() {
    return $this->Item->Title . &quot;\n&quot;;
  }
}

$wsdl = 'http://developer.ebay.com/webservices/latest/eBaySvc.wsdl';
$options = array('classmap' => array(
  'SearchResultItemArrayType' => 'eBaySearchResultItemArrayType',
  'SearchResultItemType' => 'eBaySearchResultItemType',
  ),
);

$client = new SoapClient($wsdl, $options);

$params = array('Query' => 'ipod');
$results = $client->GetSearchResults($params);

foreach ($results->SearchResultItemArray as $item) {
  print $item;
}
</code></pre>
<p>To solve my first problem, the iteration, I make  <tt>eBaySearchResultItemArrayType</tt> implement the <tt>IteratorAggregate</tt> interface. When a PHP 5 class implements this interface, PHP will invoke the <tt>getIterator()</tt> method during a <tt>foreach</tt> loop.</p>
<p>In this case, I return <tt>$this->SearchResultItem</tt>, wrapping it inside an <tt>ArrayObject</tt> to make the array iterable.</p>
<p>For the pretty-printing issue, I define a <tt>__toString()</tt> method inside of <tt>eBaySearchResultItemType</tt>. Now, when I print an instance of this class, PHP calls that method instead.</p>
<p>With my classes defined, I use the <tt>classmap</tt> option to map the PHP classes to the SOAP complexTypes, and pass this mapping along as part of the second parameter to the <tt>SoapClient</tt> constructor.</p>
<p>Once this is set up, everything else in the request is identical. However, when I print out the results, the syntax is clean:</p>
<pre><code>
foreach ($results->SearchResultItemArray as $item) {
  print $item;
}
</code></pre>
<p>At one level, this is just syntax and icing. However, I don&#8217;t think you should dismiss syntax with a wave of your hand. To quote Sam Ruby on <a href="http://www.intertwingly.net/blog/2005/09/29/Ruby-1-8-vs-LINQ">C# and LINQ</a>:</p>
<blockquote><p>[S]yntax matters.  Very much so.</p></blockquote>
<p>So, I am convinced that this is a good thing to spend time on. There are a couple other tricks I&#8217;ve pulled out, such as:</p>
<pre><code>
class eBayFeesType implements ArrayAccess {

  public function offsetGet($offset) {
    foreach ($this->Fee as $value) {
      if ($value->Name == $offset) {
        return $value;
      }
    }
  }

  /* and the other interface methods... */
}

class eBayFeeType {
  public function __toString() {
    return (string) $this->Fee->_;
  }
}
</code></pre>
<p>This lets me do:</p>
<pre><code>
echo &quot;Listing fee is: &quot;, $results->Fees['ListingFee'], &quot;\n&quot;;
</code></pre>
<p>Which I must say is far nicer than either iterating in place or even calling out to a utility method.</p>
<p>I was interested to discover that I needed to manually cast <tt>$this->Fee->_</tt> to a string because I thought it was a string. Actually, it is a float, and PHP won&#8217;t autocast floats to strings in this instance.</p>
<p>Personally, I think if PHP should autocast here, but I can see the logic. If you&#8217;re promising to return a string, you should actually return one.</p>
<p>At first, I was writing each class by hand. But that got boring and wasn&#8217;t scalable. Therefore, my new goal is to automate this process. I am writing a script to read the WSDL file, parse out the complexTypes, and then convert them to PHP classes.</p>
<p>My original script was using the <tt>SoapClient::__getTypes()</tt> method as a pre-processor, but I needed to parse that output again to get it into a usable format. After a little digging, I discovered that PEAR::SOAP implements its own parsing routines and gives me a far more flexible PHP data structure to manipulate. So, I am going in that direction instead.</p>
<p>Since this is a one-time action, speed isn&#8217;t vital, so it&#8217;s okay that PEAR::SOAP is written in PHP.</p>
<p>If you&#8217;re interested in more details on these new PHP 5 features, they&#8217;re documented in the <a href="http://www.php.net/manual">PHP Manual</a>. Alternatively, in a shameless plug, you can check out my book <a href="http://www.amazon.com/exec/obidos/ASIN/0596006365/ref=nosim/trachtenberg-20">Upgrading to PHP 5</a>.</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=325&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2005/10/24/ebay-soap-update/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

