Online documentation - Websydian v6.0 |
Users Guide | Patterns Reference | WebsydianExpress | Search |
Introduction Implementing Other Uses Parts Tutorial Glossary
In the following a number of new terms are used. See the Glossary section for a definition of the terms.
This tutorial is divided into two sections, the first covering the implementation of the Publisher application, and the second the implementation of the Subscriber application. See the figure below.
The tutorial implements both sides of a Web Service1).
In this tutorial, the Web Service Publisher is a distributor of goods, while the Web Service Subscriber is a broker collecting information from different distributors for the benefit of the user (find nearest outlet, shortest delivery time, lowest price, etc.). The Broker processes the returned information and presents the results to the user of the Broker service.
Standard Web Approach | Use of Broker with Web Services |
---|---|
The user goes to the web sites of each of the distributors. |
The user goes to the web site of a Broker that collects information from a number of distributors. |
In the standard web approach interaction between the user and the distributors is browser based.
In the Web Service approach interaction between the user and the distributors is a mix of browser based communication (between the user and the Broker) and Web Services (between the Broker and the distributors). In other words, a layer of Web Service communication is inserted between the user and the distributors - but without the user needing to change browsing habits or even know about Web Services.
In this example, the communication between the Broker and a single Distributor is implemented. The Broker and Distributor interact using Web Services, where the Distributor acts as the Publisher, while the Broker acts as the Subscriber to Web Service.
Two Web Service functions will be implemented for the Distributor. The first Web Service function will return a list of all available items in the distributor database. This Web Service function will henceforth be referred to as the ReturnAll Web Service.
The second Web Service function will return a more detailed information on specific items specified by the Broker. This Web Service function will be referred to as the ReturnSpecific Web Service.
The Broker calls the ReturnAll Web Service. The returned list of items are then imported into the Broker database. When the customer who uses the Broker service has decided on which items information is wanted, the Broker calls the ReturnSpecific Web Service and subsequently processes the returned data for the customer.
The Broker and the Distributor exchange data using XML documents and Web Services. The import and export functionality used to implement this Web Service example are described in details in the TransacXML implementing section.
The import and export functionality between XML and database is implemented in a 'Web Service unaware' fashion, i.e. the import/export functions can be used both within a Web Service context and as standalone functions.
The import/export functions are implemented in the TransacXML Tutorial, so please make sure that the TransacXML Tutorial has been completed.
The Broker only interacts with one distributor, and the retrieved data is stored in the Broker database without further processing.
In this tutorial the Broker and the Distributor are implemented in the same Plex model - this is of course different from real world applications, where the Subscriber and Publisher will be located in disparate systems.
The interaction between Broker and Distributor is strictly limited to Web Service dialogs - as it would be, if they were placed in disparate systems. Of course the Broker and Distributor could interact directly (as they do in the TransacXML Tutorial), but that would violate the the purpose of the present guide: demonstration of how to implement Web Service with Plex and Websydian.
In the figure below, the export from the Distributor database to an XML document with subsequent import into the Broker database is shown as it occurs in the TransacXML implementation guide. How the XML document resulting from the first step is made available to the import in the second step is not described; it could be stored on a removable media, emailed, or copied via the Internet - the agents involved in the operation of copying data from Distributor to Broker are responsible for the transfer of the XML document.
Using simple TransacXML functionality, exchange of data between disparate systems is a two step procedure, where the XML document being used as information carrier must somehow be transferred from one system to the other.
In the next figure, export from the Distributor database to the Broker database using Web Services is shown. Notice that the Web Service through the SOAP functions handles both the transfer of the XML document and the invocation of the remote functionality - in this example it is the Broker who requests the Distributor to export data and return the XML document through the Web Service.
Using Web Service functionality, exchange of data between disparate systems is a one-step procedure (taking place at two locations), where the Broker initiates the process, and the Distributor answers with an XML document containing the requested information (wrapped in a SOAP Envelope).
A different scenario is also very likely, in which the Distributor "pushes" information onto the Broker. In that case the Distributor and Broker trade places as Subscriber and Publisher.
This tutorial is based on the model described in the TransacXML Tutorial. In order to follow this implementation guide, it is necessary to complete the TransacXML Tutorial.
A copy of the model - with all functionality implemented as described in this implementation guide - can be downloaded here.
When doing WebServices it is recommended adding a namespace to the XML documents used by the WebService. This enables the developer
to create well formed WSDL files.
Add the following triples to the model.
Source Object | Verb | Target Object | Comments |
---|---|---|---|
CommonXML.ReturnOffer | is a ENT | NameSpaceAware | |
CommonXML.ItemList | is a ENT | NameSpaceAware |
Add information to the source codes specifying the namespace and prefix
CommonXML.ReturnOffer.Namespace
http://www.websydian.com/webservicedemo
CommonXML.ReturnOffer.Prefix
wsdemo
CommonXML.ItemList.Namespace
http://www.websydian.com/webservicedemo
CommonXML.ItemList.Prefix
wsdemo
The Distributor implements two Web Service functions; ReturnAll, and ReturnSpecific.
The base entity for the Publisher is the HttpSoap entity.
Source Object | Verb | Target Object | Comments |
---|---|---|---|
DistributorA | is a ENT | HttpSoap |
The core functions in the HttpSoap entity are the SoapGenerator and SoapProcessor. The SoapGenerator is used by a Subscriber to communicate with a web service, whereas the SoapProcessor is used by a Publisher to implement a web service.
The Distributor acts only as Publisher and does not make use of the SoapGenerator function, which should not be generated.
Source Object | Verb | Target Object | Comments |
---|---|---|---|
DistributorA.Services.SoapProcessor | impl name NME | SOAPDisA | |
file name NME | SOAPDisA | ||
DistributorA.Services.SoapGenerator | implement SYS | NO |
Create the directory c:\temp\SoapProcessor (this is where the SoapProcessor function stores temporary files).
Create an executable file wrapper for the SoapProcessor function.
Open the SOAPDisA.ini file and add the following lines:
[TransacXML]
MAX_CONTENT_LENGTH=10240
TEMPORARY_FILES=c:\temp\SoapProcessor\
The MAX_CONTENT_LENGTH parameter is used to limit the size of accepted Web Service requests, and the TEMPORARY_FILES
parameter is used to specify where the SoapProcessor should place temporary files.
The Distributor exports from the database into XML documents both when responding to ReturnAll and ReturnSpecific Web Service requests.
An XmlHandler function is used to implement a web service function. In this tutorial the Distributor implements two XmlHandlers: One for the ReturnAll web service function and one for the ReturnSpecific web service function.
Specify triples to define the XMLHandler function ReturnList:
Source Object | Verb | Target Object | Comments |
---|---|---|---|
DistributorA.Services | includes FNC | XMLHandlers | |
DistributorA.Services.XMLHandlers | includes FNC | ReturnList | |
DistributorA.Services.XMLHandlers.ReturnList | is a FNC | DistributorA.Abstract.XMLHandler DomServerExternal |
|
impl name NME | ReturnList | ||
file name NME | RetList | ||
implement SYS | Yes |
Open the action diagram for ReturnList and specify the following code in the Edit Point XmlHandler functionality:
Edit Point XmlHandler functionality
Call ExportItemListToXML
// Map OutputDocument<BodyOutObjectStoreReference>
// Map OutputDocument<BodyOutDocument>
Call Meta.CheckCall
Specify the XMLHandler function ReturnOffer:
Source Object | Verb | Target Object |
---|---|---|
DistributorA.Services.XMLHandlers.ReturnOffer | is a FNC | DistributorA.Abstract.XMLHandler DomServerExternal |
impl name | CalculateOffer | |
file name | CalcOff | |
implement SYS | Yes |
Open the action diagram for ReturnOffer and specify the following code in the Edit Point XmlHandler functionality
Edit Point XmlHandler functionality
Call ExportToReturnOffer
// Map InputDocument<BodyInObjectStoreReference>
// Map InputDocument<BodyInDocument>
// Map OutputDocument<BodyOutObjectStoreReference>
// Map OutputDocument<BodyOutDocument>
Specify the XmlHandler functions in the SoapProcessor:
Source Object | Verb | Target Object |
---|---|---|
DistributorA.Services.SoapProcessor | comprises FNC | DistributorA.Services.XMLHandlers.ReturnList DistributorA.Services.XMLHandlers.ReturnOffer |
The SoapProcessor now knows two XmlHandler functions, and will - upon Web Service requests - be able to direct the requests to the corresponding XmlHandler functions.
The Broker imports from the returned XML data into the database both when calling the ReturnAll Web Service and the ReturnSpecific Web Service.
When calling the ReturnSpecific Web Service the Broker exports from the Broker database to an XML document which is passed to the SoapGenerator as the payload of the ReturnSpecific Web Service request.
The base entitiy for the Subscriber is the SOAP entity.
Specify Broker inheritance:
Source Object | Verb | Target Object |
---|---|---|
Broker | is a ENT | HttpSoap |
Broker.Services.SoapGenerator | impl name NME | SGBroker |
file name NME | SGBroker | |
Broker.Services.SoapProcessor | implement SYS | No |
The Broker acts as Subscriber only, and does not make use of the SoapProcessor function.
The Broker (Subscriber) requests the Distributor to return a list of items. To make such a request it is necessary to call the Distributor
(Publisher) Web Service with the correct parameters.
Specify a function, WSItemListExchange, which acts as a wrapper function for the Broker SoapGenerator function:
Source Object | Verb | Target Object | Comments |
---|---|---|---|
WSItemListExchange | is a FNC | ExportXMLDocument ImportXMLDocument |
|
input FLD ...for VAR |
WSYHTTP/InternetServerName Connection |
||
input FLD ...for VAR |
WSYHTTP/InternetServerPort Connection |
||
input FLD ...for VAR |
WSYHTTP/InternetApplicationName Connection |
||
input FLD ...for VAR |
WSYHTTP/InternetUrl Connection |
||
input FLD ...for VAR |
SOAPAction Connection |
||
file name NME | WSIList | ||
impl name NME | WSIList | ||
name NME | WSList |
The WSItemListExchange function first calls the Broker SoapGenerator, then imports the returned data into the Broker database.
Open the action diagram of the WSItemListExchange function and add the following code in the specified edit points:
Edit Point Process XML document
Call Broker.Services.SoapGenerator
// Map Local/InputDocument<ObjectDocument>
// Map Local/InputDocument<ObjectStoreReference>
// Map Local/OutputDocument<ObjectDocument>
// Map Local/OutputDocument<ObjectStoreReference>
// Map Connection<SOAPAction>
// Map Connection<InternetServerName>
// Map Connection<InternetServerPort>
// Map Connection<InternetApplicationName>
// Map Connection<InternetUrl>
// Map <CharSet.utf-8>
// Map <UseSSL.*No>
Go Sub Check error
If NOT Environment<*Returned status> IS <State: OBJECTS/*Returned status.*Abnormal>
Call ImportItemListFromXML
// Map Local/OutputDocument<ObjectStoreReference>
// Map Local/OutputDocument<ObjectDocument>
Go Sub Check error
else
Go Sub Check error
Pre Point Handle error message
Dialog Message Message: OBJECTS/Message
// Map Environment<*Message text>
The Broker requests the Distributor to return a list of specific items, based on a supplied XML document. This functionality is exactly the same as in WSItemListExchange, except that the Web Service in this case needs an XML document as input (containing the items for which an offer is requested).
Specify the function, WSReturnOfferExchange
Source Object | Verb | Target Object | Comments |
---|---|---|---|
WSReturnOfferExchange | is a FNC | ExportXMLDocument ImportXMLDocument |
|
input FLD ...for VAR |
WSYHTTP/InternetServerName Connection |
||
input FLD ...for VAR |
WSYHTTP/InternetServerPort Connection |
||
input FLD ...for VAR |
WSYHTTP/InternetApplicationName Connection |
||
input FLD ...for VAR |
WSYHTTP/InternetUrl Connection |
||
input FLD ...for VAR |
SOAPAction Connection |
||
file name NME | WSOffer | ||
impl name NME | WSOffer | ||
name NME | WSOffer |
Open the action diagram for WsReturnOfferExchange and add the following code in the specified edit points:
Edit Point Process XML document
Call Broker.Services.SoapGenerator
// Map Local/InputDocument<ObjectDocument>
// Map Local/InputDocument<ObjectStoreReference>
// Map Local/OutputDocument<ObjectDocument>
// Map Local/OutputDocument<ObjectStoreReference>
// Map Connection<SOAPAction>
// Map Connection<InternetServerName>
// Map Connection<InternetServerPort>
// Map Connection<InternetApplicationName>
// Map Connection<InternetUrl>
// Map <CharSet.utf-8>
// Map <UseSSL.*No>
If NOT Environment<*Returned status> IS <State: OBJECTS/*Returned status.*Abnormal>
Call ImportReturnOfferFromXML
// Map Local/OutputDocument<ObjectStoreReference>
// Map Local/OutputDocument<ObjectDocument>
Go Sub Check error
else
Go Sub Check error
Pre Point Handle error message
Dialog Message Message: OBJECTS/Message
// Map Environment<*Message text>
To test the functions, it is necessary to setup the Web Server, and generate and build the functions used.
First it is necessary to create a test wrapper function for WSItemListExchange and WSReturnOfferExchange, respectively.
Specify the function TestWSItemListExchange:
Source Object | Verb | Target Object | Comments |
---|---|---|---|
TestWSItemListExchange | is a FNC | FunctionShell ClientExternal |
|
message MSG | InternetUrl | ||
message MSG | SOAPAction | ||
local FLD | SOAPAction WSYHTTP/InternetUrl |
Specify the contents of the InternetUrl message to Distributor/SoapDisA.EXE
Specify the contents of the SOAPAction message to ReturnList
Insert the following action diagram code into the TestWSItemListExchange function:
Edit Point Execute
Format Message Message: TestWSItemListExchange.InternetUrl, local<interneturl>
Format Message Message: TestWSItemListExchange.SoapAction, Local<SOAPAction>
Call WSItemListExchange
// Map <FileName.*Blank>
// Map <version.*Blank>
// Map <Encoding.*Blank>
// Map <FileName.*Blank>
// Map <InternetServerName.localhost>
// Map <InternetServerPort.HTTP>
// Map <InternetApplicationName.*Blank>
// Map Local<InternetUrl>
// Map Local<SOAPAction>
Go Sub Terminate
Specify the function TestWSReturnOffer:
Source Object | Verb | Target Object | Comments |
---|---|---|---|
TestWSReturnOffer | is a FNC | FunctionShell ClientExternal |
|
message MSG | InternetUrl | ||
SOAPAction | |||
InputDocument | |||
local FLD | SOAPAction WSYHTTP/InternetUrl BodyFile |
Specify the contents of the InternetUrl message to Distributor/SoapDisA.EXE
Specify the contents of the SOAPAction message to CalculateOffer
Specify the contents of the InputDocument message to c:\temp\Request.xml
Insert the following action diagram code into the TestWSReturnOffer function:
If you are implementing a Java version of the Soap Generator, we have found that in some cases you have to add a / to the start of the InternetUrl - so the content becomes: /Distributor/SoapDisA.EXE.
Edit Point Execute
Format Message Message: TestWSReturnOffer.InternetUrl, Local<InternetUrl>
Format Message Message: TestWSReturnOffer.SoapAction, Local<SOAPAction>
Format Message Message: TestWSReturnOffer.InputDocument, Local<BodyFile>
Call WSReturnOfferExchange
// Map <FileName.*Blank>
// Map <version.*Blank>
// Map <Encoding.*Blank>
// Map Local<BodyFile>
// Map <InternetServerName.localhost>
// Map <InternetServerPort.HTTP>
// Map <InternetApplicationName.*Blank>
// Map Local<InternetUrl>
// Map Local<SOAPAction>
Go Sub Terminate
Generate and build each function implemented in this implementation guide:
Create executable wrappers for the functions TestWSReturnOffer and TestWSItemListExchange.
Add the following information to the ini files for the functions
[TransacXML]
TEMPORARY_FILES=c:\temp\SoapGenerator\
To make the Distributor Web Services available for the Broker, it is necessary to setup a web server. Please consult the appropriate section of the Websydian documentation for details on how to do this.
Run the functions TestWSItemListExchange and TestWSReturnOffer.
As a result of running TestWSItemListExchange the database Data.All Items now holds the entire inventory from Distributor A.
As a result of running TestWSReturnOffer the database Data..Returned Items now holds the requested items specified in the input XML document, but with more details (price and delivery time).
1) Websydian supports the following Web Service standards:
SOAP v1.1 is supported in the following configurations: | |||
Literal Document Style, Publicer | Literal Document Style, Subscriber | Literal RPC Style, Publisher | Literal RPC Style, Subscriber |
Natively supported by Websydian in Java and WinC. | Natively supported by Websydian in Java and WinC. | Requires XML/Websydian specialist. Contact support@websydian.com for more information. Platforms supported: Java and WinC. | Natively supported by Plex with EJB option in J2EE. |
Encoded messages not currently supported:
WSDL v1.1. is supported in the following configurations: | |
Export | Import |
Java, WinC | Manual |