|By Jon Strande||
|February 22, 2002 12:00 AM EST||
Almost every industry today has B2B exchanges that enable businesses to improve the efficiency of some process or communication with customers, partners, or suppliers. The open and public exchanges that exist today will be replaced tomorrow with Web services, which allow direct communication between two businesses.
What these two communication methods have in common is that both receive and reply using XML. If you aren't writing these communication-enabling types of applications today, you very well may be in the future.
This article demonstrates how to:
One of the problems you run into when you're writing communicative applications like these is that you need to know that you're sending and receiving proper data. Most of the projects I've worked on recently are just these types of applications - and I quickly found that I needed to determine two things: (1) the validity of the data being returned, and (2) whether the server was handling the incoming data properly.
The first - determining that the server is returning proper data - is very simple in its purest form: a request can be made via the GET method and most current browsers will render the XML that the server responds with. Although testing the validity of the response data is easy using a GET request, it is more important to know that it is responding that way as a result of being invoked with an actual request containing XML.
Which leads me to the next point, testing to make sure your server application is handling the incoming XML documents properly. What this really means is that you want to know that your application will handle an incoming XML document, and that it will perform properly. By invoking your application with XML, you can test whether, given good input, your application will respond properly and, given bad data, whether it will behave in the manner you anticipate.
I knew this wouldn't be the last application to require my testing the sending and receiving of XML, so I decided to write a generic tool to facilitate the process.
The tool itself is simple, and I've oversimplified it by putting almost all of the client code in one class. First let's have a look at the user interface, shown in Figure 1.
As you can tell, it's a very simple application - a button to allow you to choose an XML document, a place to type in a URL, a text box to display the results from the server, and a button to initiate the POST. A look at the code in Listing 1 gives you the following methods:
private void getXMLFile() & private void postData()The method getXMLFile is called as a result of clicking on the XML File button. The method's only purpose is to pop open a FileChooser Dialog (see Figure 2) that allows you to specify the XML document you want to use for your test.
The postData method is what actually does the most work - too much work for an individual method, but, for simplicity, all the really important code is in one place. We start by getting an instance of a DOMBuilder and calling the build() method, passing in the File object for our XML file. We then make a connection to the server identified in the URL text field of the user interface. This is accomplished with the HttpURLConnection class in the java.net package.
After establishing our connection, we get to use a nice class provided by the JDOM API, the XMLOutputter class! First we instantiate an OutputStreamWriter, passing the HttpURLConnections getOutputStream() as a parameter to the constructor of the OutputStreamWriter. We then create an instance of the XMLOutputter class with a string representing the indent we want to use, in this case a "\t" for tabs and a boolean indicating that we'd like to use new line characters.
Now that we have that stuff set up, we need to associate our XML document object with our outputter. The method to do this is output(Document theDocYouWantToWriteOut, OutputStreamtheActualOutputStream). After calling the output() method and a quick call to flush(), we're ready to start getting input back from the server.
The code for this is nothing new, so I'll only touch on it by saying that we're getting the input stream from HttpURLConnection and that you can examine all this code by downloading the source.
What we've accomplished here is an easy way to post an XML file to a server and display the results in a text box. For testing purposes I've written a servlet that pretty much echoes the content of the XML document submitted by the client. The servlet adds a node to the document named SERVER_TIME, which contains a date-time stamp as the text of that node.
The code for the doPost() method is shown in Listing 2. The code for the servlet is simple and can also be examined in Listing 2 or by downloading the source code from this article.
Authenticating the Use of the Authenticator Class
One problem with these applications is that they're generally password protected - in order to access them you need to be authenticated. Thankfully, Java makes it easy to do this. In the java.net package is an Authenticator abstract class that you can subclass to create a graphical interface that allows users to provide their credentials for authentication. The code to do this same thing can be found in Chapter 7, "Retrieving Data with URLs," of Java Network Programming, 2nd Edition, by Elliotte Rusty Harold (O'Reilly). A simple overview of this class, right from the JavaDoc, is as follows:
The class Authenticator represents an object that knows how to obtain authentication for a network connection. Usually, it will do this by prompting the user for information.So, as you can see by the code below, we have the following constructor and methods:
Applications use this class by creating a subclass, and registering an instance of that subclass with the system with setDefault(). When authentication is required, the system will invoke a method on the subclass (like getPasswordAuthentication). The subclass's method can query about the authentication being requested with a number of inherited methods (getRequestingXXX()), and form an appropriate message for the user.
private void show() public PasswordAuthentication getPasswordAuthentication()Those methods, as well as two inner classes that handle the OK and Cancel responses (again, right from Java Network Programming), are all that's really required to add authentication to this application. The Authenticator will prompt you for credentials only when the site you're trying to access requires it, as shown in Figure 3.
Extending the Tool
As I mentioned, the tool itself is very basic, and is useful for testing XML-based applications. And there are quite a few ways that you can turn this application into a more effective testing tool. For example :
The JDOM API
This tool was written using the JDOM (www.jdom.org) beta 6. However, none of the methods used in this application were deprecated in the beta 7 release of the JDOM API. That said, let's look at some of the classes and methods being used.
For starters, we're using the org.jdom.Document class, which defines the methods for manipulating an XML document. I make more use of this class in the sample servlet that I've included. The method I'm using is getRootElement().
The next class I use, the Element class, is analogous to a node in an XML document or an "element" in the document. The method addContent() is used in the Element class to add text to an element; those elements can then be added to other elements through the addContent() method, or to a document object.
As already mentioned, I'm using two other classes, a DOMBuilder and an XMLOutputter. Together these classes allow you to (1) create a Document object from various types of inputs and (2) write a Document object out, respectively.
Overall, the JDOM API is extremely easy to use; I may have made it seem more difficult than it truly is. The authors of JDOM have done a great job of creating a simple and effective API for working with XML.
As you can see, testing an XML-based server-side application is fairly straightforward and can be accomplished rather easily. The basic tool, combined with one or more of the suggestions for extending the tool, should help speed up the process of building and debugging server-based XML applications.
Buzzword alert: Microservices and IoT at a DevOps conference? What could possibly go wrong? In this Power Panel at DevOps Summit, moderated by Jason Bloomberg, the leading expert on architecting agility for the enterprise and president of Intellyx, panelists peeled away the buzz and discuss the important architectural principles behind implementing IoT solutions for the enterprise. As remote IoT devices and sensors become increasingly intelligent, they become part of our distributed cloud enviro...
Mar. 29, 2017 12:15 PM EDT Reads: 7,866
SYS-CON Events announced today that Auditwerx will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Auditwerx specializes in SOC 1, SOC 2, and SOC 3 attestation services throughout the U.S. and Canada. As a division of Carr, Riggs & Ingram (CRI), one of the top 20 largest CPA firms nationally, you can expect the resources, skills, and experience of a much larger firm combined with the accessibility and attent...
Mar. 29, 2017 12:00 PM EDT Reads: 611
SYS-CON Events announced today that T-Mobile will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on ...
Mar. 29, 2017 11:45 AM EDT Reads: 2,556
SYS-CON Events announced today that Infranics will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Since 2000, Infranics has developed SysMaster Suite, which is required for the stable and efficient management of ICT infrastructure. The ICT management solution developed and provided by Infranics continues to add intelligence to the ICT infrastructure through the IMC (Infra Management Cycle) based on mathemat...
Mar. 29, 2017 11:00 AM EDT Reads: 3,407
SYS-CON Events announced today that Interoute, owner-operator of one of Europe's largest networks and a global cloud services platform, has been named “Bronze Sponsor” of SYS-CON's 20th Cloud Expo, which will take place on June 6-8, 2017 at the Javits Center in New York, New York. Interoute is the owner-operator of one of Europe's largest networks and a global cloud services platform which encompasses 12 data centers, 14 virtual data centers and 31 colocation centers, with connections to 195 add...
Mar. 29, 2017 10:15 AM EDT Reads: 1,688
SYS-CON Events announced today that Cloudistics, an on-premises cloud computing company, has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Cloudistics delivers a complete public cloud experience with composable on-premises infrastructures to medium and large enterprises. Its software-defined technology natively converges network, storage, compute, virtualization, and management into a ...
Mar. 29, 2017 10:00 AM EDT Reads: 2,327
In his session at @ThingsExpo, Eric Lachapelle, CEO of the Professional Evaluation and Certification Board (PECB), will provide an overview of various initiatives to certifiy the security of connected devices and future trends in ensuring public trust of IoT. Eric Lachapelle is the Chief Executive Officer of the Professional Evaluation and Certification Board (PECB), an international certification body. His role is to help companies and individuals to achieve professional, accredited and worldw...
Mar. 29, 2017 08:45 AM EDT Reads: 921
In his General Session at 16th Cloud Expo, David Shacochis, host of The Hybrid IT Files podcast and Vice President at CenturyLink, investigated three key trends of the “gigabit economy" though the story of a Fortune 500 communications company in transformation. Narrating how multi-modal hybrid IT, service automation, and agile delivery all intersect, he will cover the role of storytelling and empathy in achieving strategic alignment between the enterprise and its information technology.
Mar. 29, 2017 08:00 AM EDT Reads: 7,506
Microservices are a very exciting architectural approach that many organizations are looking to as a way to accelerate innovation. Microservices promise to allow teams to move away from monolithic "ball of mud" systems, but the reality is that, in the vast majority of organizations, different projects and technologies will continue to be developed at different speeds. How to handle the dependencies between these disparate systems with different iteration cycles? Consider the "canoncial problem" ...
Mar. 29, 2017 06:00 AM EDT Reads: 9,062
The Internet of Things is clearly many things: data collection and analytics, wearables, Smart Grids and Smart Cities, the Industrial Internet, and more. Cool platforms like Arduino, Raspberry Pi, Intel's Galileo and Edison, and a diverse world of sensors are making the IoT a great toy box for developers in all these areas. In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists discussed what things are the most important, which will have the most profound e...
Mar. 29, 2017 04:00 AM EDT Reads: 15,114
Keeping pace with advancements in software delivery processes and tooling is taxing even for the most proficient organizations. Point tools, platforms, open source and the increasing adoption of private and public cloud services requires strong engineering rigor - all in the face of developer demands to use the tools of choice. As Agile has settled in as a mainstream practice, now DevOps has emerged as the next wave to improve software delivery speed and output. To make DevOps work, organization...
Mar. 29, 2017 03:45 AM EDT Reads: 2,162
My team embarked on building a data lake for our sales and marketing data to better understand customer journeys. This required building a hybrid data pipeline to connect our cloud CRM with the new Hadoop Data Lake. One challenge is that IT was not in a position to provide support until we proved value and marketing did not have the experience, so we embarked on the journey ourselves within the product marketing team for our line of business within Progress. In his session at @BigDataExpo, Sum...
Mar. 29, 2017 03:30 AM EDT Reads: 3,253
Web Real-Time Communication APIs have quickly revolutionized what browsers are capable of. In addition to video and audio streams, we can now bi-directionally send arbitrary data over WebRTC's PeerConnection Data Channels. With the advent of Progressive Web Apps and new hardware APIs such as WebBluetooh and WebUSB, we can finally enable users to stitch together the Internet of Things directly from their browsers while communicating privately and securely in a decentralized way.
Mar. 29, 2017 03:00 AM EDT Reads: 6,096
DevOps is often described as a combination of technology and culture. Without both, DevOps isn't complete. However, applying the culture to outdated technology is a recipe for disaster; as response times grow and connections between teams are delayed by technology, the culture will die. A Nutanix Enterprise Cloud has many benefits that provide the needed base for a true DevOps paradigm.
Mar. 29, 2017 01:15 AM EDT Reads: 2,523
What sort of WebRTC based applications can we expect to see over the next year and beyond? One way to predict development trends is to see what sorts of applications startups are building. In his session at @ThingsExpo, Arin Sime, founder of WebRTC.ventures, will discuss the current and likely future trends in WebRTC application development based on real requests for custom applications from real customers, as well as other public sources of information,
Mar. 29, 2017 01:00 AM EDT Reads: 1,131
In his General Session at 17th Cloud Expo, Bruce Swann, Senior Product Marketing Manager for Adobe Campaign, explored the key ingredients of cross-channel marketing in a digital world. Learn how the Adobe Marketing Cloud can help marketers embrace opportunities for personalized, relevant and real-time customer engagement across offline (direct mail, point of sale, call center) and digital (email, website, SMS, mobile apps, social networks, connected objects).
Mar. 28, 2017 11:15 PM EDT Reads: 3,529
"My role is working with customers, helping them go through this digital transformation. I spend a lot of time talking to banks, big industries, manufacturers working through how they are integrating and transforming their IT platforms and moving them forward," explained William Morrish, General Manager Product Sales at Interoute, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
Mar. 28, 2017 09:30 PM EDT Reads: 3,912
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, will discuss some of the security challenges of the IoT infrastructure and relate how these aspects impact Smart Living. The material will be delivered i...
Mar. 28, 2017 09:30 PM EDT Reads: 2,268
SYS-CON Events announced today that Ocean9will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Ocean9 provides cloud services for Backup, Disaster Recovery (DRaaS) and instant Innovation, and redefines enterprise infrastructure with its cloud native subscription offerings for mission critical SAP workloads.
Mar. 28, 2017 08:15 PM EDT Reads: 2,393
Your homes and cars can be automated and self-serviced. Why can't your storage? From simply asking questions to analyze and troubleshoot your infrastructure, to provisioning storage with snapshots, recovery and replication, your wildest sci-fi dream has come true. In his session at @DevOpsSummit at 20th Cloud Expo, Dan Florea, Director of Product Management at Tintri, will provide a ChatOps demo where you can talk to your storage and manage it from anywhere, through Slack and similar services ...
Mar. 28, 2017 07:00 PM EDT Reads: 4,562