Sei sulla pagina 1di 18

The 4th Dimension Web Services Companion 19

Web Services: Questions and Answers


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
What Are Web Services?
The term Web Services is a term used differently by marketing, management, standards
committees, and regular programmers. When one term is used by such different commu-
nities, it is unreasonable to expect to nd a single, crisp and unambiguous meaning.
What Do Web Services Have to Do with the Web?
Web services are not the Web and are not services, but Internet
middleware enabling you to link to customers, partners and operating
groups.
George Colony Founder and CEO of Forrester Research
Point of View Description
Marketing Web Services are a great way to sell tools and 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.
Management Web Services are a great way to save money.
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
Developers
Web Services will keep us busy for the next ten years.
Web Services are a system for dening 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.
Regular
Programmers
Web Services are a great way to share programs.
As most commonly used, Web Services are a Remote Procedure Calling system that trans-
fers XML payloads over HTTP. Web Service interfaces are readily thought of as network-
readable APIs. Also, theyre fun.
2
Chapter 2 - Web Services: Questions and Answers
20 The 4th Dimension Web Services Companion
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.
Why Are Web Services so Fashionable?
Todays variety of computer platforms, operating systems, programming languages, and
development environments shows no signs of diminishing. Heterogeneity is the norm in
the IT world, has always been so, and will remain so for the foreseeable future. Getting
diverse systems to communicate and cooperate is an ongoing challenge for many organi-
zations. Past efforts to create an overall framework for network-oriented program integra-
tion, such as DCOM and CORBA, are complex, proprietary, and expensive to implement.
Reducing the cost and complexity of integration projects is a driving force behind Web
Services standardization and adoption. While current Web Service systems have fewer fea-
tures than a system like CORBA, todays Web Services offer more features than developers
actually need. Fortunately, the largest software vendors in the world, including
Microsoft, IBM, Sun, and Oracleare cooperating on the core Web Service standards.
4th Dimensions Web Services features enable developers to quickly and easily publish
and subscribe to Web Services.
Are 4th Dimensions 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.

