my very first web service

okay, a little nuts-and-bolts post today. I've finished my first web service, though it is really just a web service wrapper to a tool already offered online by UPS. I guess the service I'm offering is a free implementation of their tool using WSDL and being able to hit UPS using the account I created. I guess I better say that by using my service, you agree to the terms that UPS has put on their service. and don't go around using this in production or commercial programs, as I think it's not allowed without your own account, and my IP address will more than likely change soon, breaking the WSDL URL.</p>

here's the description as generated by webservice helper. here's the WSDL for you to use.

what I've done is used cURL in PHP to make an HTTP post to UPS. I made a class that creates the correctly formed UPS access XML and request XML strings, then made another class and function that takes the inputs (as described in the WSDL) and returns an XML string. then I just added the proper documentation in the class (for ws-helper), and dropped that class into ws-helper's designated directory, and voila. it generated the WSDL and accepts the soap requests.

the code to consume this service in PHP 5 is pretty easy too, if you have configured PHP with --enable-soap, that is.

$lukeUPSRateService = SoapClient('http://68.0.120.127:8888/wshelper/service.php?class=upsRateRequest&wsdl');

$returnXML = $lukeUPSRateService->performUPSRateRequest($fromZip, $height, $length, $toZip, $weight, $width);</p>

then you could do whatever you want with the XML...like, say...

(un-tested code follows)

$upsXMLObject = simplexml_load_string($returnXML);

$cheapestRate = 100000;

for($i=0; i<$upsXMLObject->RatedShipment.length; $i++){

if($upsXMLObject->RatedShipment[i]->TotalCharges->MonetaryValue < $cheapestRate){ $cheapestRate = $upsXMLObject->RatedShipment[i]->TotalCharges->MonetaryValue;

}

}
</div>

Random news items

isn't this basically what a blog is supposed to be about?</p>

if T. Erl is still reading this blog, he would have a good deal to say about this, maybe. while I think it's beneficial for code-cruncher types, the idea of being able to properly implement web services after supposedly only 24 hours of research is pretty crazy. and as Erl would agree, it would no doubt miss out on the full potential of what a Web Services platform can do. but quick-and-dirty IT projects are the bread and butter of some developers, and some successful businesses, too!

(as an aside, I have read that book, and it was very good as a starter. but please, please, if you read it, don't consider the single 20-page chapter on 'Typical Web Services Designs' as a good grounds for architecting an SOA with Web Services. it demonstrates only the typical hub-and-spoke integration approach, and Erl's book is far superior.

it looks like we bought our Altova XML Enterprise Suite a little too early up at the office. I've signed up for that ridiculous www.freeipods.com site, because my geeky nature demands I have an iPod, but my wallet demands I don't spend money on it. Altova wanted to give me an iPod all along!

just 2 news items, it seems. I guess it's typical blog-fashion, even if it is somewhat lacking in depth.
</div>

2 posts in a day!

a minor effort to get some of the very justified and well-founded pressure off of my own back, and onto someone else's....</p>

Erl responded to my open-source inquiry. I don't know if he spoke for himself, or if he really did just speak for 'some' others...

"That's not an area I'm really involved with, so I'm probably not

the best person to ask. I believe that some think open source

implementations may undermine the standardized interoperability that the

WS-* platform promotes."

in a bit of blog-magic, I will magically turn the former 'Anonymous' commentor into MATT CROUCH and hopefully get him to sink his very shrewd fangs into Erl's statements.
</div>

back to business

so, back to business of web services, after some lengthy, though productive, discussion of open-source licensing. along with more support for the anticipated growth in the Web Service industry, this article acts as a nice Web Services Chapter 0. it talks about the building blocks, and the current, already large, web service landscape - of course using eBay and Amazon as the prime examples. it contains many good links on its points (I especially liked the article about BPM/BPEL).</p>

in more personal/specific news, I showed the current state of the UPS Rate Selection Service php tool that I built to the Tulsa PHP Meetup Group. they seemed pretty interested, but I still have some work to do this weekend - I re-wrote the script using classes and am adding the correct documentation to expose it as a web service using the Webservice helper tool. I'm dedicating this weekend to that, and World of Warcraft, so it should be very much done in time for Tuesday's meeting with the EDS folks.

I'll also need to put down some of the MySQL 5.0 XML features that are in the works in order to keep the lamp5 discussion related to MySQL, seeing as how Tuesday's meeting is the Tulsa MySQL Meetup Group. I'm still a huge fan of MySQL, but am just discovering that it is not very involved with the Web Services I'm interested in.
</div>

I blog corrected

the astute (and probably solitary) reader who corrected my erroneous assumptions regarding the Open Source Definition sent me on a much deeper research tangent that is very much vital to the subject of open source web services. but I will first address and correct my statements.</p>

the primary source of my confusion and ill-founded assumptions was my reliance on the article's summarization of the definition, rather than the definition as outlined by OSI. I therefore had an incomplete perspective of the open source definition, and lambasted a straw-man that had no real resemblance of the real Open Source Definition & Licensing body. I owe OSI an apology, although they never knew it, and I offer it, although probably only to an empty blogosphere.

with my more fully-developed perspective, in regards to my comments about OSI 'zealots' and its 'dream-world', I will withdraw the 'dream-world' accusation, in recognition of the fact that the the OSI definitions and licenses (and specific concepts therein) are not only reasonable, but beneficial and conducive to advancing commercial software.

however, I still retain my, perhaps stereotypical, slant that the majority of open-sourcerors(tm) are ordinarily highly committed to, and evangelical of, open-source for ethical, or moralistic reasons more than techincal or (especially) commercial reasons.

but rather than try to offer up my own argument for the still small, though deeply important, point of contention I have with OS at large, I'm glad I can reference the opinions of somewhat more respected and established OS advocates. Namely, Michael Tiemann:

"...the freedom to use, distribute, and modify software will prevail against any model that attempts to limit that freedom. It will prevail not for ethical reasons, but for competitive, market-driven reasons."

now, for a more productive topic of discussion, I would contend that it is impossible to license Web Services under the GPL and here's way...

GPL, 2.b:

"You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License."

Web Services are Programs that will be utilized by countless numbers of other programs, and if a Web Service is utilized by another program, that program is said to be derived from the Web Service program. So the GPL is out for commercial Web Services.

The LGPL is more attractive....LGPL, 2.d:

"If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works."

For me, and probably for other commercial firms looking to make profit from Open Source Web Services, the fuzziness of the 'reasonably considered independent works' is way too open for discussion, especially considering the very next part of the license goes on to state:

"But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License..."

There is no real way, without getting more detailed and technical in the license, to determine where a proprietary program that uses a Web Service can be considered an independent or seperate work. And if a proprietary program were to use many Web Services, all under LGPL, the nightmare of working out the boundaries that the license applies to could hinder the adoption/consumption/embrace of OS Web Services.

I think a Web Services-specific open source license needs to be made, fashioned after the LGPL, but specifically stating that programs utilizing only standardized output of the licensed program are not themselves derivative works of the program, but are considered reasonably independent, recognizing that the standardized output could be replaced by a different program with no detriment.

I hope open-sourcerors catch the Web Services bug, though there are reasons why they wouldn't, and some progress is made in this important area of WS and OS licensing. </div>