XML Part 3: Code Development

Web Languages
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Well, here we are at the third and final article in this series. In the first article, I talked about XML in general and explained the components that make up an XML document. I placed a heavy emphasis on the fact that XML is really a definition of tag semantics, not a definition of tags, like HTML. The tags you use and what you populate the tags with is up to you. As long as you follow the rigidity of XML, you'll be fine. The last sections of the first article dealt with reading, manipulating, validating, and transforming XML.

The second article discussed bringing XML to the next level, which is application-to-application (A2A), with Web Services being the enabler in this paradigm. While many XML standards provide security, message delivery, service advertisement, and subscription, there is no part of XML that actually does these things. And if you already have functionality such as encryption, why not just snap that into your XML infrastructure?

In this article, I'm going to get a little less scholastic and a little more hands-on. I'll show you a pseudo system and some of the code that could be used to support this system when it communicates with other systems. A good friend of mine, Steve Bos, who I have worked with for years, is an excellent programmer and has created the code in this article. He has several years of hands-on experience with XML, utilizing many of the technologies already discussed.

It's All in the Design

Let's start with a simple system. We are going to be reviewing a hotel reservation portal. There are three external entities: the customer, the hotel, and the credit card authorization firm. The portal provides a nice interface for what can be a batch and/or interactive system. Its all in the design!

The hotel may send pricing information to the portal either at a fixed interval (such as nightly or weekly) or when there are price changes. Availability information may also be sent in batch, or the portal can interactively query the hotel to see if there are rooms available when a user makes a request. While we will not code every possibility, it is important to look at different possibilities in the hopes that you come with some XML ideas on your own.

Tools Transform the Design

In the code examples that follow, Steve used Micosoft's C# (pronounced "C sharp") because of the vast array of utilities Microsoft has made available to quickly build XML/Web Service applications. Universal Description, Discovery, and Integration (UDDI) and Web Services Description Language (WSDL) definitions are created with the click of a button, which takes the complexity out of these services. Simple Object Access Protocol (SOAP) messages complement UDDI and WSDL by connecting to remote Web Services. I'll show you what a SOAP message should look like.

SOAP Message

Let's take a look at a SOAP message. (The text was formatted for readability. If this were real XML, you would not see any tabs or carriage returns/line feeds.) This SOAP message sends a request to the hotel on behalf of the user. It includes the hotel ID, client name, room options, and some payment information." 


      Mr. Wilson
      Honeymoon Suite
      Mr. Bud Wilson

Figure 1: This sample SOAP message requests hotel availability information.

Let's examine this code.

The standard first line indicates that we are using XML Version 1.0 and that the text encoding is UTF-8.

The next few lines set up some "run-time" properties of the document. A nice thing about XML is that you can follow the convention of anyone on the Internet in terms of naming your XML data elements. For our SOAP envelope, we will be using the standards from the Universal Resource Indicator (URI) (name space xmlns). We will also be using the XML Schema Definition (xsd) from and the SOAP definition from

The SOAP payload begins with . The next line opens an Execute tag that includes a URI as a parameter. This is the location of the remote system (in our case, the hotel we will be booking our reservation with). The remainder of the SOAP message contains the parameters that will be passed to the hotel, such as guest name, credit card information, etc.

As with other XML standards we reviewed, all elements must be closed out. The last three lines of the SOAP message close out the Execute, SOAP:Body, and SOAP:Envelope elements.

The intended recipient of a SOAP message is a Web Service, which supplements a Web server. When a new SOAP message comes in, the Web Service automatically parses through the message and sends the parameters to an object that has the business logic programmed into it. This object could update database tables, check availability of a room, call out to external credit card authorization companies, or anything else that is programmatically possible. In our example, we are going to check the availability of the room and then confirm that the funds are available on the credit card. Once this is complete, we will return the following XML to the program that initially submitted the XML, which is waiting for a response.

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 454" 



Figure 2: This SOAP message is a response to the original request.

This response looks a little different from the request because we included the HTTP headers. HTTP/1.1 200 OK indicates that the document you were posting to was found and that the operation completed successfully. An HTTP/1.1 404 File Not Found would indicate that the Web Service you are trying to publish was not found. You would see this message if you went to a URL and the document you entered was not found on the server. The remaining lines of the HTTP headers indicate the text encoding type, which matches the UTF-8 that we had in our request, and the length of the response.