J2EE and .Net share support for core Web Service standards.
Are Web Services New?
Yes and no. The SOAP and WSDL standards are relatively new, but the idea of sending
messages between programs over a network has been around for decades. Past efforts to
create network-oriented distributed object frameworks like CORBA, DCOM, and Java RMI
havent gone to waste. While creating these tools, the computer science and application
development communities discovered and learned important information about how to
build widely distributed systems. In the words of Tim Bray, co-editor of the XML 1.0 spec:
J2EE .Net
XML
SOAP
HTTP
The 4th Dimension Web Services Companion 21
Learning Web Services
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.
Learning Web Services
What Do I Need to Learn to Start Using Web Services?
Given the range of tools, standards, languages, trends, and fads that appear (and disap-
pear) every year, developers need to choose carefully before devoting time to new tools.
The ideal subject is:
1. Relatively easy to learn.
2. Readily applicable to contemporary problems.
3. Broadly accepted.
4. Reasonably likely to be important for years to come.
Web Services satisfy all of these conditions. As a comparison, basic Web Services are eas-
ier to learn than HTML and Web site construction. Additionally, its often easier to make a
strong business case for Web Services rather than standard Web site construction since
Web Services can be much narrower in scope. The table below summarizes the knowl-
edge a 4th Dimension developer needs in order to start using Web Services, in addition to
the a general understanding of Web Services.
Do I Need to Learn Web design and HTML?
No. SOAP messages are a system for program-to-program communications, not end-user
display. HTML is never used in SOAP. Programmer documentation for Web Services is
typically built in WSDL, an XML-based le-format. WSDL les typically display poorly, if
at all, in browsers. WSDL les are much easier to read in a WSDL-aware program, such as
4th Dimensions Web Services Wizard, StrikeIrons (http://www.strikeiron.com/) WSDL
Analyzer, Altovas XMLSpy (http://www.altova.com/), or an on-line tool like the Generic
SOAP Client (http://soapclient.com/soaptest.html).
Subject
Knowledge Needed for
Web Services Publishing
Knowledge Needed for
Web Services Client Development
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 How to activate 4th Dimension Web Services. None to minimal.
WSDL None to minimal. None to minimal.
XML None. None to considerable.
Chapter 2 - Web Services: Questions and Answers
22 The 4th Dimension Web Services Companion
What Else Do I Need to Learn for More Advanced Projects?
More advanced projects typically require a developer to understand only a subset of
SOAP and XML. Typically, what is needed is a more detailed knowledge of parsing, navi-
gating, and constructing XML, subjects discussed in detail later in this book.
Do I Need to Learn to Hand-Write XML, XML Schema, DTDs, WSDL, Etc.?
Chances are you will never need to learn to hand-write any of the les involved in imple-
menting Web Services. The most likely exceptions are learning to hand-tune WSDL les
and parse or construct XML les. Until you have an actual need for this knowledge, how-
ever, you can ignore these topics. Part of the purpose of SOAP is to insulate developers
from the intricacies and details of XML. Automated toolsincluding 4th Dimensioncon-
tinue to get better and better at automating the construction and consumption of all of the
necessary les and formats. Later chapters in this book contain most, if not all, of the
detailed knowledge you are likely to need about XML, SOAP, and WSDL.
SOAP
What Is SOAP?
SOAP is an acronym standing for the Simple Object Access Protocol. As stated in the
SOAP specication, 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 denes a framework for describing the contents of a message and how to process it,
a set of encoding rules for expressing instances of application-dened 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.
Does SOAP Require a Network?
No. SOAP messages can be used to exchange messages between programs running on a
single machine. In fact, using 4th Dimension, you can even have a program send itself
SOAP messages. This is convenient way to test 4th Dimension-based Web Services.
Does SOAP Require the Web?
No. In practice, SOAP messages are almost always sent over HTTP, but this is not a
requirement. You could, for example, submit SOAP messages over email for later process-
ing.
Note 4th Dimension, like many tools, only supports SOAP over HTTP.
What Is a SOAP Server?
A SOAP server is a piece of software capable of receiving, processing, and replying to
SOAP messages.
What Is a SOAP Client?
A SOAP client is a piece of software capable of creating and sending SOAP requests and
processing SOAP responses.
The 4th Dimension Web Services Companion 23
SOAP
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 the Difference Between RPC and DOC?
The WSDL standard denes two types of SOAP messages, RPC (Remote Procedure Call)
and DOC (Document). Often, either style can be used for a particular service. In fact,
when looking at a particular SOAP message there is often no way to determine if it is
build for an RPC-style or DOC-style exchange. RPC-style is typically less complex and eas-
ier to implement, while DOC style is more abstracted, complex, and exible.
4th Dimension 2004 supports both RPC-style and DOC-style messaging, as summarized in
the table below:.
What Is SoapAction?
HTTP is the most commonly used transport mechanism for SOAP messages. The SOAP
1.1 specication acknowledges this practice by specifying a SOAP-specic 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:
POST /4DSOAP/ HTTP/1.1
User-Agent: 4D built-in SOAP Client
Date: Thu, 07 Aug 2003 23:57:38 GMT
Content-Type: text/xml; charset=utf-8
Host: 192.168.1.104
Connection: Close
SoapAction: "Conversions#textToUppercase"
Content-Length: 450
4th Dimension includes the SoapAction header with every request generated by the
CALL WEB SERVICE command, unless the message is congured as using SOAP 1.2 with the
SET WEB SERVICE OPTION command. The SOAP 1.2 standard no longer uses the SoapAc-
tion header. However, in light of the widespread use of SoapAction, the SOAP 1.2
standard allows an action to be added to the Content-Type HTTP header, as in the
HTTP fragment below:
Feature RPC DOC
SOAP Server Automatic Automatic or custom programming
SOAP Client Automatic Automatic or custom programming
Chapter 2 - Web Services: Questions and Answers
24 The 4th Dimension Web Services Companion
POST /4DSOAP/ HTTP/1.1
User-Agent: 4D built-in SOAP Client
Date: Thu, 07 Aug 2003 23:57:38 GMT
Content-Type: application/soap+xml; action=Conversions#textToUppercase
Host: 192.168.1.104
Connection: Close
Content-Length: 450
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 Dimensions SOAP client features are built into the program. No plug-ins or extra
licenses are required.
What Version of SOAP Does 4th Dimension Support?
4th Dimension 2004 supports SOAP 1.1 and SOAP 1.2 as a client or Server. As a SOAP
server, 4th Dimension 2004 sets the SOAP version to match the incoming request. As a
SOAP client, 4th Dimension defaults to using SOAP 1.1 messages. This behavior can be
overridden by using the SET WEB SERVICE OPTION command prior to calling the CALL WEB
SERVICE command, as in the statement below:
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 developers point of view,
RESTs signicant 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.
Simplied 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 nding support from a signicant minority of Web Service developers and service
providers. For example, Amazon and Xignite provide both REST and SOAP interfaces for
their Web Services.
The 4th Dimension Web Services Companion 25
XML
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.
Tim Bray co-creator of XML
XML is a giant step in no direction at all.
Erik Naggum SGML luminary and Internet aphorist
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
dening structured documents, messages, and data. In a formal sense, XML (and its exten-
sions) provide a formal grammar for dening 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.
Do I Need to Learn XML to Work with SOAP?
One of the purposes of SOAP is to insulate developers from the underlying intricacies of
XML. The 4th Dimension SOAP server requires no knowledge of XML whatsoever.
4th Dimensions SOAP client can be used with many Web Servicesincluding any offered
by the 4th Dimension SOAP serverwith no knowledge of XML. XML knowledge is
required only when working with Web Services that use complex or DOC-style inputs or
outputs that 4th Dimension cannot automatically parse.
What Is an XML Application?
The term XML application can be confusing since it is used in different contexts to apply
to two different things: software for processing XML and documents written to conform to
the rules of a specic XML-based document type. For example, Xerces, TinyXML, and
Expat are all examples of XML parsers, which programmers would typically call an appli-
cation. WSDL les and SOAP messages are examples of XML-based document types that
are formally called XML applications instead of XML documents. Given these two uses
of the terms, the following sentence is valid, if ambiguous: Ive just written an XML appli-
cation to process my XML application.
Chapter 2 - Web Services: Questions and Answers
26 The 4th Dimension Web Services Companion
What Does XML Look Like?
XML is always text so that it can be read by humans or machines. As an example, below
is a small 4th Dimension table, a record from the table, and a sample XML export le gen-
erated by the 4th Dimension Export Editor:
Why Is XML So Popular?
The XML standard and its key extensions, like XML Schema, are detailed, precise, exible,
and complicated. Because of its exibility, XML is used by hundreds of other standards,
including WSDL and SOAP. By now, XML has gained enormous momentum as the default
solution for custom document encoding. In a sense, XML is popular precisely because
XML is popular.
Why Does Working with XML Always Sound Easy and then Turn Out to Be Difcult?
XML is fussy. If you have a 10Mb XML document with a single awsay an error in cap-
italization of a single letter in a single XML element namethe entire document is invalid.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--Created by 4th Dimension -->
<Contact>
<Contact>
<Contact_ID>109</Contact_ID>
<Company_ID>899</Company_ID>
<First_Name>John</First_Name>
<Last_Name>West</Last_Name>
<Date_of_Birth>1972-04-24T00:00:00</Date_of_Birth>
</Contact>
</Contact>
The 4th Dimension Web Services Companion 27
XML
Why Is XML So Complicated?
A camel is a horse designed by a committee.
Sir Alec Issignois Designer of the Morris Minor and Morris Mini
The XML standard accommodates the needs and interests of two communities with
largely unrelated needs, backgrounds, goals, preferences, and sensibilities:
Authors of structured, narrative-oriented documents. Technical writers using Frame-
maker are an example of this category of users.
Programmers packaging program data for storage and exchange.
XML is further complicated by the wildly varied backgrounds and preferences of the peo-
ple contributing to the standards. Every programming language has its own collection of
data types and approaches to structured data. While there are many commonalities across
languages, there are important differences as well. XML (and XML Schema) were
designed to accommodate virtually any known programming language. Consequently,
you will need only a tiny fraction of the data types XML supports for any particular lan-
guage. The rest of the standard, by denition, solves problems youll never have. As an
indication of the scale of the extra complexity, in printed form, the standards for XML,
XML Schema, SOAP, and WSDL are about the size of a phone book. In comparison, the
XML-RPC standarda simpler alternative to SOAPts on two pieces of paper.
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 specic 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 specic 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
les.
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 simplied subset of XPath notation signicantly reduces the complexity of
nding 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.
What Version of XML Does 4th Dimension Support?
4th Dimension supports XML 1.0.
Chapter 2 - Web Services: Questions and Answers
28 The 4th Dimension Web Services Companion
XML Namespaces
What Are XML Namespaces?
The elements and attributes in an XML document can be formally dened, much as data-
base elds are dened. For example, an element like first_name can have a type, list
of allowed values, and other properties in XML. XML namespaces act as a reference to a
specic structured XML denition. Namespaces serve several purposes:
Distinguishing between element denitions in a document that includes multiple
namespaces. SOAP messages always include multiple namespaces, for example.
Enabling programs to identify specic kinds of documents, such as SOAP messages
or WSDL documents. 4th Dimensions Web Service Wizard, for example, can inter-
pret WSDL documents rather than simply parsing them as generic XML.
Supporting applications, such as XSLT processors, that prefer or require elements
to use full namespace notation.
See Also See XML Namespaces in the XML (eXtensible Markup Language) chapter, starting on
page 77, for more details.
What do Namespaces Look Like?
Several namespace declarations are highlighted in the SOAP 1.1 fragment below:
<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">
What Do Namespaces Have to Do with Web Services?
Namespaces enable XML documents with identical element names to remain distinct. This
is different than keeping Web Service names distinct. Web Services are distinguished by
their URLs, just like Web pages. For example, Web Services named GetPrice running on
three different servers are readily distinguished by their request URLs:
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 denition-specic
prexes to enable a program, like an XSLT processor, to keep the different meanings of
otherwise identically named elements distinct.
The 4th Dimension Web Services Companion 29
WSDL
What Are Some Examples of Valid Namespaces?
You have a lot of freedom in selecting namespaces. The only requirement is that they be
a legal URI which means, for all practical purposes, a legal URL. The URL doesnt need to
point to an actual Web page or other resource, it simply needs to be properly constructed.
(Its a good practice to make the URI a valid URL, all the same.) Below are some valid
namespaces:
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 les are
like programmers references or users manuals for specic Web Services. Methods,
parameters, and other information are each formally described in an XML-based format.
How Do I Read WSDL Files?
WSDL les are an XML document type and can be read by any text editor, XML editor, or
XML-aware browser. Moreover, there is an increasing range of WSDL-aware programs.
For example:
4th Dimensions Web Services Wizard.
StrikeIrons WSDL Analyzer:
http://www.strikeiron.com/
Xmethods interactive on-line WSDL analyzer:
http://www.xmethods.com/ve2/Tools.po
SOAPClients interactive on-line generic SOAP client tool:
http://www.soapclient.com/soaptest.html
MindReefs interactive on-line generic WSDL analyzer:
http://www.mindreef.net/tide/scopeit/start.do
Altovas XMLSpy:
http://www.altova.com/
How Can I Create WSDL Files?
You can create WSDL les within 4th Dimension automatically by making methods avail-
able as Web Services and setting the Published in WSDL method property.
Do I Need a WSDL File to Publish a Web Service?
No. A system can provide Web Services without providing a WSDL le. WSDL documen-
tation obviously makes the Web Service far easier for other programmers to work with. In
fact, some environments cant communicate with Web Services without a WSDL le.
Chapter 2 - Web Services: Questions and Answers
30 The 4th Dimension Web Services Companion
Do You Need a WSDL File to Subscribe to a Web Service?
No. You need to know and understand the exact input and output requirements of the
remote Web Service, but you may develop this knowledge by any means. Other forms of
documentation, or message capture and analysis are alternative approaches to learning
how a Web Service operates.
Warning Note that many development environments only communicate with Web Services that provide a
WSDL le.
Which Version of WSDL Does 4th Dimension Support?
4th Dimension supports WSDL 1.1.
HTTP
What is HTTP?
HTTP is the HyperText Transfer Protocol, commonly known as the Web.
What Version of HTTP Does 4th Dimension Support?
4th Dimension 2004 supports HTTP 1.1.
UDDI
What is UDDI?
UDDI stands for the Universal Description, Discovery, and Integration standard. UDDI is
a high-level protocol that denes an active directory system for Web Services and busi-
nesses. UDDI provides or denes 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-specic 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.
Link UDDI is managed by the OASIS standards group, found at http://www.uddi.org/.
4th Dimension Web Service Commands
4th Dimensions Web Service server commands and Web Service client commands are
completely independent. The table below identies the commands in each category:
4D 2003 The SET WEB SERVICE OPTION command requires 4th Dimension 2004 or later.
Server Client
Get SOAP info AUTHENTICATE WEB SERVICE
Is SOAP request CALL WEB SERVICE
SEND SOAP FAULT Get Web Service error info
SOAP DECLARATION GET WEB SERVICE RESULT
SET WEB SERVICE PARAMETER
SET WEB SERVICE OPTION
The 4th Dimension Web Services Companion 31
Developing Web Service Clients with 4th Dimension
Developing Web Service Clients with 4th Dimension
What Is Required to use 4th Dimension as a SOAP Client?
Everything required by the 4th Dimension SOAP client is built into 4th Dimension; all that
is needed is a physical/network connection with the target Web Service. While Web Ser-
vice servers and clients are generally on different machines, there is no reason a Web Ser-
vice client cant communicate with a Web Service server on the same machine.
What Does the Web Services Wizard Do?
The Web Service Wizard parses WSDL les from any source and automatically produces
SOAP client code. Alternatively, WSDL les can be examined without creating methods,
and methods can be created using the Wizard without analyzing a WSDL le.
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 satised 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")
SET WEB SERVICE OPTION(Web Service SOAP Header ;$xmlref)
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.
What Is a Proxy Method?
The Web Services Wizard creates what 4th Dimension calls a proxy method, like the sam-
ple shown below (line breaks added for legibility):
` Proxy_TextToUppercase
C_TEXT($1)
SET WEB SERVICE PARAMETER("inText";$1;string)
CALL WEB SERVICE("http://192.168.1.104:8080/4DSOAP/";
"Conversions#textToUppercase";
"textToUppercase";"http://www.4d.com/namespace/default";
Web Service Dynamic )
If (OK=1)
GET WEB SERVICE RESULT($0;"outText";*) ` Memory clean-up on the nal return value.
End if
Chapter 2 - Web Services: Questions and Answers
32 The 4th Dimension Web Services Companion
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:
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:
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 exible. 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 exible. DOC-style is a message-oriented format that, while more
complex to manipulate, is extremely exible. 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
Proxy Method
Method One Method Two
Web Service
SOAP S
O
A
P
Network
4th Dimension
Web Service
Method One Method Two
The 4th Dimension Web Services Companion 33
Publishing Web Services with 4th Dimension
4th Dimensions 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.
Publishing Web Services with 4th Dimension
What Is Required to Use 4th Dimension as a SOAP Server?
Out of the box, 4th Dimension databases include everything required to integrate Web
Services. 4th Dimensions Web Service publishing and client features are entirely distinct.
Therefore, no special licenses, Web server, plug-ins or other software are required to use
4th Dimension as a Web Services client. All that is needed is a live network connection
between the 4th Dimension application and the Web Service host. Publishing Web Ser-
vices, however, requires 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:
Does the 4th Dimension SOAP Server Require the 4th Dimension Web Server?
Yes. You cant use 4th Dimensions 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 les. For more information, see Organizing Web Service Methods Thematically
in the Hand-Tuning WSDL Files chapter, starting on page 314.
Style Data Types Support
RPC Simple data Automatic
RPC Complex data of array types Automatic
RPC Other complex data Automatic or custom coding required.
DOC Always complex data Automatic or custom coding required.
GET HTTP request/response Call cURL with LAUNCH EXTERNAL PROCESS.
POST HTTP request/response Call cURL with LAUNCH EXTERNAL PROCESS.
Item Web Service Server Web Service Client
Plug-ins None needed None needed
Special Licenses 4D Web Services Server License None needed
4D Web Server Required Not used
Connection between client and server Required Required
Chapter 2 - Web Services: Questions and Answers
34 The 4th Dimension Web Services Companion
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.
Do I Really Need to Read All of those Standards Documents?
No, although good reasons to read standards documents include:
Gaining a deeper understanding of the inner workings of a system or service.
Implementing a standard, or portion of a standard, directly.
Investigating error codes, headers, enumerated values, and other standards-based
values your code encounters.
Impressing your friends. (Note: If this applies, its time to diversify your circle of
friends!)
Providing you with a powerful non-prescription sleeping aid.
What is BNF?
The bulk of Internet standards youre 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 difcult to follow. Sometimes, its 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 youre reading for denitions.) Standards allow for various levels of imple-
mentation or conformance. Different programs can support the same standard more or
less completely. The specication keywords distinguish required and optional features.
The example below is drawn from section 3 of the SOAP 1.1 recommendation:
The 4th Dimension Web Services Companion 35
Standards Documents
A SOAP application SHOULD include the proper SOAP namespace on all
elements and attributes dened by SOAP in messages that it generates. A SOAP
application MUST be able to process SOAP namespaces in messages that it
receives.
Unfortunately, a few useful keywords are missing. Standards should (but never do)
include passages like the following:
The following requirement was included to satisfy a theoretical point. It will
NEVER be implemented or used in real implementations and should be
IGNORED at all times.
Its important to check books, discussion lists, and other software to determine how stan-
dards are really implemented and applied before devoting a great deal of time on imple-
mentation, or before assuming real-world implementations follow the standards. Few
standards are ever implemented completely and very few programs ever provide fully
conformant implementations.
Where Are the SOAP Standards Documents?
Where Are the XML Standards Documents?
There are literally hundreds of XML and XML related standards. Below are links to several
of the core specications:
Specication Location
SOAP standards directory http://www.w3.org/TR/soap
SOAP 1.1 http://www.w3.org/TR/2000/NOTE-SOAP-20000508/
SOAP 1.2 Part 0: Primer http://www.w3.org/TR/soap12-part0/
SOAP 1.2 Part 1: Messaging Framework http://www.w3.org/TR/soap12-part1/
SOAP 1.2 Part 2: Adjuncts http://www.w3.org/TR/soap12-part2/
SOAP Messages with Attachments http://www.w3.org/TR/SOAP-attachments
XML Schema Part 1: Structures http://www.w3.org/TR/xmlschema-1/
XML Schema Part 2: Datatypes http://www.w3.org/TR/xmlschema-2/
Specication Location
XML home page at the World Wide Web Consortiums site http://www.w3.org/XML/
XML 1.0, third edition http://www.w3.org/TR/REC-xml
XML 1.0, second edition, annotated by Tim Bray http://www.xml.com/axml/testaxml.htm
XML 1.1 recommendation http://www.w3.org/TR/xml11/
XML Schema Part 1: Structures http://www.w3.org/TR/xmlschema-1/
XML Schema Part 2: Datatypes http://www.w3.org/TR/xmlschema-2/
SOAP 1.2 Part 0: Primer http://www.w3.org/TR/soap12-part0/
SOAP 1.2 Part 1: Messaging Framework http://www.w3.org/TR/soap12-part1/
SOAP 1.2 Part 2: Adjuncts http://www.w3.org/TR/soap12-part2/
SOAP Messages with Attachments http://www.w3.org/TR/SOAP-attachments
Namespaces in XML 1.1 http://www.w3.org/TR/xml-names11/
Associating Style Sheets with XML documents Version 1.0 http://www.w3.org/TR/xml-stylesheet/
Chapter 2 - Web Services: Questions and Answers
36 The 4th Dimension Web Services Companion
Where Are the WSDL Standards Documents?
Specication Location
WSDL 1.1 http://www.w3.org/TR/wsdl
WSDL 2.0 working drafts directory http://www.w3.org/2002/ws/desc/
WSDL 2.0 Part 1: Core Language http://www.w3.org/TR/wsdl20
WSDL 2.0 Part 2: Message Exchange Patterns http://www.w3.org/TR/wsdl20-patterns
WSDL 2.0 Part 3: Bindings http://www.w3.org/TR/wsdl12-bindings
A current list of published working drafts http://www.w3.org/2002/ws/desc/

Potrebbero piacerti anche