Wednesday, January 5, 2011

Development trends to watch in 2011

2011 is here! While I don’t like to make predictions per se, I do like to explore what topics I think may be important to developers for the next twelve months. Let’s jump right into my look ahead for 2011.

Silverlight

2010 was the year that Silverlight (and with it, WPF for apps that need access to local resources) gained real momentum. The more I play with Silverlight, the less it frustrates me, though lots of aspects of the technology still rub me the wrong way. In my opinion, the “patterns and practices” people pollute Silverlight’s ecosystem; they waste a lot of time and effort on a million frameworks to do things that address a couple of stylistic and academic concerns at the expense of increased complexity, indirectness of code, and significantly raising barriers to entry.

Fortunately, I learned that you don’t need to do things the way these folks push. In fact, the default, out of the box Silverlight development experience is very similar to WinForms (for better or for worse), and the learning curve is not nearly as bad as it appears when you first survey the landscape. This is particularly good news because, in 2011, enough development is moving to Silverlight and WPF that folks who don’t have the time and energy to learn new development paradigms will be moving to it.

Windows Phone 7

In my TechRepublic columns about Windows Phone 7 development, I note that the experience hasn’t always been pleasant. While aspects of Windows Phone 7 development still frustrate me, it is a much better experience than its competition in terms of writing applications.

I don’t know if Windows Phone 7 will be a big hit, but if it’s a success, it will be a late bloomer like Android. Remember, Android was anemic until the Droid 1 was released just over a year ago, and now it’s a big hit. That said, I think that Android is the odd man out right now. The development experience is tough because of the fragmentation. You never know what resolutions to expect, for example, or baseline phone functionality. Even on a particular model, you can’t expect a particular version of Android. With iPhone, BlackBerry, and Windows Phone 7, you do.

RIM has lost an incredible amount of momentum, and none of its recent attempts at regaining it have looked promising. Palm’s WebOS is on ice until HP figures out what it wants to do with it. Symbian has huge worldwide success except for the United States. iPhone continues to move crazy unit numbers. If Windows Phone 7 becomes a hit, it will be at the expense of RIM and Android. I think Android has enough problems, and Windows Phone 7 has both enough potential to pull it off. Windows Phone 7 is already quite good in ways that Android isn’t, both to developers and users. If I were an Android developer, I would be watching Windows Phone 7 to see where it goes.

Mainstream development alternatives

The more I see of Java and .NET, the less I am happy with them. Java and .NET work really well for some things; however, both have a lot of problems, not the least of which is the ecosystems. The Java ecosystem isn’t sure if it wants to be some open source haven or the next COBOL. The .NET folks are going insane replicating development patterns that were pioneered 30 years ago, but instead of studying the literature and figuring out how to do it right, they get hung up in replicating what was done ages ago, including the workarounds that were needed due to technical limitations at the time. Meanwhile, neither ecosystem is doing much of anything to deliver products that allow typical developers to produce better applications quicker with fewer bugs and security problems.

Frameworks that enable developers to use the latest pattern fads cover up the fundamental problems with both platforms, which is the amount of complexity in the typical application is overwhelming. I hope that the alternatives to these mainstream development platforms get more traction in the future. I haven’t talked to anyone who left Java or .NET and was eager to go back, particularly around Web development. If you think there has to be a better way to get apps out the door, 2011 is a great year to check out your choices!

Web development maturity

In the last decade, Web development has really taken off, and there has been a ton of innovation in the space. Going forward, we are going to see a lot more maturity in the market. For better or for worse, HTML5 continues its progress toward being a universal standard for building Web applications. Web browsers are following suit, and even Internet Explorer is trying hard to comply with the HTML5 standard. This means that developers can spend more time getting stuff done and less time figuring out one-off workarounds and clever hacks for problems that shouldn’t even exist.

The economy

In 2010, the economy picked up steam for tech workers, but the momentum seems to be more for specialists than generalists. “Plain vanilla” developers are watching their wages remain steady, and entry-level developers are in tough competition with more experienced overseas workers within the same salary range. It seems like not many companies want to make a long-term investment in less-experienced developers who show promise, and even fewer want to put anything into their existing staff.

