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

zhaozj2021-02-17  55

1.1 Thin customer connection

Thin customers (such as web browsers or wireless browsers) represent people who are interested in viewing web pages. Network services should perform any necessary processing required for web requests, such as executing B2C transmission and displaying a order confirmation page.

To achieve this, developers write dynamic web pages with JavaServer Page (JSP) technology. The JSP component is a dynamic page technology that can be based on the back-end data processing results (usually HTML and XML). They operate in a manageable environment of a container, which provides services that JSP components need, such as explaining them to perform code.

The JSP component acts as a front end "presentation" interface that enters the backend business logic layer, which may be implemented in a variety of different methods (eg EJB, ordinary Java objects, or ordinary javabeans). They then produce results, typically HTML or XHTML (an XML-compatible HTML version).

The JSP component represents a user interactive interface instead of a program interface that can be called by another system. For example, an stock quotation service may be used by a network service of a technical stock quotation average. The same backend stock quotation service may return to end user stock quotes with JSP technology.

Figure 5 shows the role of the JSP component.

Figure 5 JSP component responding to a network request

It is noted that the method of using JSP components in the context is descriptive but not illustrative. Developers may also use Java Servlets to produce the same results.

1.2 fat customers

Customers connected to network services are called fertilizer customers. For example, under a company's internal LAN topology, such as downloads, security and heterogeneous technology are not very important. The responsiveness and function of the user interface may be more important, especially when the application is based on a commonly used basis, such as the internal call center application.

A fertilizer customer can connect network services in a different way. For example, it can use techniques such as UDDI, WSDL, SOAP, and EBXML. This example is the minimum efficiency, because both the client and the server are developed by the same development group, which does not need to transmit and process.

A more efficient method is to use a more efficient protocol such as RMI-IIOP (Java Remote Method Invocation over the Internet Inter-ORB Protocol). OMG IIOP is a standard protocol for communication between EJB components. Fertilizers can use this to directly connect the EJB layer.

2 implement network services

So far, we have talked about how our network services connect various types of clients. Next, let's see how to implement the interior of network services.

2.1 Data Interpretation and Transmission (Data Translation and Transform)

Before entering a network service, the difficulty we need to overcome is to create an interface layer to explain the received XML data as a format that can be processed by our network service, then interpret the result to the client. A developer therefore requires a robust mechanism to parse XML, bind them to Java objects, generate XML, and convert various XML formats. Sometimes, because our application supports different interfaces, such as from the B2B partner SOAP, HTML from the web browser, WML from the wireless browser requires the same set of services, we need different programs to provide different customers. The service interface is to handle different semantics associated with different client environments.

2.1.1 JAXP

Java API for XML Process is a Java XML parsed industrial standard API. It has SAX (Simple API for XML) and DOM (Document Object Model), as well as a mountful XSLT (XML Stylesheet Language Transform) engine interface. These formation of parsing and processing XML documents. When these APIs are somewhat original for network services, they represent the best software that is currently issued. JAXP provides access, modify, and establish an API of all the features in Java, which is the most basic API in our network service interface. For details, please see:

http://java.sun.com/xml/tutorial_intro.htmlhttp://java.sun.com/xml/xml_jaxp.html

2.1.2 JAXB

Java API for XML Binding is a specification that will be converted to each other of XML documents and Java objects. Using JAXB, you can automatically convert the XML document as Java object with the background EJB layer. You can also get objects from the EJB layer and convert to XML, which can be returned to business partners.

The JAXB interface provides methods for processing XML documents than DOM and SAX high-level. This specification allows the interlocation of XML Schema and Java classes to provide a simple way to convert an XML document as a Java object instance or in turn. This is also much easier than a tag over a time.

2.1.3 XSLT

The XML document from the business partner may be used for the corresponding internal use frame (Schema). For example, a business partner may use the term "ordernum", and we use "ORDERID".

Instead, we often need to express a return result into a different format according to different customers issuing a request. For example, a call of a business partner may require a return result in the form of SOAP, and the browser user needs the results of XHTML. In more complex situations, we need to support more formats, such as WML required by wireless devices, sound response systems required for VoiceXML. This requires that we have a mechanism to convert basic XML responses to different XML formats to provide different interfaces for this system.

XML Stylesheet Language Transformations (XSLT) is a mechanism that converts the converted XML document from one Schema to another. A Stylesheet specifies a range of pattern matching rules and is used to recurrent a tree traversal similar to the DOM sample. A XSLT style expression syntax is rich in expression, including complete loops, conditions, mathematical computing commands, and the structure and scope of similar functions, and recursive definitions.

2.1.4 Shared context

When two merchants start a thing, there must be a associated context (context). This context can appear in the form of a special agreement (such as discount rules, preferential price rules) or in the form of business rules that apply only to specific partners, which will cause different partners' things. Moreover, a business cooperation may include multiple calls in a short period of time. Each call may be tied to a shared context that requires across the lifecycle of the entire collaborative instance.

In a J2EE network service, it is recommended to use the discrete location to store the above. As a developer, you should consider the complex network service requires context and plans to put it in your architecture. Discrete components. Now, context processing can be implemented by manually using JDBC (Java Database Connectivity). However, the future context API is also planned, which may make the contextual requirements of the network service system. Context data can be accessed by any component, such as servlet, JSP, or EJB components. 2.1.5 Business Layer

Once the received XML data is interpreted as a Java object, the data is ready for the EJB business layer processing. EJB technology is the standard for creating business components in Java. With EJB components, you can get backend services from your container, such as secure, things, permanent, connect pools, load balancing, and error repair services.

There are three EJB components in the EJB 2.0 standard:

Translator Note: These definitions are already old (relatively), please see the original text in order to keep integrity:

Session Beans perform work on behalf of clients (they are verbs). Session beans are generally short-lived and perform fairly quick actions, such as trading a stock, submitting a purchase order, or calculating taxes on a transaction.

Entity Beans represent business data (they are nouns) They are generally long lived and map to an underlying storage, such as an RDBMS or OODBMS system There are two subtypes of entity beans:.. Bean-managed persistent (where you write the persistence logic And Container-Managed Persistent (WHERE THE Container Genereates The Persistence Logic for you). Some Examples of Entity Beans include Stocks, Orders, Customers, Employees, And Acounts.

MessageDriven Beans are message-oriented components. They receive messages using message-oriented middleware, such as IBM MQSeries or TIBCO Rendezvous. Messages can also be sent from Java clients using the Java Message Service (JMS) standard. When a message arrives for a message -Driven bean, IT IS Similarly Accessed Using The JMS API. Examples of Message-Driven Beans Include A Logging Service, A Stock Trading Service, or an ORDER Submission Service.

Typically, the session beans calls Entity Beans to get the required action. For example, a price engine for calculating the order price is a session beans, which is used in one or more products and ordering Entity Beans. Message Drive Beans Receive Messages and Routing Messages to Session Beans or Entity Beans. Figure 6 is an example of an EJB component interaction

Figure 6 EJB business layer

We use the Java Naming and Directory Interface (JNDI) API to find and destroy the EJB components. This API is typically used to access external resources of many types of J2EE platforms, including database engines, intermediate-oriented middleware engines, or EJB component factories.

EJB details, you can see:

Http://java.sun.com/products/ejb/white/white_paper.html

Http://java.sun.com/products/ejb/

http://www.theserverside.com/

"Mastering Enterprise Javabeans" by Ed Roman, Published by John Wiley & Sons.

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

New Post(0)