Professional Documents
Culture Documents
Introduction
Web Services are a large and often detailed collection of subjects. This chapter brings
together many of the most commonly asked questions about Web Services, SOAP, XML,
and related topics. Further details on most of these subjects are found later in this book.
Web Services
Web Services increase code reuse, simplify system design, breathe new life into old sys-
tems, are fully standards-based, and can make you a coffee.
Despite the marketing hype, Web Services really can make it easier to reuse and recom-
bine old work, and integrate pre-written code. Additionally, Web Services are fashionable
and one of the most effective tools for motivating developers is to give them projects that
involve learning new and popular skills.
Standards Web Services will keep us busy for the next ten years.
Developers
Web Services are a system for defining and implementing platform-neutral multi-computer
systems. Based on dozens of standards, Web Services allow for data exchange processing
cooperation, process choreography, and overall security. Apart from the core standards
(XML, XML Schema, SOAP and WSDL), there are competitive standards for virtually every
component of a Web Service. The core standards include substantial portions which are
rarely, if ever, implemented. Likewise, many ancillary standards, like XLink, may never be
adopted commercially.
Web Services are most commonly implemented through SOAP messages sent over the
Web. However, Web Services can be implemented without SOAP, and SOAP messages
can be sent without the Web. For example, SOAP messages can theoretically be sent over
email. The “Web” in Web Services is often conceptual rather than technical.
Are 4th Dimension’s Web Services Compatible with .Net? With J2EE?
While the core Web Service standards, including SOAP and XML, are shared by all major
software vendors, there is no single Web Services framework. Microsoft and other domi-
nant vendors are creating Web Service-oriented frameworks that add proprietary tools and
extensions onto the core standards. 4th Dimension is fully compatible with the core stan-
dards shared by all Web Services implementations. As the marketplace matures,
4th Dimension regularly adds new features to maintain or increase compatibility with
other environments. For example, 4th Dimension 2004 added support for SOAP 1.2, set-
ting SOAP headers, and enhanced support for messaging-style (DOC) communications.
XML
J2EE SOAP .Net
HTTP
J2EE and .Net share support for core Web Service standards.
SOAP has the advantages that it's simpler and easier to implement than
any existing alternative, and makes better use of the pervasive Web
infrastructure. The effect is that you can pull a system together using
SOAP in weeks, not quarters.
Obviously, the alternatives offer richer feature sets, particularly in the
area of transaction semantics, security, and so on, but at a dramatically
higher cost. SOAP will not sweep all before it; but it will be very widely
deployed across the Internet and the intranets of this world.
HTML None, Web Services do not use HTML. None, Web Services do not use HTML.
HTTP How to turn on the 4th Dimension Web server. How to type in a URL.
SOAP
What Is SOAP?
SOAP is an acronym standing for the Simple Object Access Protocol. As stated in the
SOAP specification, SOAP is a lightweight protocol for exchanging information in a dis-
tributed environment. It is an XML-based format that consists of three parts: an envelope
that defines a framework for describing the contents of a message and how to process it,
a set of encoding rules for expressing instances of application-defined data types, and a
convention for representing remote procedure calls and responses. Put in plainer lan-
guage, SOAP is a system for sharing and exchanging data and features amongst programs
on a network.
Note 4th Dimension, like many tools, only supports SOAP over HTTP.
Can a 4th Dimension System Be Both a SOAP Server and a SOAP Client?
Yes.
Does a 4th Dimension System Need to be Both a SOAP Server and a SOAP Client?
No. A 4th Dimension database can be a SOAP server, SOAP client, or both. The SOAP
server and SOAP client features are entirely independent. Of course, 4th Dimension may
act as a SOAP client to 4th Dimension SOAP servers, including the same application.
What Is SoapAction?
HTTP is the most commonly used transport mechanism for SOAP messages. The SOAP
1.1 specification acknowledges this practice by specifying a SOAP-specific HTTP request
header named SoapAction. This header is part of the HTTP request, not a part of the
SOAP message included with the HTTP request. This distinction is important for two rea-
sons:
■ The SoapAction header value is not bound by the rules of XML and may contain
any valid string.
■ The Web server can inspect the header and determine what the SOAP message re-
quires without parsing the SOAP message.
4th Dimension supports the SoapAction header both as a Web Service publisher and as
a SOAP client. A typical SoapAction header looks like the one highlighted below:
Are any Special Licenses or Plug-ins Required to Use 4th Dimension as a SOAP Server?
The 4th Dimension SOAP server requires a copy of the 4D Web Services Server License.
Although the SOAP server runs on top of the native 4th Dimension Web server, the 4D
Web Services Server License does not automatically license the full Web Server. To use the
native Web server for tasks other than SOAP requires a separate 4D Web Server License.
No plug-ins are required by either the Web server or the SOAP server.
4D 2003 In 4th Dimension 2003, a single license enabled both the native Web server and the SOAP server.
These license are split in 4th Dimension 2004. Fortunately, the cost of the two licenses in
4th Dimension 2004 matches the price of the combined license in 2003. The 2004 licensing
scheme is cheaper for developers needing only the Web server or the SOAP server.
Are any Special Licenses or Plug-ins Required to Use 4th Dimension as a SOAP Client?
No. 4th Dimension’s SOAP client features are built into the program. No plug-ins or extra
licenses are required.
SET WEB SERVICE OPTION(Web Service SOAP Version ;Web Service SOAP_1_2 )
What Is REST?
REST (REpresentational State Transfer) is an architectural philosophy for constructing Web
Services. REST is sometimes called “XML over HTTP.” From a developer’s point of view,
REST’s significant features include:
■ Requiring messages to be sent over HTTP (Web) rather than also supporting proto-
cols such as email.
■ Sending Web Service requests using HTTP GET (URLs) or POST (Web forms) in-
stead of through SOAP messages.
■ Simplified testing and development since request generation is simple enough to
do with a text editor and a browser, or just a browser.
■ Structuring Web Services as a series of navigation links, just like the Web in general.
In practice, this entails, for example, sending a list of links to record details rather
than sending a series of full records in a single response.
REST is finding support from a significant minority of Web Service developers and service
providers. For example, Amazon and Xignite provide both REST and SOAP interfaces for
their Web Services.
What Is XML-RPC?
XML-RPC is a predecessor of SOAP that offers much of the same functionality. Despite
having the more complex-sounding name, XML-RPC is by far simpler. The entire XML-
RPC standard prints out onto two pieces of paper and can be implemented with relatively
little effort. XML-RPC offers fewer data encoding options than SOAP, which is based on
the XML Schema data types. XML-RPC is still a viable standard but is less likely to see new
implementations given the overwhelming industry adoption of SOAP.
XML
What is XML?
XML opens the door to interoperable information. My dream: In a decade
or so, ‘proprietary, noninteroperable information’ sounds as silly as
‘proprietary, noninteroperable network’ does today.”
T im Bray — co-creator of XML
XML is an acronym standing for the eXtensible Markup Language. Based on the older and
more complex Standard Generalized Markup Language (SGML), XML is a language for
defining structured documents, messages, and data. In a formal sense, XML (and its exten-
sions) provide a formal grammar for defining formal grammars. XML is not a program-
ming language, network protocol, or data format, although all of these things may use or
depend on XML.
Why Does Working with XML Always Sound Easy and then Turn Out to Be Difficult?
XML is fussy. If you have a 10Mb XML document with a single flaw—say an error in cap-
italization of a single letter in a single XML element name—the entire document is invalid.
The XML standard accommodates the needs and interests of two communities with
largely unrelated needs, backgrounds, goals, preferences, and sensibilities:
What Tools Does 4th Dimension Provide for Working with XML?
Because of its complexity, XML can be challenging to learn in detail. Fortunately, there is
typically no need to learn how to read and write XML generically. Instead, programmers
usually need to read and write specific XML documents or messages. 4th Dimension pro-
vides several tools for this purpose:
■ The language supports parsing and navigating XML stored in documents, text,
BLOBs, or at specific URLs.
■ The import/export editor can read and write XML. This feature can be convenient
for importing and exporting and as a way of experimenting with XML formatted
files.
■ 4th Dimension automatically parses and produces correctly formatted SOAP mes-
sages, which are in an XML format, when used as a SOAP server or SOAP client.
■ 4th Dimension 2004 includes an extensive collection of high-level and low-level
commands for reading and writing XML as a tree (DOM-style) or a stream (SAX-
style.) A simplified subset of XPath notation significantly reduces the complexity of
finding and creating nested nodes.
■ There are numerous free and commercial components and plug-ins available for
4th Dimension that add additional parsing, XML production, and XML navigation
features.
■ Example code included with this book or freely available from 4th Dimension im-
plement many standard XML parsing algorithms, XML-related utilities, and SOAP
APIs.
XML Namespaces
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
http://www.example_1.com/GetPrice
http://www.example_2.com/GetPrice
http://www.example_3.com/GetPrice
This standard Web behavior makes it possible, for example, for a vertical market applica-
tion to include Web Services. Each copy of the program runs on a different server, so
there is never any confusion about which instance to use.
So what, then, do namespaces do? Namespaces are used by programs, such as XSLT pro-
cessors, that read elements from multiple XML documents simultaneously. As an example,
a server can produce any number of XML documents with an element named customer.
If the documents come from different sources, such as different databases, the child ele-
ments of customer might be entirely different. Namespaces work as definition-specific
prefixes to enable a program, like an XSLT processor, to keep the different meanings of
otherwise identically named elements distinct.
mailto:dpadams@island-data.com
http://www.4dcompanion.com/namespaces/conversions/
http://www.4dcompanion.com/namespace=conversions
http://www.example.com/conversions.shtml
telnet://telnet.foo.com/
WSDL
What is WSDL?
WSDL is an acronym standing for the Web Service Description Language. WSDL files are
like programmer’s references or user’s manuals for specific Web Services. Methods,
parameters, and other information are each formally described in an XML-based format.
Warning Note that many development environments only communicate with Web Services that provide a
WSDL file.
HTTP
What is HTTP?
HTTP is the HyperText Transfer Protocol, commonly known as the Web.
UDDI
What is UDDI?
UDDI stands for the Universal Description, Discovery, and Integration standard. UDDI is
a high-level protocol that defines an active directory system for Web Services and busi-
nesses. UDDI provides or defines mechanisms and APIs for dynamically locating, binding
with, or publishing Web Services over SOAP. Web Service registries, like XMethods (http:/
/www.xmethods.com/) provide UDDI interfaces as an option. UDDI-specific registries
like BindingPoint (http://www.bindingpoint.com/) provide full Web Service and business
registry services.
Tip See 4D, Inc. Technical Note 03-12 “UDDI Client as a SOAP Example” for an excellent introduction
to UDDI and a sample 4th Dimension UDDI client.
Server Client
Get SOAP info AUTHENTICATE WEB SERVICE
4D 2003 The SET WEB SERVICE OPTION command requires 4th Dimension 2004 or later.
How Can 4th Dimension SOAP Clients Authenticate Themselves to Web Services?
The AUTHENTICATE WEB SERVER command enables 4th Dimension SOAP client code to
include an HTTP Basic authentication user name and password with SOAP requests.
Some Web Services manage authentication through custom SOAP headers, a requirement
that can be satisfied using the SET WEB SERVICE OPTION command, as in the code fragment
shown below:
C_STRING(16;$xmlref)
C_STRING(16;$xmlnode)
$xmlref:=DOM Create XML Ref("Header")
$xmlnode:=DOM Create XML element($xmlref;"Username")
DOM SET XML ELEMENT VALUE($xmlnode;"donald@duck.com")
Based on the code fragment listed above, 4th Dimension produces the requested User-
name SOAP header, as illustrated in the XML fragment below:
<SOAP-ENV:Header>
<Header>
<Username>donald@duck.com</Username>
</Header>
</SOAP-ENV:Header>
4D 2003 The SET WEB SERVICE OPTION command requires 4th Dimension 2004 or later.
The method listed above takes the text to pass the Web Service as a parameter, enabling
any number of internal 4th Dimension methods to call the remote Web Service without
writing any Web Service code. All of the Web Service code is centralized in the proxy
method. The overall relationships amongst methods is diagrammed below:
4th Dimension
Web Service
AP
SOAP SO
Proxy Method Network
In reality, a proxy method calls an outside Web Service using SOAP.Within the
4th Dimension database, the proxy method makes the Web Service appear and function
like a local method, as diagrammed below:
4th Dimension
Web Service
Can I Create Web Service Clients Without the Web Services Wizard?
Yes. The Web Services Wizard automates the process of creating Web Service client code,
but it is not required. Many developers use the Web Services Wizard to quickly create a
method that they then hand-tune.
What Web Service Message Styles Does 4th Dimension Support as a SOAP Client?
The XML, SOAP and WSDL standards in their entirety are each large, detailed, extensible,
and highly flexible. There are several ways to design Web Service messages, some more
complex than others. The basic pattern chosen depends largely on the development envi-
ronment used to build the host Web Service. The best-known and most important differ-
ence is between “RPC-style” and “DOC-style” formats. RPC-style formats are simpler to
read and write, but less flexible. DOC-style is a message-oriented format that, while more
complex to manipulate, is extremely flexible. Increasingly, DOC-style Web Services are
coming to dominate, partly because .Net favors DOC-style. Besides RPC-style and DOC-
style SOAP messages, an increasing minority of Web Services are based on standard URLs
and HTTP GET or POST without SOAP. The Web Service Wizard and underlying language
in 4th Dimension support for these various approaches to Web Services, as summarized in
the table below:
4th Dimension’s support for XPath notation for reading and writing XML dramatically sim-
plify working with complex XML. Third-party plug-ins and components also offer addi-
tional tools for advanced XML programming.
Does the 4th Dimension SOAP Server Require the 4th Dimension Web Server?
Yes. You can’t use 4th Dimension’s native SOAP serving features without the native Web server.
However, you do not need to license the full Web server if you only need the SOAP features. If
you prefer to use an ITK-based Web server, you must write your own SOAP serving code.
What SOAP Message Styles Does 4th Dimension Support as a SOAP Server?
The 4th Dimension 2004 SOAP server supports RPC-style or DOC-style messages.
How Many Web Services Can a Single 4th Dimension Program Publish?
A single 4th Dimension database may offer as many methods as needed as Web Services,
however, all of the methods are grouped within a single Web Service name.
See Also Multiple service names can be hosted by a single 4th Dimension database by saving and hand-tun-
ing WSDL files. For more information, see Organizing Web Service Methods Thematically
in the Hand-Tuning WSDL Files chapter, starting on page 314.
What Security Options Does 4th Dimension Provide for Web Services?
All of the security features of the native 4th Dimension Web server are available for Web Services,
including SSL support.
Standards Documents
The nice thing about standards is that there are so many to choose from.
Andrew S. Tannenbaum, author of MINIX, an open-source UNIX clone.
What is BNF?
The bulk of Internet standards you’re likely to encounter are written using some aug-
mented version of Backus-Naur Form (BNF) grammar. The picture below illustrates a typ-
ical use of this grammar found in section 2.3 of the XML 1.0 recommendation:
Until you are comfortable with BNF, standards are difficult to follow. Sometimes, it’s eas-
ier to read books, Web sites, and discussion list postings that translate standards into more
familiar terminology or offer detailed examples of real implementations.
Why Do Standards Capitalize Words such as MUST and SHOULD and MAY?
The capitalized words you see in standards are requirements keywords. (See RFC 2119 or
the standard you’re reading for definitions.) Standards allow for various levels of imple-
mentation or conformance. Different programs can support the same standard more or
less completely. The specification keywords distinguish required and optional features.
The example below is drawn from section 3 of the SOAP 1.1 recommendation:
Specification Location
XML home page at the World Wide Web Consortium’s site http://www.w3.org/XML/