The trend of hiring to fill knowledge gaps instead of training will only increase. The really bright spots are for people with in-demand, specialized skills, such as Silverlight and mobile developers. It looks like Ruby and Rails will also have more demand as time goes on.

I also think this is a great opportunity for independent consultants. Companies have learned to be choosy enough about projects that their overall need for workers may stay the same in terms of total developers needed, but they are much more likely to need certain skill sets for limited periods of time.

What development topics will you follow in 2011? Let us know in the discussion.

Friday, December 24, 2010

Introduction to NuSOAP



NuSOAP is a group of PHP classes that allow developers to create and consume SOAP web services. It does not require any special PHP extensions. The current release version (0.6.7) of NuSOAP at the time this was written (03-November-2004), supports much of the SOAP 1.1 specification. It can generate WSDL 1.1 and also consume it for use in serialization. Both rpc/encoded and document/literal services are supported. However, it must be noted that NuSOAP does not provide coverage of the SOAP 1.1 and WSDL 1.1 that is as complete as some other implementations, such as .NET and Apache Axis.


This document describes how to obtain and install NuSOAP, then provides some samples to illustrate the capabilities of NuSOAP. It is by no means an exhaustive description of NuSOAP, but it is hopefully enough to get any PHP coder started. Programming with NuSOAP follows this up with more complex samples.


Installation

Hello, World

Debugging

Request and Response

Resources


Installation


The NuSOAP project is hosted by SourceForge. You can obtain NuSOAP either as a downloadable release or from the CVS tree of the NuSOAP project on SourceForge. A browser-based CVS interface is provided. As an example, you can obtain version 1.81 of nusoap.php with the following URL: http://cvs.sourceforge.net/viewcvs.py/*checkout*/nusoap/lib/nusoap.php?rev=1.81. You can start working with the version of the code you choose. I have run the samples below with version 1.81.


Once you have downloaded a copy of nusoap.php, you simply need to place it in your code tree so that you can include it from your PHP code. Some users put in it a separate lib directory. For my examples, I placed it in the same directory as the sample code itself.


Return to top.

Hello, World


Showing no imagination whatsoever, I will start with the ubiquitous "Hello, World" example. This will demonstrate the basic coding of NuSOAP clients and servers.


I will start with the server code, since without a server there is no need to have any client. The server exposes a single SOAP method named Hello, which takes a single string parameter for input and returns a string. Hopefully, the comments within the code provide sufficient explanation! For the simplest services, all that will change are the functions being defined and registered.


<?php  


// Pull in the NuSOAP code require_once('nusoap.php');
// Create the server instance $server = new soap_server;
// Register the method to expose $server->register('hello');
// Define the method as a PHP function
function hello($name) {
return 'Hello, ' . $name; }

// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?>

The client for this service is below. There are a few important things to note. First, when the instance of soapclient is created, the parameter specified is the URL to the service. In my case, helloword.php is accessed from http://localhost/phphack. The services you consume will, of course, be located at different URLs. Second, when calling the service, the first parameter is the service name. This must match the case-sensitive name of a method available on the server. In this example, it must match the method registered within helloworld.php. Finally, the second parameter in the call is an array of parameters that will be passed to the SOAP service method. Since the hello method of helloworld.php requires a single parameter, this array has one element.


<?php  

// Pull in the NuSOAP code
require_once('nusoap.php');

// Create the client instance

$client = new soapclient('http://localhost/phphack/helloworld.php');

// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));

// Display the result

print_r($result);

?>

Return to top.

Debugging


As with all programming, there are times when you will have problems you need to debug. NuSOAP provides a couple of facilities to help with that. With SOAP, a very typical step in debugging is to view the request being sent and response being returned. The NuSOAP soapclient class has members named request and response that allow you to view these. For example, here is a modified version of the helloworldclient.php that displays the request and response. In the next section, I will review the structure of the request and response displayed by this client code.


<?php  

// Pull in the NuSOAP code
require_once('nusoap.php');