We start the XML portion the same way we started the request. The XML version and encoding format is indicated. The SOAP envelope element is opened with references made to the same URIs as the request.

The SOAP body element is opened as well, and it uses an interesting parameter. The ExecuteResponse element has the same URI as the Execute element in the request. This is because the same Web Service that is accepting the request is then creating the response.


First and foremost, WSDL defines a Web Service. In order to define this Web Service, it needs to describe the "binding," or what type of message to send and where (remember, a Web Service can operate from email). It also defines the port and the message that will traverse the port. A message is a series of parameters to be either received or sent, and the WSDL defines the specific parameters in a message and the format of those parameters.

This sounds both somewhat difficult and easy at the same time. You can see the hierarchy from the definition I provided above, but coming up with the syntax may be tedious. This is why you would almost never define WSDL yourself. Many packages, including C#, provide the run-time engines that create the WSDL for you. Let's look at an example that would define the reservation service that our SOAP message would be sent to." 










type="s:string" />

style="document" />

Figure 3: This code defines the reservation service that our SOAP message is sent to.

As in our SOAP requests, the first section relates to the version of XML we are using and the encoding method. We then reference external naming schemas, including one of our own located at

In WSDL, the subcomponents are defined first and the Web Service itself is defined last. The first definition is a schema. The first schema we define is ReserveRoom, a series of variables required to reserve a room. Look back at the SOAP example, and you'll see that the variable names are slightly different, but the schema definition matches what we are sending via our SOAP request.

The minOccurs and maxOccurs tags in the schema allow you to define how many times an element is present. Setting both of these values to "1" mandates that this variable be present only once. We could complicate this WSDL by adding a GuestNames tag that could have one to 100 names, depending upon the size of the room. So your minOccurs would be "1" and your maxOccurs would be up to "100."

In this WSDL, we define a schema for both the input and the output. This allows us to "code it once, call it twice" as my COBOL instructor used to say.

Moving on down the example, we find the Message element, a simple element that indicates we are using the ReserveRoom schema for our ReserveRoomSoapIn message and the ReserveRoomResponse schema for our ReserveRoomSoapOut message. So now we have bound a schema to a message, but we're not done yet.

The next step in the WSDL is defining the ports that may be available for a Web Service. A complex Web Service would have many different ports. In our simple example, we kept the port to simply reserving a room, or ReserveRoom. As you can see from the example, the input message (SOAP in our case, as opposed to email) expects ReserveRoomSoapIn, and we will be outputting ReserveRoomSoapOut. You should recognize both of these from when we defined them as messages.

The binding area is complicated, as it defines what we expect and the order in which we expect it. Because you can have several SOAP messages that constitute a Web Service transaction, the binding indicates when and how to expect those message and in what format. It also describes what you should expect to be returned, which is important if there are several messages being sent to you.

Finally, we define the Web Service itself, including the address, and reference the binding that we just defined. I don't think there is any question as to why you would want an application to automatically generate the WSDL.


As explained in the last article, UDDI provides a searchable directory of companies that upload their business classification information. UDDI encompasses uploading the information as well as searching it.

We're going to step away from the hotel reservation and perform a simple query that looks for information on Microsoft. Here's the code:

