Use J2EE to establish XML-based network services (2)

zhaozj2021-02-17  50

1 client connection

The client's connection refers to how the customer accesses your network service. Table 1 shows three main customer types connected to network services.

Table 1 Customer connection method

Customer type

Example

This kind of customer connection method

Business Partners

Sponsor (DISTRIBUTORS), Salers, Large Customers

XML-based network service technology (SOAP, UDDI, WSDL, EBXML)

Thin Clients

Browser, PDA, wireless device

Lightweight, Lightweight Protocol, such as HTTP

THICK Clients

Applets, application, existing system

Weavy, complex protocol (Heavyweight Protocol) such as IIOP.

1.1 Business partner connection

Business partners can get special web services. Business partners can connect with different programming languages, middleware, and hardware. Therefore, when a business partner accesses your system, the network service request appears in XML. XML is a standard meta-marker language (META-MARKUP LANGUAGE) can be used for commercial data and allowing heterogeneous systems to interact.

1.1.1 java servlets

When a business partner issues a network service request, receive the XML document is Java servlets. A servlets is a Java object based on request / response that runs in a manageable container environment. It can respond to requests that use any protocol (such as HTTP, FTP, or POP). In this case, servlets is used to respond to the HTTP request, because network services use HTTP services to make communication across firewalls possible.

When a request enters a J2EE network service system, there is an ordered operation as shown in FIG. 2.

Java servlet gets an XML document

XML-based request obtained by servlet processing

Then, servlet calls one or more Enterprise JavaBeans (EJB) components to complete business data processing

The function of the external system may call the external system when the EJB component is processed.

EJB component returns data to servlet

Then, the servlet conversion return value is an XML document.

Servlet returns XML to your client as an answer

Figure 2: Request for a business partner

1.1.2 UDDI

Before the business partner is able to start a business network service call, it must first find where the business service is available, discovers the interface and semantics of the call to start configuring software and services in their end. Therefore, we need tools to publish our services.

UDDI (Universal Description, Discovery, and Integration) is a very important new project that is used for web services providing and search. The UDDI project provides a service called UBR (UDDI Business Registry), which is a global transaction and service public directory. Network service providers can register and describe their services with UBR. Users can query UBR to discover network services and obtain information with service interoperability.

UDDI provides a mechanism for the description document for a guideline system to find a specific service. UDDI includes standard "White pages" types search and "Yellow Pages" type topics search, also have "Green Pages" type of service type searches. "Green Page" search. Enables developers to find all services in a service type.

UDDI uses SOAP messages (typical forms to XML / HTTP) to publish, edit, browse, and find information in registry. It also includes XML Schema to encapsulate registry services (Registry Service) to send or return different types of data. 1.1.3 JAXR

In order to support the implementation of the UDDI function on the Java platform, Java APIS for XML Registries (JAXR) is an API specification that will be developers to be developed to access the registry. It is worth noting that JAXR is not currently necessary, and you can still use more common XML APIs to interact with protocols. JAXR is a Java API that provides a variety of publishing, query, and editing registry supporting. It focuses primary focus on network services for B2B applications, and provides complex content queries and publish / subscribes to XML messages. It can also be used to access other types of registry, such as EBXML REGISTRY (later we will talk).

1.1.4 WSDL

In order to let the merchant find the service it wants, the syntax and semantics of the network service call need to be determined before the call. The WSDL (Web Services Description Language) specification is an XML document describing network service interface, semantic, and daily repetitive work (Interface, Semantics, And Adminicia). It allows simple services to be quickly and easy to describe and archive.

Here is a WSDL definition:

TargetNamespace = "http://example.com/stock quote.wsdl"

XMLns: TNS = "http://example.com/stockquote.wsdl"

XMLns: xsd1 = "http://example.com/stock quote.xsd"

XMLns: soap = "http://schemas.xmlsoap.org/wsdl/soap/"

XMLns = "http://schemas.xmlsoap.org/wsdl/">

XMLns = "http://www.w3.org/2000/10/xmlschema">

TYPE = "TNS: stockquoteporttype">

Transport = "http://schemas.xmlsoap.org/soap/http" />

SOAPACTION = "http://example.com/getlasttradeprice" />

My First Service

It includes the following key information:

l The description / format of a message. It can be passed in and elements (by means of embedded XML Schema definition).

l Semantics in the message transfer in the element. (For example: only request, request - answer, just answer)

l Specific encoding in element (encoded on a particular transport protocol such as HTTP, HTTPS, or SMTP).

l The server address (a URL) in the element. WSDL is usually referred to as a technical interface for a description interface. Although UDDI is the most commonly used and is recommended for registration of WSDL specifications, the UDDI specification is not limited to which format will be linked to its registry. It may be WSDL, and the regular man-oriented document is even just a Email address that gets information.

In Java Community Process (JCP), the Java API for WSDL (JWSDL) specification is underway. When it is published, the API will be provided to process the WSDL document instead of processing the XML document directly. When you can use JAXP's function, you can use JWSDL easier and fast, which simplifies developers' work.

Figure 3 shows WSDL and UDDI

Figure 3 Using JAXR, UDDI and WSDL

转载请注明原文地址:https://www.9cbs.com/read-30472.html

New Post(0)