// Create the client instance
$client = new soapclient('http://localhost/phphack/helloworld.php');

// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));

// Display the result
print_r($result);


// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES)
. '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES)
. '</pre>';

?>

NuSOAP also provides a means to view debug information logged throughout its classes. Adding the following to the client code will display this verbose debugging information. Unfortunately, interpretation of the output must be left to the reader.


// Display the debug messages  

echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES)
. '</pre>';

The server can provide similar debugging. Interestingly, the debug text is written as an XML comment at the end of the SOAP response, so it can be viewed by displaying the response at the client. The server with debugging enabled looks like this.


<?php  

// Pull in the NuSOAP code
require_once('nusoap.php');

// Enable debugging *before* creating server instance
$debug = 1;

// Create the server instance
$server = new soap_server;

// Register the method to expose
$server->register('hello');

// Define the method as a PHP function

function hello($name) {
return 'Hello, ' . $name; }

// Use the request to (try to) invoke the service

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?>

A third means of debugging is not really debugging at all. It is simply good programming practice. The examples above have not checked for errors occurring during the SOAP call. A more robust client would look like the following.


<?php  
// Pull in the NuSOAP code
require_once('nusoap.php');

// Create the client instance
$client = new soapclient('http://localhost/phphack/helloworld.php');

// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Constructor error: ' . $err . '</b></p>';

// At this point, you know the call that follows will fail }
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));

// Check for a fault
if ($client->fault) {
echo '<p><b>Fault: ';
print_r($result);
echo '</b></p>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Error: ' . $err . '</b></p>';
} else {
// Display the result
print_r($result); } }

?>

To test this code, cause an error to happen, such as by changing the name of the method to invoke from 'hello' to 'goodbye'.


Return to top.

Request and Response


I showed above how easy it is to display the SOAP request and response. Here is what the request from the helloworld2client.php looks like.


POST /phphack/helloworld2.php HTTP/1.0  
Host: localhost User-Agent: NuSOAP/0.6.8 (1.81)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "" Content-Length: 538

<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd">
<SOAP-ENV:Body>


<ns1:hello xmlns:ns1="http://testuri.org">
<name xsi:type="xsd:string">Scott</name>
</ns1:hello>
</SOAP-ENV:Body> </SOAP-ENV:Envelope>

In the HTTP headers, you will notice that the SOAPAction is an empty string. This is simply the default. Your service methods can be assigned to a SOAPAction, and your client code can specify a SOAPAction as one of the parameters to the call method.


In the XML payload, you see that NuSOAP uses ISO-8859-1 character encoding, also known as Latin-1. To specify a different encoding, you set the soap_defencoding property on the soapclient instance. It is the programmer's responsibility to encode the parameter data correctly using the specified encoding. Fortunately, PHP provides functions for encoding and decoding data using the most common encoding in SOAP, UTF-8.


Another thing to note is that the element specifying the method call, the element named hello, has been placed in the http://tempuri.org namespace. It is better practice, and necessary with many services, to specify the actual namespace in which the method is defined. This will be shown in a future document.


The response from the SOAP service looks like this.


HTTP/1.1 200 OK  Server: Microsoft-IIS/5.0  
Date: Wed, 03 Nov 2004 21:32:34 GMT
X-Powered-By: ASP.NET
X-Powered-By: PHP/4.3.4
Server: NuSOAP Server v0.6.8
X-SOAP-Server: NuSOAP/0.6.8 (1.81)
Content-Type: text/xml;
charset=ISO-8859-1
Content-Length: 556

<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd">
<SOAP-ENV:Body>
<ns1:helloResponse xmlns:ns1="http://tempuri.org">
<return xsi:type="xsd:string">Hello, Scott</return>
</helloResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Return to top.

You can download the source for this example as well.


Return to top.

Monday, December 20, 2010

10 network diagramming tools for every budget

1-CADE (free)