UddiConnection CONNECTION = new UddiConnection      (;
FindBusiness BUSINESS = new FindBusiness("Microsoft");
BUSINESS.CategoryBag.Add(CommonCanonical.NtisGovNaics1997,"51121","NAICS: Software Publisher");

This code excerpt is from C#, and as you can see, it is relatively easy to comprehend. The first line defines a new UDDI connection to the Microsoft Test server, which is specified by the URL. The second line of code stipulates the search criteria that we are looking for. In this example, we are looking for a business named Microsoft. The third line allows us to stipulate a series of qualifiers. We want to ensure that our search is case-sensitive and does not find "microSOFT." The fourth line hones in on the business classification standard (NtisGovNaics1997) and stipulates that we are looking for a software publisher. The final line initiates the connection and retrieves the information into the BusinessList object for your use.

Relatively simple, isn't it? Of course, the devil is in the details and what you do with that information once you have it. In our example, we know the company name that we are looking for. But what if we don't, and we are looking for a type of business? How can we discern the good from the bad and the ugly? And will we even be able to do this when we search for Hotel and receive hundreds of results?

The Future of XML

There will be many degrees of XML acceptance. At present, I see the landscape of XML as a collection of islands linked by shallow narrows that anyone can walk across at will. At each island is a different XML technology that solves a different problem. How many islands you travel to depends upon your ambitions and your specific business problems.

On the fringe of these islands, a super island will be established that has bridges and a hefty admission fee. These will come to you in the form of frameworks or add-ons to your business applications. They'll carry a significant cost but will be all-encompassing. Instead of studying standards and downloading SDKs and toolkits, you'll be able to go to the super island, which will provide full XML integration with all the functionality that the standards define.

There will also be an isolated island of third-party vendors. They will operate the Web Services, perform the UDDI registration and searching, define the WSDL to use your Web Services, and transport the SOAP messages to complete complex transactions. Aside from transaction and subscription fees, the process will be relatively painless, and you'll never have to leave your island.

Nonetheless, you will most likely have to get your feet wet with XML. It is a mutating technology that seems to be touching everything that is front and center right now. You now have a better understanding of XML and the superfluous technologies that extend it so that, when the time comes, you do not drown.

Additional Resources

Since publishing the first article in this series, MC Press Online has exploded with excellent in-depth articles on XML and its surrounding technologies. In addition to these articles, author Steve Bos, whose code has been introduced here, has a full-length book in the works. Expect to see it available at the MC Press store around May. This book will provide more details on the technologies introduced here and apply them to the iSeries.

Chris Green is a Senior Network Support Specialist located in Toronto, Ontario, Canada. He has eight years experience focusing on the iSeries and networking technologies. Utilizing this experience, he has authored over 30 articles and several white papers and has co-authored an IBM Redbook entitled Securing Your AS/400 from Harm on the Internet. Most recently, he has achieved Security Essentials (GSEC) certification from the SANS Institute. For questions or comments, you can email him at This email address is being protected from spambots. You need JavaScript enabled to view it..



Support MC Press Online





  • White Paper: Node.js for Enterprise IBM i Modernization

    SB Profound WP 5539

    If your business is thinking about modernizing your legacy IBM i (also known as AS/400 or iSeries) applications, you will want to read this white paper first!

    Download this paper and learn how Node.js can ensure that you:
    - Modernize on-time and budget - no more lengthy, costly, disruptive app rewrites!
    - Retain your IBM i systems of record
    - Find and hire new development talent
    - Integrate new Node.js applications with your existing RPG, Java, .Net, and PHP apps
    - Extend your IBM i capabilties to include Watson API, Cloud, and Internet of Things

    Read Node.js for Enterprise IBM i Modernization Now!


  • Profound Logic Solution Guide

    SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation.
    Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects.
    The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the companyare not aligned with the current IT environment.

    Get your copy of this important guide today!


  • 2022 IBM i Marketplace Survey Results

    Fortra2022 marks the eighth edition of the IBM i Marketplace Survey Results. Each year, Fortra captures data on how businesses use the IBM i platform and the IT and cybersecurity initiatives it supports.

    Over the years, this survey has become a true industry benchmark, revealing to readers the trends that are shaping and driving the market and providing insight into what the future may bring for this technology.

  • Brunswick bowls a perfect 300 with LANSA!

    FortraBrunswick is the leader in bowling products, services, and industry expertise for the development and renovation of new and existing bowling centers and mixed-use recreation facilities across the entertainment industry. However, the lifeblood of Brunswick’s capital equipment business was running on a 15-year-old software application written in Visual Basic 6 (VB6) with a SQL Server back-end. The application was at the end of its life and needed to be replaced.
    With the help of Visual LANSA, they found an easy-to-use, long-term platform that enabled their team to collaborate, innovate, and integrate with existing systems and databases within a single platform.
    Read the case study to learn how they achieved success and increased the speed of development by 30% with Visual LANSA.


  • Progressive Web Apps: Create a Universal Experience Across All Devices

    LANSAProgressive Web Apps allow you to reach anyone, anywhere, and on any device with a single unified codebase. This means that your applications—regardless of browser, device, or platform—instantly become more reliable and consistent. They are the present and future of application development, and more and more businesses are catching on.
    Download this whitepaper and learn:

    • How PWAs support fast application development and streamline DevOps
    • How to give your business a competitive edge using PWAs
    • What makes progressive web apps so versatile, both online and offline



  • The Power of Coding in a Low-Code Solution

    LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed.
    Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

    • Discover the benefits of Low-code's quick application creation
    • Understand the differences in model-based and language-based Low-Code platforms
    • Explore the strengths of LANSA's Low-Code Solution to Low-Code’s biggest drawbacks



  • Why Migrate When You Can Modernize?

    LANSABusiness users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
    In this white paper, you’ll learn how to think of these issues as opportunities rather than problems. We’ll explore motivations to migrate or modernize, their risks and considerations you should be aware of before embarking on a (migration or modernization) project.
    Lastly, we’ll discuss how modernizing IBM i applications with optimized business workflows, integration with other technologies and new mobile and web user interfaces will enable IT – and the business – to experience time-added value and much more.


  • UPDATED: Developer Kit: Making a Business Case for Modernization and Beyond

    Profound Logic Software, Inc.Having trouble getting management approval for modernization projects? The problem may be you're not speaking enough "business" to them.

    This Developer Kit provides you study-backed data and a ready-to-use business case template to help get your very next development project approved!

  • What to Do When Your AS/400 Talent Retires

    FortraIT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators is small.

    This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:

    • Why IBM i skills depletion is a top concern
    • How leading organizations are coping
    • Where automation will make the biggest impact


  • Node.js on IBM i Webinar Series Pt. 2: Setting Up Your Development Tools

    Profound Logic Software, Inc.Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. In Part 2, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Attend this webinar to learn:

    • Different tools to develop Node.js applications on IBM i
    • Debugging Node.js
    • The basics of Git and tools to help those new to it
    • Using as a pre-built development environment



  • Expert Tips for IBM i Security: Beyond the Basics

    SB PowerTech WC GenericIn this session, IBM i security expert Robin Tatam provides a quick recap of IBM i security basics and guides you through some advanced cybersecurity techniques that can help you take data protection to the next level. Robin will cover:

    • Reducing the risk posed by special authorities
    • Establishing object-level security
    • Overseeing user actions and data access

    Don't miss this chance to take your knowledge of IBM i security beyond the basics.



  • 5 IBM i Security Quick Wins

    SB PowerTech WC GenericIn today’s threat landscape, upper management is laser-focused on cybersecurity. You need to make progress in securing your systems—and make it fast.
    There’s no shortage of actions you could take, but what tactics will actually deliver the results you need? And how can you find a security strategy that fits your budget and time constraints?
    Join top IBM i security expert Robin Tatam as he outlines the five fastest and most impactful changes you can make to strengthen IBM i security this year.
    Your system didn’t become unsecure overnight and you won’t be able to turn it around overnight either. But quick wins are possible with IBM i security, and Robin Tatam will show you how to achieve them.

  • Security Bulletin: Malware Infection Discovered on IBM i Server!

    SB PowerTech WC GenericMalicious programs can bring entire businesses to their knees—and IBM i shops are not immune. It’s critical to grasp the true impact malware can have on IBM i and the network that connects to it. Attend this webinar to gain a thorough understanding of the relationships between:

    • Viruses, native objects, and the integrated file system (IFS)
    • Power Systems and Windows-based viruses and malware
    • PC-based anti-virus scanning versus native IBM i scanning

    There are a number of ways you can minimize your exposure to viruses. IBM i security expert Sandi Moore explains the facts, including how to ensure you're fully protected and compliant with regulations such as PCI.



  • Encryption on IBM i Simplified

    SB PowerTech WC GenericDB2 Field Procedures (FieldProcs) were introduced in IBM i 7.1 and have greatly simplified encryption, often without requiring any application changes. Now you can quickly encrypt sensitive data on the IBM i including PII, PCI, PHI data in your physical files and tables.
    Watch this webinar to learn how you can quickly implement encryption on the IBM i. During the webinar, security expert Robin Tatam will show you how to:

    • Use Field Procedures to automate encryption and decryption
    • Restrict and mask field level access by user or group
    • Meet compliance requirements with effective key management and audit trails


  • Lessons Learned from IBM i Cyber Attacks

    SB PowerTech WC GenericDespite the many options IBM has provided to protect your systems and data, many organizations still struggle to apply appropriate security controls.
    In this webinar, you'll get insight into how the criminals accessed these systems, the fallout from these attacks, and how the incidents could have been avoided by following security best practices.

    • Learn which security gaps cyber criminals love most
    • Find out how other IBM i organizations have fallen victim
    • Get the details on policies and processes you can implement to protect your organization, even when staff works from home

    You will learn the steps you can take to avoid the mistakes made in these examples, as well as other inadequate and misconfigured settings that put businesses at risk.



  • The Power of Coding in a Low-Code Solution

    SB PowerTech WC GenericWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed.
    Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

    • Discover the benefits of Low-code's quick application creation
    • Understand the differences in model-based and language-based Low-Code platforms
    • Explore the strengths of LANSA's Low-Code Solution to Low-Code’s biggest drawbacks



  • Node Webinar Series Pt. 1: The World of Node.js on IBM i

    SB Profound WC GenericHave you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.
    Part 1 will teach you what Node.js is, why it's a great option for IBM i shops, and how to take advantage of the ecosystem surrounding Node.
    In addition to background information, our Director of Product Development Scott Klement will demonstrate applications that take advantage of the Node Package Manager (npm).
    Watch Now.

  • The Biggest Mistakes in IBM i Security

    SB Profound WC Generic The Biggest Mistakes in IBM i Security
    Here’s the harsh reality: cybersecurity pros have to get their jobs right every single day, while an attacker only has to succeed once to do incredible damage.
    Whether that’s thousands of exposed records, millions of dollars in fines and legal fees, or diminished share value, it’s easy to judge organizations that fall victim. IBM i enjoys an enviable reputation for security, but no system is impervious to mistakes.
    Join this webinar to learn about the biggest errors made when securing a Power Systems server.
    This knowledge is critical for ensuring integrity of your application data and preventing you from becoming the next Equifax. It’s also essential for complying with all formal regulations, including SOX, PCI, GDPR, and HIPAA
    Watch Now.

  • Comply in 5! Well, actually UNDER 5 minutes!!

    SB CYBRA PPL 5382

    TRY the one package that solves all your document design and printing challenges on all your platforms.

    Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product.

    Request your trial now!

  • Backup and Recovery on IBM i: Your Strategy for the Unexpected

    FortraRobot automates the routine tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:
    - Simplified backup procedures
    - Easy data encryption
    - Save media management
    - Guided restoration
    - Seamless product integration
    Make sure your data survives when catastrophe hits. Try the Robot Backup and Recovery Solution FREE for 30 days.

  • Manage IBM i Messages by Exception with Robot

    SB HelpSystems SC 5413Managing messages on your IBM i can be more than a full-time job if you have to do it manually. How can you be sure you won’t miss important system events?
    Automate your message center with the Robot Message Management Solution. Key features include:
    - Automated message management
    - Tailored notifications and automatic escalation
    - System-wide control of your IBM i partitions
    - Two-way system notifications from your mobile device
    - Seamless product integration
    Try the Robot Message Management Solution FREE for 30 days.

  • Easiest Way to Save Money? Stop Printing IBM i Reports

    FortraRobot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing.
    Manage your reports with the Robot Report Management Solution. Key features include:

    - Automated report distribution
    - View online without delay
    - Browser interface to make notes
    - Custom retention capabilities
    - Seamless product integration
    Rerun another report? Never again. Try the Robot Report Management Solution FREE for 30 days.

  • Hassle-Free IBM i Operations around the Clock

    SB HelpSystems SC 5413For over 30 years, Robot has been a leader in systems management for IBM i.
    Manage your job schedule with the Robot Job Scheduling Solution. Key features include:
    - Automated batch, interactive, and cross-platform scheduling
    - Event-driven dependency processing
    - Centralized monitoring and reporting
    - Audit log and ready-to-use reports
    - Seamless product integration
    Scale your software, not your staff. Try the Robot Job Scheduling Solution FREE for 30 days.