Cade is a tool developed by a company that focuses primarily on CAD. CADE is a 2D vector editor for Windows that can handle the task of diagramming your network with ease. One feature I really like about this tool is the ability to notate IP address, serial number, and manufacturer for each piece of equipment. CADE has all the stencils you need for a complete network diagram. CADE is free to use.

2-Concept Draw Pro



Concept Draw is one of the more powerful network diagramming tools you will find. Concept Draw is actually more than just a network diagramming tool, it's a full-fledged business diagramming tool. Concept Draw Pro is full drag and drop with little to no learning curve. This particular tool has every networking symbol you will need as well as the ability to customize just about everything you add. The cost of Concept Draw Pro is $249.


3-Dia (free)



Dia is an open source diagramming tool that suffers from a very old-school look and feel on its symbols and UI. However, Dia is very simple to use and doesn't distract from the task at hand. Dia works on just about any Linux desktop and is free of charge.



4-Diagram Designer (free)



Diagram Designer is another freeware tool that looks a bit outdated but the ease of use should make it appealing to a wide variety of users. Unlike Dia, Diagram Designer has a much larger selection of symbols and icons. The only thing I didn't much care for with Diagram Designer is that the connector tool is a free-form tool so you actually have to manually draw your connections between machines. Outside of that little drawback, DD is a solid entry.



5-eDraw



Outside of the industry standard, Visio, eDraw Max is one of the finest of the group. Along with a very user-friendly interface and next to no learning curve, eDraw Max has one of the more updated look and feels among all of the entries. Of course eDraw Max is also a full-blown diagramming tool that can cover all of your business diagramming needs. The cost of eDraw Max is $99.95 for one license and, as you increase numbers, the individual license cost goes down.



6-GoVisual Diagram Editor (free)



Some pieces of software are simply not made equal. GoVisual Diagram Editor is one such tool that shows how a very complicated tool can produce results that are less than pleasing. Although you can really take some time with GoVisual and make the results work for you, you will be missing features (such as network device object icons) that make the network diagram far easier to read. But if you're looking for a free tool that can be used for just about any type of diagramming, GoVisual might be the tool for you. Cost? Free.



7-LanFlow



LanFlow is one of the better tools I have used for this task. It has a great user interface, plenty of network objects to play with, the ability to create LAN, telecom, Internet, and computer diagrams with little effort. LanFlow even comes with two different network diagram templates (3D and b&w). When you open up a new network diagram template you can simply start dragging around objects to fit your network, add new objects (or remove objects), group (or ungroup) objects, and much more. The cost of LanFlow for a single user license, is $89.00, making this one of the best of the low-cost alternatives to Visio.



8-NetProbe




Although you can use NetProbe as a network diagramming tool, it's primary purpose is a real-time network device monitoring. But what makes NetProbe a possible contender for network diagramming is its ability to allow you to add, as you need them, devices that are on (or will be on) your network. But, you don't have to do all of that manual labor as NetProbe has a built-in tool that will automatically scan your network and lay out all of the devices for you. The Standard version is free but is limited to eight hosts. The Pro version of NetProbe (allowing for up to 20 hosts) will set you back only $40.00 and the Enterprise version (allowing for 400 hosts) runs $295.



9-Network Notepad (free)




Network Notepad is exactly what it sounds like it would be -- a notepad for network diagrams. But don't let the term "notepad" fool you. Network Notepad is full-fledged diagramming tool that even includes interactive functionality (such as telnet, browse, ping, and more). Network Notepad has an easy-to-use drag-and-drop interface and also has an autodiscover feature for Cisco devices. This tool is free of charge.



10-Microsoft Visio




Visio is, of course, the de facto standard for diagramming in the Windows world. Not only can you create beautiful network diagrams, you can create them easily and share data-linked diagrams with others via a Web browser. Visio offers plenty of templates to add on such as data center templates, office consolidation, fault tree, help desk, HVAC, network rack equipment, network planning for enterprise/data center/home office, and much more. Visio is the king of the hill as far as network diagramming, and with the crown comes the price tag of $249.99 for the Standard version, $559.99 for the Professional version, and $999.99 for the Premium 2010 edition. For more information on what each version offers, visit the Visio product purchase page.