Application Interoperability: Point-to-point

xiaoxiao2021-03-06  41

Release Date: 09/15/2004

| Update Date: 09/15/2004

Microsoft Corporation

Summary: Total to introduce a point-to-point communication method for XML Web services and .NET remote processing. The subject includes binary communication and routing, and the use of third partial running bridges that integrate Java and .NET content.

This page

Use .NET remote processing to connect to the Runtime Bridge Connection Web Services Summary Reference

Designing an effective interoperability solution requires a technical technology to connect to the Java and .NET Framework system. This chapter introduces a method of connecting two platforms that can be used in the scenario of point-to-point, such an application can synchronize another application.

This technology that makes .NET Framework and Java interacts on the basis of point-to-point:

• .NET Remote Processing • XML Web Services

.NET remote processing is the first technology described, which provides many advantages in a purely .NET Framework environment, such as better performance and simple implementation methods. However, Java applications cannot be directly connected to .NET remote processing, they need to use runtime bridge implementation. This chapter is to study two most popular runtime bridge products, Ja.NET and JNBRIDGEPRO.

As long as developers and system architects begin to discuss interoperability, web services will become more and more popular. Web services exist everywhere and guarantees that it is not necessary to describe the method, but they are not always the best interoperability solutions.

Use .NET remote processing to connect

In Chapter 2, "Understanding Enterprise Platform", you learned that .NET remote processing is a communication and data transfer mechanism for Microsoft based .NET Framework. Although .NET remote processing is mainly designed to communicate between .NET Framework applications, it provides an extensible communication framework that you can customize it based on it to support Java applications. Connection.

To use the .NET remote processing, you must implement a running-hour bridge, and you can see these two runtime bridges in this chapter you can see these two runtime bridges, Ja.Net from Intrinsyc and from from INTRINSYC Jnbridge, Inc. JNBridgePro. Before you study the running time, you need to have a solid understanding of .NET remote processing.

Understanding .NET remote processing

Fundamentally, .NET remote processing makes two processes in the same or different application domains communicate with each other in the client-server. In general, server components are a remote object.

.NET Remote Processing Communicates inter-process communication by using a remote object with a specific client, a server application domain, or a particular communication mechanism. Therefore, .NET remote processing is flexible and convenient to customize.

This abstraction is achieved by using the following two main concepts:

• The channel channel is transferred between the remote components. The default channel is TCP and HTTP. • Formatting Program Format The program converts object conversion (serialization) as a common format that can be understood by other processes (or platforms for interoperability). The default format program is binary and soap.

Note this chapter will discuss SOAP later.

In Chapter 3, "The Basic Principle of Interoperability", you understand binary sequence and XML serialization. The binary formatting program performs binary serialization of data objects, and the SOPA formatter performs XML serialization for data objects. However, SOAP formatting procedures are packaged for serialized XML documents with additional XML tags associated with SOAP.

By specifying channels and formatting programs, you can define how to establish communications between a remote object and its clients. The channel specifies the communication protocol. The formatting program then acts as serialization, serialization, and deserialized data objects transmitted between remote objects and clients. Customize these channels and formatting programs is to let you use .NET remote processing to implement connections between .NET Framework applications and Java applications. .NET remote processing not only provides communication between processes, you can also use it to connect two or more application components in different application domains. To do this, change the configuration of the .NET remote processing when you exchange data between separate applications. This provides flexibility to build applications that are running on a single computer, and can be extended to be run in a distributed environment with minimal code adjustment.

.NET remote processing also supports two methods of transmitting data between application components. They are:

• Press value (PBV) • Press to reference (PBR)

Press value transfer involves returning data from remote system call to the client. Pass by reference to the pointer or reference to the data and the remote server hold the data.

These two methods have advantages and disadvantages. The way you choose depends on the type of application you are developing, and the data and applications you want to pass must be run in the network environment.

When switching large data objects or in a distributed system in which communication is delivered slower in the network lag time, performance can be provided in accordance with the reference delivery. However, if you deliver a data object by reference, you will remotely call the data objects that are referenced on the server each time the client access to the other field.

For example: If you pass a CustData's CustomerData object to the client by reference, each client accesses a field, for example: CustData.Name or CustData.Address, the server is a remote call. This may generate a tightly coupled and cumbersome app.

Note In a service-oriented application, the loose coupling between the application components is more ideal, so you should use the value transfer.

Realize .NET remote processing

In a typical .NET remote processing implementation of two components direct communication, it consists of the following components:

• A remote application object or server component • A host application that listens to the client to the remote application component request. • A client application component that issues a request to the remote application component.

Figure 4.1 illustrates an example of a .NET remote processing frame connection between the client and the server.

Figure 4.1: A typical .NET remote processing implementation

Implementation .NET remote processing includes the following stages:

• Determine the host application or environment. • Create server components. • Create a client. • Edit the configuration file.

The following sections provide an overview of the steps that implement .NET remote processing. For more information on .NET remote processing, see the reference section at the end of this chapter. See Chapter 7 to 9 for encoding examples in the Xbike sample application.

Determine host applications or environments

The .NET remote processing server component needs to host the host in an application domain to listen to the incoming request of the object. Host a remote processing server component You have four options:

• ASP.NET • Component Services (COM ) on IIS • A Windows System Services • A Windows Application (Based on Console or Windows Forms)

You can use the .NET remote processing object as a host as the ASP.NET component running on IIS. This brings a lot of benefits, including built-in support for security and scalability. With these configurations, you can use binary or SOAP formatting programs, but you can only use HTTP channels, it is slower than TCP.

You can use the remote processing object in the component service as a host as a COM service component on Windows XP Professional SP1 or WinODWS Server 2003. This configuration provides corporate functions of component services, such as integrated security, transaction, pilot, and activation. You can remotely process objects in any hosting Windows service. In a Windows service, a remote processing object provides flexibility to use the selected channel or formatting program configuration, including the highest efficiency binary execution combination on TCP. However, .NET remote processing does not have a built-in security model. Therefore, if you want to host a remote object in a Windows service, you need to build your own authentication and authorization mechanism.

Finally, you can host a remote processing server component in a Windows application. However, the application runs in the context of the login user, so it is necessary to be executed after the user is logged in. They run in the user's security context, which may not suit your environment. Host a remote server component in a Windows service will be better.

Note When a Windows service or some other application type is in a Windows Form Application, you should specify the port. For non-ASP.NET hosts, remote processing can monitor any ports that are not used.

Usually, because IIS provides security and performance benefits, you should use it to host remote processing objects. For more information on host a remote object in IIS, see the reference section at the end of this chapter. For examples of using JA.NET and .NET remote processing in Xbikes sample applications, see Chapter 7 and 8.

Create server components

The server component is the service provider, providing the client application to send and receive data by reference to the method or client to send and receive data by reference. To pass the .NET remote processing, the server component class needs to inherit from the MarshalByrefObject class. Any data passed by the server component via value must be serialized.

Create client components

In order to enable .NET remote processing on the client, you don't have to implement any additional interfaces. However, the client must have a reference to server components or interfaces. The client uses this reference to query any method or data type disclosed by the server component. The client also needs to load remote processing configurations, which can be loaded from one profile from its own code.

Edit profile

The following .NET remote processing items need to be configured:

• Quote for remote systems • Channel • Format

You can also store these settings in your application code or you can access settings in a configuration file at runtime to configure all of these items. It is recommended that you store your configuration settings in a configuration file so you can change them without recompiling applications. In the finished system, this method provides more flexibility, allowing you to change the settings without recompiling and deploying applications.

In the .NET remote processing scheme, both client components and server components must access configuration information. If you store configuration settings in a file, the contents and locations of these files are different for the client and server side.

The .NET remote processing profile is a text file that XML formatted. You can edit these configurations in a Notepad or your selected text editor.

Server component configuration

On the server side, you must register all the remote objects before you can access them on the client .NET remote processing environment. During this registration process, you must provide all the information required to activate and manage the life cycle of this object. Net Remote Processing Framework. The most important information required for registration is:

• Object Type • Object Location (URL) • Activation Requirements for Managing Object Life Cycles • Channels for Connection Objects

The location of the server remote processing profile depends on the host application you are using. E.g:

• For IIS host applications, you store remote processing configurations in web.config files in the virtual root of the application. • For component service host applications, the remote processing configuration will be stored in a file called dllhost.exe.config in the / system32 directory. This is because server components DLLHOST.EXE run as part of the COM process. • For a Windows service, remote processing configuration information is in the application configuration file of the Windows service. For example, if the Windows service is named myService.exe, the remote processing configuration is in the file myservice.exe.config. Client component configuration

The client must also add the same configuration setting as the server. You store client configuration settings in the named file you created, such as files named remoting.config. The client application is loaded with the configuration file name as a parameter call. The location of the Remoting.config file depends on the application type to which the client component belongs. E.g:

• For ASP.NET-based clients, the Remoting.config file is in the virtual root directory of the application. These configuration settings must be loaded in the Application_Start method of the global.asax file. • For the COM service component client, the remote.config file is located in the / system32 directory. • For any other client, the remoting.config file should be placed in the same directory with the client executable file.

Now you understand the basic principles of .NET remote processing, the next chapter will tell how to connect the Java application with this technology.

Back to top

Implementation time

Some vendors use .NET remote processing as a basic connection protocol to implement interoperability between .NET Framework applications and Java applications. Running the West Bridge Objects to some extent, allowing you to use .NET remote processing to process them, and vice versa. The two major products under this category are Ja.NET from Intrinsyc and JNBridgePro from JNBridge Inc..

Note JA.NET and JNBRIDGEPRO Different from JNBridgePro allows clients from the .NET remote processing client to Java objects and classes, but JA.NET allows inverting operations. This difference has no effect on this book.

Assess Ja.NET

JA.NET provides two-way implementations of Java .NET remote processing stack. Using JA.NET, you can generate a Java agent that exposes or uses components with .NET remote processing protocol.

Because JA.NET is a two-way bridge, it will generate a set of C # proxy from .NET. Similarly, access from Java .NET will generate a set of Java agents.

If you check the generated agent, you should notice the method that the class passed by the value contains all the fields of all the fields, and the remote processing of the class passed by reference is just a housing defining this class. JA.NET compilation definitions requires this, and you need them at a later runtime for class analog remote servers. This will generate an exception if you try to create a local copy of this class. You can only have a remote instance of this class. These agents do not use custom code, only use pure .NET remote processing.

When analyzing a .NET assembly, if you observe the generated Java agent, you should be able to see a plurality of codes of encapsulation and re-seal processes to the JA.NET runtime. When you access .NET from Java, you need to customize the code of the initialization JA.Net runtime, and any remote or receive code. However, .NET does not require any special code because JA.NET follows the .NET rules of the remote object. JA.NET allows Java components to behave like a CLR component, and let CLR components perform like Java components. In addition, JA.NET JANETOR tool extends this feature by generating Java agents within a WAR file. You can then carry this WAR file on a web server and use all .NET remote processing to access EJB from .NET Framework.

Access a .NET Framework server from Java

The easiest implementation is that when a JA.NET run library allows a Java client to access a .NET Framework server (in this case, it is implemented in Visual Basic.net). Figure 4.2 shows how to complete it.

Figure 4.2: Connect JA.NET to a VB.NET server component

Figure 4.2 shows how the Java platform carries the JA.NET running assembly.

Access IIS components from Java.

The Java client can also use the JA.NET runtime to access a remote CLR component, as if it is a local Java component. Figure 4.3 illustrates this method.

Figure 4.3: Connect JA.NET to the .NET component of boarding on IIS

Figure 4.3 illustrates a JA.NET agent that processes communication between Java client and Ja.NET runs. In this example, IIS is carrying the .NET Framework application.

Accessing an EJB from .NET Framework

The third method will include a WAR file that includes the JA.NET running library to any web server that supports servlet. The CLR client (written in any supported .NET Framework language) can access the EJB as if it is like accessing the local CLR component. Figure 4.4 illustrates an example of this use.

Figure 4.4: Connect a .NET client to an EJB using JA.NET.

In addition, Ja.Net runs for you:

• Write EJB clients with any .NET supported language. • Access the .NET Framework component from any Java object or EJB. • Reute each platform components with other environments.

Note Because of the transmission and data formatting perspective. Net remote processing is an extensible protocol, JA.NET supports HTTP and TCP / IP transport protocols and SOAP and binary data formatting and can support future transfer and formatting programs.

Ja.net tool set

The JA.NET toolset consists of six major parts. They are:

• The GenServiceGenjava and Gennet tools provide access to the .NET Framework assembly with GenService for development. You only need GenService to generate a proxy, so you don't have to install it in your product's environment. • The Gennet Gennet generates a .NET Framework agent, which accesses the Java class via Ja.Net runtime. • Genjava GetJava produces a Java agent, which accesses the .NET Framework assembly via Ja.Net runtime. • JANETOR JANETOR Tools Let you view and modify JA.NET Runturing configuration settings. You can also generate a WAR file with JANETOR to help deploy Ja.Net runtime to the web server. JANETOR includes Ja.NET products, licenses for local sharing and remote access objects. • JA.NET TCP Server JA.NET TCP Server provides independent hosts for Java classes through Ja.Net runtime, and these Java classes are not boarding on the J2EE server. The JA.NET runtime includes this component. • Ja.Net Runture 鈥 _ JA.NET Runture is the main collection of these tools. Janet.jar files contain runtime components. Link type between .NET Framework and Java.

When using JA.NET to link .NET Framework to Java, you need to understand the link between the .NET Framework's data type and the Java data type. Table 4.1 illustrates this information.

Table 4.1: .NET Framework to Java's data type mapping. .NET Framework data types Java data type System.Boolean boolean System.Char char System.String java.lang.String System.Single float System.Double double System.Int8 byte System.Int16 short System.Int32 int System.Int64 long System. Byte byte system.uint16 short system.uint32 int system.uint64 long system.Object java.lang.Object system.datetime java.util.date

Table 4.2 Description How you can use Ja.NET in Java and .NET Framework maps.

Table 4.2: Ja.NET set of Java in the mapping between Java and .NET Framework collection classes .NET Framework collections System.Collections.IList Java.util.LinkedList System.Collections.IList java.util.ArrayList Java.util.Vector System .Collections.ilist

Table 4.3 shows the reverse mapping from the .NET Framework to Java.

Table 4.3: Ja.net Collection Maps between .NET Framework and Java .NET Framework Collection Class Java Collection Class System.collections.Arraylist J ava.util.list

For more information on types and collection mappings, see Ja.NET documents.

Understand JA.NET events and abnormalities

To thorough understanding .NET remote processing options you need to understand more concepts. It includes the following concepts:

• Event JA.net provides event support by extending Java.util.EventListener to system events on the .NET Framework. This provides a significant advantage because the server components can now be implemented to the client's callback now. Events are especially useful when you want to achieve asynchronous operations or long-running transactions. • Exception Processing JA.NET provides exception handling functions, and reports an exception to another platform on one platform. The Java server is abnormally mapped back to the .NET Framework system.Runtime.Remoting.Remotingexception function and the exception mapped on the .NET Framework back to com.instrinsyc.janet.RemoteException. Typically, these derived exceptions contain text from the original exception. To process these exceptions, capture an exception that occurs as a result, and then search for text in an embedded exception to get more information. • Strong naming support JA.NET supports use and creates a strong naming assembly. Then you can register these assemblies in the global assembly cache for service components (COM ). • Easy to configure because JA.NET is a Java implementation of a pure .NET remote processing protocol, .NET Framework party does not require special runtime libraries. Like the Configuration of the .NET Framework and a standard .NET remote processing implementation, you only need a simple version of the DLL that contains classes and interface definitions. Any remote processing can be implemented on the .NET Framework (derived from MarshallByrefObject) or remote processing on JA.NET. You can also send serialization classes through the valuable value, just like only the implementation on the .NET Framework. Best criterion for achieving JA.NET

When using JA.NET, you should implement a few best practices. These issues include performance, design, and deployment factors. E.g:

• Upgrade to version 1.5. • Use a binary protocol for .NET remote processing. • Deploy the WAR package on the application server to access EJB and JMS. • Understand the .NET remote processing to facilitate good design practices. • Comprehend the difference in deliver (PBR) and value transfer (PBV).

Upgrade to version 1.5

It is highly recommended that you upgrade to Ja.Net 1.5, which is free for the earlier Ja.Net version of users. The 1.5 version contains many important new features, some of which are required to run the examples in this book. Some new features include the following:

• Strong naming assembly support. • Improve type mapping between .NET Framework types and Java types. • Major performance improvement. • Improve the serialization capabilities of the value transfer class of both parties. • Integrated web servers for non-enterprise hierarchy through HTTP remotely accessed. • Improved SDK. • .NET Framework version 1.0 and 1.1 runtime support. • For JMS integration .NET Framework proxy. • Strengthening stability and performance.

Use a binary protocol to perform .NET remote processing.

This chapter describes the benefits of using .NET remote processing instead of SOAP. Although JA.NET also supports SOAP connections, .NET remote processing provides better performance, providing the fastest connection with TCP / binary. However, if you need to cross the firewall, use IIS's security infrastructure, or easily deploy components within an application server, HTTP / binary is the preferred protocol.

Note http / binary is still much more faster than HTTP / SOAP.

Deploy the WAR package on the application server to access EJB and JMS.

The fastest way to access the EJB is to access from the application server itself. The easiest deployment is to create a WAR file that contains Ja.Net runtime JAR, EJB client JAR, and a configuration file. You can use Ja.NET JANETOR tools to easily create a WAR file, and then you can deploy it to the application server immediately. Because the WAR file resides in the same process space in the application, accessing EJB is much faster than accessing it from an external process with RMI. Understanding .NET remote processing to promote good design practices

Because JA.NET is a pure Java implementation of a .NET remote processing protocol, the same rules for .NET Remote Processing Best Practices also apply to Ja.NET. Make sure you read the current copy of the .NET remote processing, so you can understand the advantages of combining it and ja.net.

I have the difference in PBR and PBV.

In a PBR class, each method call leads to a data request. However, if you send a PBV class, this will serialize the entire class, including a superclass or class field. If you pass a very large object via a value, this object has a large number of fields that contain a lot of data, this may generate a considerable network traffic. In this case, it may be better to use PBR. Similarly, if you have a small class, consider sending a copy of this class with a value transfer, rather than making a network call for each field. It is understood that the difference in PBR and PBV reduces network traffic and improves performance.

Assess JNBridgePro

JNbridgePro is a point-to-point bridge solution that links Java components to .NET Framework. Java code runs on a normal Java Virtual Machine (JVM) or J2EE application server, while the .NET Framework code is running on the standard .NET Framework CLR. JNbridgePro follows the communication of both parties.

The agent makes the Java class and objects behave like a normal .NET Framework class, and objects. The .NET Framework component and those proxy interactions are like a standard local .NET Framework function call, but the agent object transparently will call the call to Java. Java component processing method calls and fields are accessed and return values ​​or data to the agent. The agent then supplies the result to the .NET Framework component.

An application that uses JNBridgePro to perform Java / .NET Framework inter-JNBridgePro's .NET Framework and Java FRM (these component management platform communication and object lifecycle), and one .NET Framework assembly (one DLL), the assembly contains proxy that is public to the Java class to the .NET Framework. Developers use the JNBridgePro toolkit to generate a proxy.

Figure 4.5 shows the architecture of JNBridgePro.

Figure 4.5: Interior architecture of JNBridgePro Running

Figure 4.5 shows the runtime components and agents of the .NET Framework party. Please compare it to Figure 4.3.

.NET remote processing integrated jnbridgepro.

JNBridgePro uses .NET remote processing to implement communication between .NET Framework and Java. Because .NET remote processing is an expandable architecture, you can change the communication channel as needed. JNbridgePro uses this scalable architecture to support SOAP and binary communications.

.NET remote processing also includes different concepts with traditional "local"-oriented objects such as rent, known objects, and objects activated by client activation. JnbridgePro can encapsulate these concepts and hide them. Therefore, JNBridgePro interoperability between Java and .NET Framework code is like local development in developers. JNBridgePro creates additional features on .NET remote processing. For example, basic .NET remote processing can access a member of the actual object, but if the static member of the class is not the actual instance member of the class, the basic .NET remote processing cannot access it. JNbridgePro provides the ability to access those static members.

Understand jnbridgepro function

JNBridgePro allows Java classes and objects to be accessed by calling the corresponding JNBridgePro proxy. In addition to supporting access requests and method calls for fields, JNBridgePro supports access static and instance members. You can use the .NET Framework code to call Java classes and objects. NET Framework proxy, you can explicitly call Java from .NET Framework, and you can register a callback object by using the .NET Framework code and let Java code through it. The listener interface accesses the callback object to invoke .NET Framework from Java.

Java components can reside in a standalone JVM or a J2EE application server. Communication between .NET Framework and Java can use SOAP or faster binary protocols.

JNBridgePro supports transaction processing, allowing you to make a series of calls from .NET Framework to Java in the same transaction. If the transaction fails, the entire sequence will roll back to the start point. This prevents application calls hang between .NET Framework and Java. JNbridgePro can also create a .NET Framework agent for a Java class that is generated during execution. Such dynamically generated classes often appear in the J2EE application, especially when linked to JNDI and EJB components.

JNbridgePro also supports the following situation:

• Mapping between .NET Framework and Java primitives. • String. • Collection. • Support to transmit (PBV) and transfer (PBR) by reference (PBV). • Connect to Java-based messaging servers.

Select JnbridgePro

If your application needs synchronization, point-to-point communication between the .NET Framework and Java objects and needs to meet one or more of the following requirements, then use JNBridgePro to J2EE and .NET Framework.

• High-performance your application requires a low-cost, high-performance interoperability mechanism, while Java platforms and .NET Framework are located in the same LAN or intranet or on the same machine. • Open a richly object-oriented Java API to the .NET Framework interface. Your application requires Java to disclose a large number of Java class APIs to the .NET Framework application, or the Java API returns a custom Java object or requires custom Java objects as a parameter. . • "Frequent" interaction your application performs frequent fine-grained calls between Java and .NET Framework. Web services will work better with "short and more coarse grain size" short-solid ". • Expected to keep "local", object-oriented development model Your application architect decided not to achieve public a small amount of API as a service, service-oriented model. Instead, they want the .NET Framework code to construct new Java objects with new operators, using cross-platform garbage collection technology, and provide a traditional "local" object-oriented model.

Implement JNBridgePro Best Practice

Here are some of the best practices that do you should use JNBridgePro regardless of the interoperability scenarios. Performance-related best practices include increasing the speed of the communication channel, or reducing the number of round-trip between the platform, thus significantly improving the implementation speed of the application. Upgrade to version 1.3

If you use JnbridgePro 1.2 or earlier, you should consider upgrading to version 1.3, especially if your .NET Framework and Java components reside on different computers. When using binary communication on the network, version 1.3 or updated version provides significant performance improvements. Some implementations have demonstrated that the time of accessing EJB is reduced from 200 milliseconds to 2.3 milliseconds.

In addition to the improvement of network communication performance, the 1.3 version also supports value objects and direct mapping sets, both of which improve performance.

In order to use these improvements, download and install version 1.3 and use the 1.3 version of the agent generating tool to regenerate your agent. Replace the old version of jnbshare.dll and jnbcore.jar in your application.

Use a binary communication protocol

Binary / TCP Communication is more than one order of SOAP / HTTP. Use SOAP / HTTP when using the Internet .NET Framework and Java and the communication path through the firewall.

To use the binary / TCP communication channel, make sure that the settings in the JNBProxy.config remote processing profile use JTCP: protocol instead of the http: protocol. And set the ServertYpe property of Java-Party Profile JNBCore.properties to TCP instead of HTTP.

Place the Java component in the J2EE application server.

If you use JNBridgePro to access EJB running in a J2EE application server, you have administered JNBridgePro Java. These components consist of a WAR file containing jnbcore.jar, consisting of the JAR files and related profiles of EJB stub. Figure 4.6 This is appropriately illustrated.

Figure 4.6: J5EE Application Server

This arrangement ensures that the jnbcore.jar called the EJB call bypasses RMI and calls EJB directly.

Place the Java party and the .NET Framework party components on the same computer.

If a single .NET Framework client accesses the Java class, if possible, placing a Java component that includes Java classes on the same computer in the .NET Framework party component. This minimizes the overhead of communication. Figure 4.7 illustrates such an operation process.

Figure 4.7: Java party components on the computer running the .NET Framework component

Increasing any round-trip time and communication links will affect the overall responsiveness of the platform interface.

Reduce round-trip

One of the best ways to improve JNBridgePro performance is to reduce the number of round trip between the NET Framework and Java by reducing the number of calls to the agent. An example of how to do this is: for obtaining information, when some agent calls are required, this time depends on another value that is calculated. In order to reduce the number of proxy calls, create a Java appearance class to perform call, do calculation, and return values. Then create a proxy for this class. This value can now be called through a proxy call.

Realize the return array

JNbridgePro provides full access to the Java API, so all API features is a huge temptation. For example, if you have a Java-Party VECTOR object, you should extract an array from this vector and return to that array via the value. The .NET Framework then represents the array locally, which omits the process of extracting values ​​from the original VECTOR object from the original Vector object.

Some Java API supports the Stateful object, you might want to repeat this object to get additional information. For example, JDBC class ResultSet represents the results of the query and can contain multiple rows, and you need to scroll to see these rows. In addition, this may result in multiple round trip to ResultSet. To improve performance, create a Java packaging class to return an array of objects, each of which contains a line of results. If the result array may be very large, and the full content returns it will take a long time, you can modify this packaging class to return a limited number of results each time (for example, no more than 50).

Value object

By default, the object call setting from .NET Framework to Java is the result of the delivery (PBR) result. The called object is saved in the Java party, and only the reference to the object is returned to the .NET Framework. Quotes are much smaller than real objects, help to improve performance, but they extract any useful information to go back to Java party. Even a field value requires a round trip to obtain data. If you perform multiple queries to get data to get multiple queries or use the accessor method to query data on an EJB, you'd better specify the object of the class as a value object.

A value object is a snapshot of an object from Java and then copy back to the .NET Framework party. Depending on the type of value object, the value of its public field is copied, and the value of its Accessor (GET) method is also copied in the case of the Java Bean value object. This process does not copy the object method other than the GET method of the Java bean value object because there is a problem with the meaning of the Java method into .NET Framework.

When the object is actually just a lot of data to access by many different methods, consider using the value object. For example, an object depicting a customer bank account may have a customer account number, name, last name, address, current balance, a departure, and account opening date of the account owner.

The default settings are by reference to the account objects that are passed, so that each field accessed by the userAcct causes a round trip. However, if you pass the Account to pass the value, you will copy the data of the useerAcct from the Java direction .NET party and subsequently all field access is local calls.

By the value or reference to whether an object can take the size of the object and how much you want to access. For example, in an example of a bank account, if the unique data you want to access in your account is the current balance, you may not be worth it through the value. In this case, the time of copying all data to the .NET Framework party exceeds the time saved by all field access in the .NET Framework locally.

Regardless of whether the object passes the value or reference delivery, the code is the same, the only difference is that the class of this object is specified as a value object or reference object. Ideally, the value of the value is depends on the observation measurement value in the test environment, not the judgment of the developer.

Note The object that is alone cannot be specified as values ​​or passed by reference, and all objects for the given class need to be specified.

For more information on value objects and reference objects in JNBridgePro, see the JNBridgePro User Guide.

Use direct mapping sets

Direct mapping sets returns a collection of some objects from Java, and automatically converts them to Java's native .NET Framework collection. After the conversion, you can quickly access these elements without going round trip.

JNbridgePro supports a variety of direct mapping sets. Java Vector, array list, link list, and hash collection are directly mapped to .NET Framework arrays lists. The Java hash table and hash map mapping are .NET Framework hash table. You can also transfer parameters from .NET Framework to Java using direct mapping sets. For more information, see the JNBridge User Guide. Like a value object, the direct mapping collection is more than the reference object between Java and .NET Framework, but you can then access their elements faster. It is determined whether a collection of direct mapping depends on the size of the transmitted collection, the number of accesses, and the test environment in the test environment.

Each disclosed class produces a representation of the same name. The generated agent member (including constructor, method, and field) corresponds to a member of the Java class as a proxy basis.

Generate all supported agents

When generating a proxy, all support agents are generated for each special requested proxy class. It is often possible to omit a support agent (such as all parameters, returning values, outlines, implementing interfaces and superclars), however, resulting in these support specifications and may not be harmful. In addition, you can invoke methods that require additional class agents and access to their fields for support class and access them without re-generating agents.

Note An additional problem with all support agents is in some cases if you don't do an exception.

Depending on the original seed proxy collection, all support agents add up to 200 to 300 additional proxy classes for raw gathering. It usually produces an additional agent for no more than five minutes.

Note that there is a possibility to avoid support classes in many cases. However, there is no harm to produce such a class, and doing so in the future avoiding various issues brought about by lack of support classes (although there is no problem now).

Back to top

Connect web services

In the previous part, you understand how to use the .NET remote processing, connect the Java platform and .NET Framework by running the clock bridge. However, .NET remote processing and .NET Framework are closely related and you may need an interoperability solution that is unrelated to the platform.

Currently a wide focus on computer industry web services, and Web services provide other options for the interoperability solution. What is the Web Services and what they have provided is still worthy of attention.

High-level definition of web services is a programmable application component accessible through standard Internet protocol. There are still many more detailed Web services, and in the description seems to contain the following elements:

• Web services provide useful features through standard Internet protocols. In most cases, this protocol is SOAP on HTTP. • The web service describes their interfaces in detail so that users build a client application and talk to them. An XML document called a Web Service Description Language (WSDL) document contains these descriptions. • Users can search for available web services in some form of registry database. General Description, Discovery and Integration (UDDI) is the most common way to achieve it.

Because web services are based on standard and platform-independent, use it to make the applications on different platforms interact more appropriate. This part explains why so many suppliers have quickly recognized the Web service standard. From this note, the web service can provide a useful mechanism for connection .NET Framework and J2EE. Web services have solved three main interoperability issues:

• Agreement Standards HTTP and HTTPS are the most common implementation, but web services can flexibly use any transfer protocol. • Type Definition Web Services Always open strong type data, so if a web service is open, another web service can understand and use that data type regardless of the underlying language or platform. • Multi-layer support to implement Web services in any platform and use any of the ability of the toolkit using any vendor, so a user does not need to know a platform for a specific service run. .NET Framework and Java provide a Web service implementation, which is achieved by integrating with the underlying platform at different levels. In fact, a core principle of .NET Framework is to integrate with the Web service. Web services are ideal for providing a wide range of services on the Internet, and they are a promising technology for enterprise application integration.

However, although Web services provide a very powerful technology, they do not apply to all applications and interoperability. Because SOAP is text-based, web service calls may be too slow to require frequent, fast and fine-grained communication applications.

Service-oriented interfaces like web services are also not suitable for traditional object-oriented models. Although you might think that a service is a permanent server activation object, client activates objects (such as objects constructed in New operators), however, access requests for static methods are often not supported. Similarly, if your application needs to access a wide variety of objects and classes, use a web service is usually inappropriate. Also, if you need to link to the rich object-oriented collection of the Java API from the .NET Framework, the Web service may not be a suitable solution.

In addition to the previous problems, the Web service is different from the way to support the object architecture in the object. Finally, returning a rich custom Java object to .NET Framework can generate a problem with a Web service. In this case, consider an alternative to Web services, such as JNBridgePro and Ja.NET.

Understanding web services

In a typical web service scenario, a client application can find out what features provided by querying the WSDL file of this service and understands how to call its feature. Next, the client sends a request to the service on a given URL using the SOAP protocol over the HTTP. The server receives the request, handles it, and returns a response. The request and response use the SOAP protocol to format it.

Protocols and specifications (or "stack") supporting Web services are worthy of investigation. "Web Services Stack" is composed of 5 layers, as shown in Figure 4.8:

Figure 4.8: Five-story models of "Web Services Stack"

These layers consist of the following elements:

• Transmission (HTTP) • Encoding (XML) • Standard Structure (SOAP) • Description (Sa WSDL) • Discover (UDDI)

The next chapter describes each element.

Transmission (HTTP)

Two components of the distributed architecture must comply with public transport mechanisms in the bottom of the lamination. Because the 80 port is accepted by all the firewalls through the firewall, HTTP has become the standard of the transport layer. However, Web service implementation can run on other transport protocols (such as FTP and SMTP), or even other network stacks (such as order packet exchange (SPX) or non-routing protocols (such as NetBeui). Currently within current specifications Change dependence on HTTP or HTTPS (for encryption) is possible.

Encoding (XML)

After the transmission layer is reached, the component must pass the correct XML format document message. XML-dependent ensures the success of the transmission, because both the supply and demand know the analysis and explanation of the XML standard. Standard structure (SOAP)

Although XML defines a message encoding, it does not involve the structure and format of the document itself. In order to ensure interoperability, both supply and demand must know what to send and expect. SOAP is a mess-based protocol on XML (XSD Version 2) and standard Internet protocols such as HTTP and SMTP. The SOAP protocol specification is a message (SOAP envelope), a data type definition, and a set of conventions (SOAP body) that implements remote procedure calls (SOAP body) defines an XML structure.

Description (WSDL)

The explanation layer provides a mechanism to inform the various special services provided by the parties to WEB services. Web Service Description Language (WSDL) provides this agreement to clarify each public component:

• Component name • Data type • Method • Parameters

WDSL Description allows developers who allow remote components to query web services, find out what this service can do and how to make it. The WSDL file is a XSD-based XML document that defines the details of the web service. It also stores your web service agreement. WSDL files are usually the first entry point for any client connected to your web service so that the client knows how to use it.

Discover (UDDI)

I found the problem that I tried to answer "Where". If you want to connect a web service in an Internet location (for example, www.nwtrade.msft / services / weatherservice.aspx), you can manually enter the URL. However, the URL is a bit difficult to operate and is not very friendly to the user, so if only the NWTRADERS weather web service is better. To do this, NWTRADERS can publish its meteorological services on a general description, discovery and integration service (UDDI) server. Finding Meteorological Services Now just connect to the UDDI server by using a already approved message format to locate the URL of the service.

Figure 4.9 illustrates how the basic architectural elements of a typical web service collaborate together.

Figure 4.9: Typical architectural elements from a web service

Now you understand the parts of the web service, making a more accurate definition easier. Therefore, a Web service is an application component that performs the following tasks:

• Use open protocol communication (such as HTTP and SMTP). • Process the XML message with SOAP group frames. • Describe its messages through an XML schema. • Provide a service description using WSDL. • Discover by UDDI support.

Web service interoperability organization.

The agreement on the Web service dependence is platform-independent. This means that the interoperability of Web services between different application platforms should be automated. Unfortunately, it is not necessarily the case.

Although most protocols are recognized, there are still many Web service draft standards that have not been fully recognized by any public Web standard organization (such as WWW Federation (W3C) or Structured Information Standard Promotion Organization (OASIS)}. So many suppliers Have their own specifications are not surprising. The result is that the interoperability of Web services between different suppliers cannot be guaranteed.

Because many suppliers have such enthusiasm for Web services, establishing an independent organization focuses on providing direction and maintenance standards. There is no such organization to ensure that the Web service is really mutually used. This needs to have a Web service interoperability (WS-I). The initial member is 170, providers, business customers, system integrators, and independent work to define the implementation of Web services.

Any organization or individual I hope to support and drive the interoperability of Web services can join WS-i. WS-I provides a framework and guideline for developers and provides a framework and guidelines in the following: • Profile 鈥 _ These are specifications for defining technical standards. • Examples These examples highlight the interoperability concept and illustrate the functionality of the configuration file. • Implementing guidelines These implementation guidelines illustrate the best practices for the design requirements to achieve an interoperability of Web services. • Tools These tools include an probe and analyzer to monitor and log interactions for Web services, including errors and warnings that identify implementations that do not meet the implementation of profile guidelines.

For more information on WS-i, please refer to the Web site (http://www.ws-i.org/) of the Web Service Interoperability.

Basic Profile for implementing Web services

The most important publication from WS-I is Basic Profile1.0. This profile provides a set of named Web service specifications and a range of recommendations for each standard. Basic Profile 1.0 involves four areas:

• Message Processing (HTTP, XML 1.0, XSD 1.0, SOAP 1.1) • Description (WSDL 1.1) • Discovery (UDDI 2.0) • Security (HTTPS)

Note WS-I does not manage the specifications within Basic Profile 1.0, so it is just a unified intermediate specification for web services. Xbikes sample applications do not fully support WS-I Basic Profile 1.0.

Implement web services

Implementing a Web service on the .NET Framework and implementing a web service on the J2EE platform is different from the respective support hierarchies. Because .NET Framework includes built-in support for Web services, you do not need any additional components. Visual Studio .NET allows you to create a web service from a project template. Using J2EE, you need to add a third-party Web service implementation.

Whether you implement a web service on .NET Framework or Java, there are some public architectural elements, as shown in Figure 4.9.

Two main steps in implementing Web services are:

• Create a web service. • Create a web service client.

The next two will introduce how to perform these two tasks on both platforms.

Create a web service on .NET Framework

Web services are closely integrated with .NET Framework. This makes it easy to design and create a web service with Visual Studio.NET IDE in .NET Framework. The .NET Web Service implements the same page frame with ASP.NET, consists of the following parts:

• A addressable Web service entry point (.asmx file). • Implement the code of the web service function (usually saved in one .asmx code hidden file).

Create web services to use Visual Studio.net, your developer workstation needs to access a web server configured for ASP.NET applications. If your server runs a version of Windows Server 2003, you must install IIS from the Application Server option and include support for ASP.NET applications.

Note The default installation of the Windows Server 2003 series does not contain IIS. This is different from Windows 2000.

Visual Studio .NET allows you to create an ASP.NET Web service item with any supported Visual Studio language with Web Services Project Templates. After you create a Web service project in Visual Studio, the component designer appears. The component designer is the design interface of the web service. You can use the design view to add components to the web service and use the code view to view and edit the relevant code. When you create an ASP.NET Web service item on Visual Studio, it builds a web application project structure on a web server and creates a Visual Studio solution file on your local computer. The solution file (.sln) contains configuration and compile settings, and reserves and project-related files lists. In addition, Visual Studio automatically creates the required files and references that support Web services. After completion, VisualStudo displays the .asmx file in the design view.

By default, when you create a web service using a ASP.NET Web Services Template, Visual Studio uses code hidden files such as Service1.asmx.vb (for Visual Basic) or Service1.asmx.cs (for C #). The code hidden file contains code that implements the web service function. In this file, you have implemented methods that wish to provide web services.

Note Default, the Solution Explorer hides the code hidden file. When you view the .asmx file in the code view, you see this code to hide the contents of the file. The .asmx file itself contains the processing instruction WebService, which indicates where to find the implementation of the XML Web service.

The way you implement the functionality of the Web service and your ability to implement Web services with any other class in .NET Framework. In order for a method available in the web service, you can mark the method with the [WebMethod] property before the PUBLIC declaration of this method. The Private method cannot act as the entry point of the web service, although these methods can be called in the same class and the web service code can call these methods.

When you build a web service, ASP.NET automatically provides infrastructure and controls processing of Web service requests and responses, including analysis and creation of SOAP messages. The compiled output is a .dll file, which is located in the bin folder of the project.

Chapter 7 and 8 of this book demonstrates how to implement a detailed example of the Web service as part of the Xbikes sample application in the .NET Framework. For additional reading materials for Web services, see the "Reference" section at the end of this chapter.

Open an existing class as a web service

A common scenario is that you want to disclose an existing .NET Framework class to a web service so that other applications (such as Java applications) can access it. To do this, you can create a new web service that acts as an existing class service interface. The new web service should implement the same interface as the existing interface, so that each method of the service is only to call the existing class method. This solution is called service interface mode.

For more information on service interface mode, see the "Reference" section at the end of this chapter.

WINDOWS Server 2003 Component Services You can use the built-in SOAP activation feature to disclose ServicesDComponent through a SOAP endpoint, and then you can access ServicedComponent through a WSDL document. SOAP activation includes automatic generation and carries a SOAP endpoint by IIS. This SOAP endpoint can then accept SOAP requests via HTTP.

Because you can access this SOAP endpoint through the WSDL document, some people will say that this document is a web service. Unfortunately, the situation may not be consistent, because although you use SOAP, HTTP, and WSDL generation endpoints, the WSDL document generated from SOAP is not XSD compatible, which contains the data type specific to .NET remote processing. Only by understanding .NET remote processing can access SOAP-activated ServicComponents. Therefore, by default, the client that is not the .NET Framework Web service cannot be connected. In order to overcome this, you can do the following things:

• Use any method disclosed from the ServicedComponent's SOAP endpoint using the Java client installed with the running-hour bridge. The reason it can work is to runtime bridge understanding .NET remote processing. • Create a new web service to accept incoming Web service requests and pass them to serviceDComponent, just like the service interface modes described earlier in this chapter.

No matter which technology you choose, you should now have a web service that you can use, then you can consider creating a client application.

Create a web service client

After you have created your web service, you need to have a client application to access it. There are several ways to do, depending on the protocol of your web service support.

If your Web service supports the HTTP-Get protocol, you can access it from a web browser. By default, the web service created in Visual Studio supports http-get, http-post and http-soap commands with the ASP.NET Web service project template.

Note WS-I Basic Profile 1.0 does not support HTTP-GET and HTTP-POST protocols. It is recommended that you disable HTTP-GET and HTTP-POST to compatible with WS-I? Basic Profile 1.0.

When you don't know how to generate a web service, .NET Framework provides two help techniques. The .asmx file directly from the browser without a parameter .ASMX file will generate a help page, as shown in the following example. http://localhost/webservice1/service1.asmx Other methods of discovering information about the web service are query their WSDL properties. You can use the "WSDL" as an additional parameter to query by calling the Web service from the browser. Sasmx file. Http: //localhost/webservice1/service1.asmx? WSDL These built-in help systems can help you in the design and debug phase of the Creating a Web service client.

Realize the .NET Framework web service client

The Web Services client is any component or application that uses and references to the Web service. The web service client does not have to be a client-based application. In many cases, the Web service client may be other web applications, such as web forms or even other web services.

When accessing a web service with a managed code, a proxy class and .NET Framework processes all infrastructure encodings. The proxy class implements the interface of the interface web service and processes all the communication between the Web service client and the web service. Figure 4.1 illustrates the relationship between the proxy class, the web service client, and the web service itself.

Figure 4.10: Web service client communication with a proxy class and web service

Note You can manually create and manage proxy classes, or you can manage them to manage them through an automated Web reference feature. It is recommended to use a web reference method.

Access the web service from the managed code of Visual Studio .NET

1. Add a web reference to the project to the project to the web service you want to access. The web reference creates a proxy class with a proxy that acts as a WEB service. 2. Add a namespace to the web reference. 3. Create an instance of an agent class, then access the method of that class like a method accessing any other classes. After you have established this project, then you should be able to access the referenced web service.

Locate an XML web service and add a web reference

Sometimes you may be both a web service provider and a user. In this case, you may know the location and function of the web service. At other times, you may visit the Web services provided by others. When this happens, you may not even know if the Web service that is suitable for you is actually existing.

In order to simplify the coding model, the application written by the hosted code is used to represent each web service locally. You use the Add Web Reference dialog to add a web reference to your project. To access the Add Web Reference dialog, right-click the Web References folder in the Visual Studio .NET Solution Explorer, and then click Add Web Reference. This dialog allows you to browse local servers, Microsoft UDDI directories, and Internet to find web services.

The Add Web Reference dialog box uses Web Service Discovery Processing to find the appropriate Web service you navigated in the dialog box. For a specific address, it queries the Web site by using an algorithm for web services description documents that comply with the Web Services Description Language (WSDL) syntax by using a Web Service Description Language (WSDL) syntax.

Generate a proxy class

After you use the Add Web Reference dialog box to locate your application, click the Button Add Reference Indicates Visual Studio to download a copy of the service to the local computer, then generate an proxy access to the selected web service. The proxy class contains a method of synchronizing and asynchronously calling each disclosed web service method.

Note This technique can only be used when running Visual Studio's computer with access to the web service.

Visual Studio creates a proxy class when adding a web service description language tool (WSDL.exe) when adding a web reference, and you can manually generate a proxy class with the same tool. This is necessary when you cannot access Web services from a computer installed on Visual Studio, such as the web service is on the network and the client can access this web service until running. To manually generate a proxy file, run WSDL.exe under the command line prompt and the URL of the WSDL file for the target web service is used as a parameter. Then you can manually add the tools generated for your application project.

Use agency class

The generated proxy class has its own namespace, and you must add this namespace to your client application before you create an instance of a proxy class. As with any other class, you must first create an instance of it before any method you can call it. This process is the same as instances of creating any other classes.

When using Visual Studio generated directly from the agent class from the web service service description, accessing Web services is relatively easy to manage. In order to access a web service method, your client application can invoke a synchronization method or asynchronous method corresponding to the proxy object. These methods do the necessary work to remotely call the method of the desired web service. By default, the proxy class uses the SOAP to access the Web service method, because SOAP supports the three supported protocols (HTTP-GET, HTTP-POST, and HTTP-SOAP) the most abundant data type collection.

The agent class generated by the Add Web Reference process is derived from system.web.service.protocols.soaphttpclientprotocol class, system.web.service.protocols.soaphttpclientProtocol class contains several properties, you can use these properties to control or customize such access Web services the behavior of. For more information on available properties in the SOAPHTTPCLIENTPROTOCOL class, see .NET Framework SDK. Note When you upgrade the web reference, Visual Studio .NET automatically generates a new proxy file. The new file covers the old file and deletes any custom part you may have added to the original proxy file. Keep a backup copy of any custom proxy file to deal with this possibility. If you manually generate a proxy file with a WSDL.exe tool, this situation does not happen.

Reference with dynamic and static URL

Web references can be used to use a static URL or a dynamic URL. The Web Reference URL property specifies the location of the web service. By default, this property is the URL of the web service you selected, which is a static URL.

If you keep the default value setting for the URL Behavior property, you create the instance of this class, hardcoded URLs set the URL property of the proxy class. If you set the URL Behavior property of the web reference to Dynamic, this application gets the URL from the application configuration file at runtime.

When you create an instance of a proxy object, you can also program the URL properties of the object in your application. Regardless of which URL is used, it must be a WSDL web service that matches the service used when adding a web reference. Otherwise, you will not be able to use it earlier.

Call the web service method

After adding a web reference to the web service, you can call the WEB service disclosure and access the results like any other method you use.

For examples of how to implement these technologies in Xbikes sample applications, see Chapter 7 and 8.

Create a web service in J2EE

Implementing Web services in Java is not as simple as in Microsoft .NET Framework. When writing this article, the latest J2EE specification version is version 1.3, and the 1.4 version is currently under testing. In version 1.3, this unit without web services is implemented. For example, there is no java.webservices package so you can import and use Java syntax.

However, definition and implementation of Web services have considerable power in Java groups. Java Community Process Defines the following Java Specification Request (JSR) with the Web Services:

• JSR 109 Implementing Enterprise Web Services • JSR 93 Java API for XML Registries 1.0 (JAXR) • JSR 67 Java API for XML messages for XML APIs for XML-based RPC Java API

JSR 109 defines a web service for the J2EE architecture. It provides a familiar, portable, scalable, and interoperable client and server programming model using the J2EE component architecture. JSR 109 is built on the JSR 67, JSR 93 and JSR 101. Note If a Java vendor's Web service implementation is compatible with JSR-109, other implementations that are compatible with JSR-109 should be interoperable.

JSR 93 defines a method of connecting an XML registry, such as JAVA application, such as JNDI, EBXML, and UDDI. This JSR provides mechanism so that the Web service can publish their interfaces and the client application can then find these interfaces.

JSR 101 Contempted to process XML RPC and Java languages. This includes the following:

• Describe XML-based interface definitions in Java. • Define the interface with XML-based interface definitions (such as SOAP). • Implement a getting process.

JSR 67 provides similar definitions for XML message processing.

Java Web Services Stack

Currently, Web Services on the Java platform requires Web Services Stack, which can be selected from it. The most common implementation is these implementations:

• Apache AXIS is a Web service implementation from the open source of Apache Software Foundation. • IBM has several Web Services Stacks that can be used, such as WebSphere Application Server, Web Services Developer Kit (WSDK), and Emerge Technologies Toolkit (ETTK). IBM also provides UDDI registry and server products. • WASP from Systinet provides Web Services Stack for C / C and Java environments. SYSTINET also offers a stand-alone UDDI server. • Glue from Mind Electric is a popular Web Services Stack. Mind Electric (recently WebMethods, Inc. M & A) also provides UDDI servers. • WebLogic application servers from the BEA also have a web services stack.

Which Web Stack decision chooses to reflect the preferences and technical requirements of the organization.

Create a web service in Java

Creating a Web service on Java depends on the Web Services Stack you selected and to some extent, depending on the Java IDE you use. All suppliers provide a tutorial for how to establish a web service in their documentation. However, the main steps of establishing a web service are consistent.

First, you need to determine which feature you want to open. With this information, you need to create a new class publication or an identifier that you can do this work. Many web services stack allows you to disclose existing classes or EJBs as web services. From the viewpoint of the architecture, you should create a new class, even if it just calls an existing class. This provides some protection for preventing applications from being modified.

After you determine the class you want to open, you must configure your Web Services Stack to open this class. Most Java Web Services implementation runs inside the application server as a servlet.

Note Some stacks, such as GLUF and WASP, if an application server is not available to provide its own container.

You can configure these servlets with a variety of profiles. To deploy a web service, you only need to modify these profiles. Many suppliers also use the API to provide a way of dynamically disclosed web services, but this hardcod should be avoided. For example, GLUE requires you to create an XML configuration file for the web service. To open this web service, you just add your class to this configuration file. When the Glue Servlet is based on class load and creates the appropriate WSDL and architectural documentation, the Glue Servlet analyzes this file.

For more information on how to create a web service using Glue, see the Glue? Documentation. Chapter 7, the Xbikes sample application in the representation layer integration .NET provides an example of a web service that implements the interoperability.

Use Web services in Java

Although there are many different Java web service providers, it is a fairly simple task in almost all vendor implementations. You can use a tool named WSDL2JAVA to handle local or remote WSDL documents, which subsequently created a Java agent implementation. This is a method similar to .NET Framework uses web services. In addition to Java tools just create an interface instead of an actual class. WSDL2JAVA usually creates a helper class that creates a URL endpoint-based object. This object implements the interface created by WSDL2JAVA, and you can then use it in your client application.

Chapters 7 and 8 provides examples of using web services in the Java platform.

Protect web services

Applications running in the product environment typically require some form of authentication and authorization. This can track multiple users of the service and make the data of each user independently of other users.

The easiest way to implement authentication is to use the HTTP built-in infrastructure to provide username, password, and domain to the web service. WEB services published from .NET Framework can use HTTP authentication. Although this identifies a user, it is not safe, because the HTTP package cannot avoid listening. This basic authentication of the username and password is sent using a clear text, allowing the electronic listener to identify the username and password.

More advanced authentication methods such as Kerberos, NTLM or Digest provide encrypted authentication methods, but these methods only provide encryption for the authentication process itself. Your web service implementation may need to apply encrypted to all clients to all client transactions. To do this, you can choose one from these methods:

• Transport layer security. • Application layer security. • Web Service Security (WS-Security).

Transport layer security such as the security socket layer (SSL) encryption on HTTPS works in the protocol layer and encrypts all the packages between start points and end points in a single web service call. This works well from the client (e.g., a representation of the ASP.NET application) to the business layer. After the package reaches the business layer (the end of SSL), the business layer web service decrypts these packets.

You have to keep these packages until they reach the database layer that stores usernames and passwords, has always been encrypted, and there is a problem. Because SSL is a point-to-point encryption method, it does not apply to keep your data over multiple web service calls over multiple web services in multiple layers.

Application layer security includes developing a custom security implementation. Although this technique can avoid using end-to-end encryption to avoid using SSL generated point-to-point issues, it needs to perform encoding work only for clients that implement the custom security implementation. In a web service, this is in turn of an improved idea.

The third selection of WS-Security uses the application to provide application layer security. As long as the client understands WS-Security, they can be securely connected to the web service.

WS-Security defines an XML structure for the security token, and the client uses these security tokens as evidence of identification. WS-Security tokens typically include a username, binary number, and security token reference. WS-Security uses standard components such as X.509 certificates to recognize the identity of the client. WS-Security also provides encryption, which can include encryption of the SOAP message body, the message header, or simultaneously encrypted. You control the WS-Security setting through the policy file, this policy file is an XML file named .wsse. Implement WS-Security includes creating a policy file and associating this file with a web service. The web service is then incorporated into and outgoing the message to ensure that they meet valid settings.

To access a secure web service, you create a security policy file and associate this file with the Web service control. The client policy setting must match the server-side policy settings.

Although the WS-Security standard is not fully approved, some suppliers have produced their own implementation, including the following products:

• WSE Microsoft's Web Services Enhancements. • IBM's IBM Web Services Toolkit. • WebLogic Workshop of Bea Systems.

For more information on implementing WS-Security and WSE, see the "Reference" section at the end of this chapter.

Using general description, discovery and integration

UDDI is a standard specification for issuing and positioning web services. In order to implement UDDI, install a UDDI server, then register the web service URL and description to the service. You can imagine UDDI as a similar Internet Locator Services (ILS), but the object to which the object is a web service instead of people. Like ILS, the UDDI server can be used as a common (a UDDI service registry or UBR), private (intranet-based) or half private, used between business partners. You can also compare the UBR server to the phone number book, and the white page is listed by the company. The yellow page is grouped by the company, and the green page describes the services they provide.

UDDI overcomes a simple URL lack of inspirational meaning. For example, it does not tell you more information about the service provided. Moreover, the URL has a characteristic that turns other URL, which prevents the client from being connected. UDDI uses a publishing and subscription model to support the consistency of the web service, making it unrelated to the changes in the URL string.

UDDI Directory Data Stock URL or Access Point, allowing them to associate with the services provided and the services involved. Business information can include contact details and business operations involved, support flexible and efficient search.

The main IT suppliers serve the UDDI initiatives such as Microsoft, IBM, SAP, VERITAS and NTT UDDI, and the current version is 3.0. These five suppliers also maintain public UBR registry. For more information on UDDI, please refer to the UDDI Web site (http://www.uddi.org/).

The benefits of using UDDI's interoperability

UDDI provides a great advantage for interoperability projects involving Web services. Any Java or .NET Framework client that needs to dynamically find the service provided can take advantage of UDDI. Other benefits include the following:

• Public Web Services release UDDI provides a platform-independent web service view. • Dynamically configure any client application to dynamically configure the web service agent with UDDI to eliminate the need for hard-coded URLs. In addition, dynamically re-bound to a web service to provide multiple URL instances. Similar to cyclic DNS, if a link does not respond, the application can request another service instance from the same provider through the UDDI. • Web Services reuse large organizations may have multiple departments to develop projects, often leading to repeated Web services. UDDI allows the development team to browse the entire list of released Web services to prevent all departments from waste time and money on providing existing services. • The location-specific web service is assigned a location to a web service, allowing the client to bind to the most recent service instance, improve performance and reduce network traffic. UDDI registry

The core component of the UDDI is a registry, which allows organizations to issue location information on available services. However, you don't have a product web service for public uses to benefit from UDDI.

Note Microsoft, IBM and SAP hosted test public registry to allow developers to test registration and release processes.

Several suppliers have implemented UDDI services on its latest operating system:

• Microsoft contains UDDI in Windows 2003 as its core service • IBM has added UDDI registry to WebSphere • Mind Electric Package UDDI Server with Glue

Note If you implement UDDI inside, check to ensure that it supports 3.0 standards.

UDDI has a great growth point in the future and provides great benefits when implementing Web services. The next part considers some of the best practices to help use Web services and interoperability.

Best practice of interaction of web services

Web services are still an emerging technology. The Web service-based protocol specification is the standard that has not been officially approved, so different suppliers can not be used interoperability. WS-I Basic Profile will help improve Web services interoperability in the future. However, when you are interacting between .NET Framework and Java, in order to make you have the biggest possibility of implementing Web services, follow these best practices:

• First define data types If you plan to use complex data types on a Web service, you can design your data type from the public XML architecture from the public XML architecture using certain policies. • Test your data type Before you start writing your primary application, use the test application in the test of the concept trial to pass your data type to prove that your interoperability solution is valid. • Use the simple data type as much as possible as long as you can achieve a simpler data type, you should do this. Realize complex data types only because of reasonable business reasons, not because you like this challenge. • Basis of all data types with XSD data type If you implement complex data types is especially important. As described in Chapter 3, "Multi-Usage Basic Principle", this ensures that the data type in the complex data object is mapped to the data type in .NET Framework and Java. • Store all data types When a .NET and Java assemblies require a single XML namespace for all data types, the data type is separated from the proxy file and store them in a separate location is especially useful. • WS-I Basic Profile 1.0 If you want to make your service can be used, it is a most important factor in accordance with WS-I Basic Profile 1.0. Make sure you always use the new version of WS-I Profile and the latest revision. • Standardize the style of document / text, rather than using a combination including SOAP or RPC encoding. Note WS-I Basic PROFILE 1.0 actively promotes document / text style. • Developed with the latest Java Web Services issued Java distribution and related tools development very quickly, using the latest release allows you to use the latest specification to improve reliability and consistent interoperability. • Using UDDI Discovery Web Services UDDI is a powerful and effective way to discover a web service in one organization or as part of the service to the public. • Apply abstracted this by interoperability adapter / service interface mode, allows you to add functions to a Web service when you do not modify the call logic. The abstraction layer can represent between business logic and the ASP.NET that is called. Implement an interoperability adapter / service interface mode makes the ASP.NET code exempt from additional overhead, such as calculating the URL from the UDDI registry. For more information on interoperability adapters / service interface patterns and implementations, see Chapter 6, "Interaction Design Elements". Just like all the best practices, sometimes you need to achieve a different solution. However, follow these guidelines will help you work with multiple applications as you don't interfere with each other as much as possible.

Compare .NET remote processing and web services

The .NET remote processing and web services with run-time bridges provide different methods for application platform interoperability, which provides flexibility in the designation of communication methods between application components. Although they have some similarities, .NET remote processing and Web services have some details. Table 4.4 summarizes their different points.

Table 4.4: .NET Remote Processing and Web Services between Web Services. NET Remote Processing Web Services HTTP Channel HTTP Channel XML Formatting Program Binary Format The Program Press Value Transfer Passen by Quote Press to Implement Storage Session Status Easy More Complex Call Unless Single Method Call Status Objects All Clients All Clients Call the same server-side objects to cross the firewall Use IIS as a host using custom host to get a complete copy of complex objects

Because there is currently a considerable industry power behind the web service, you may tend to implement Web services. However, Table 4.4 shows that Net remote processing shows a significant advantage in several respects.

Because .NET remote processing joins a TCP channel, no longer needs an HTML header. Combining it with a binary formatting process can usually improve performance significantly under large communication. Realizing the passage of values ​​or is available in two ways, but it is obviously more difficult to implement them in a web service. Moreover, there is no Web service complicated in session status management in .NET remote processing.

Other advantages compared to Web services in .NET remote processing include the following aspects:

• The interoperability is guaranteed. • Support for client activation and survival control (Similar to DCOM). • Support callbacks and events. • Supports additional context information specific to .NET Framework. In the future, the above information will support additional functions such as distributed transactions and additional security levels. • Support type system fidelity, which means there is a one-to-one mapping between classes and type hierarchies. Web services and SOAP do not support this object-oriented mechanism access to remote objects.

In a closely coupled intranet environment, you want to implement .NET remote processing when you want high transaction volume and control communication. Use a Web service with a loosely coupled system, especially when connecting to the Internet or if you cannot control both the conversation.

The Web service is higher than the .NET remote processing, mainly in the following aspects:

• Platform independent Web services use open and common standards such as XML, SOAP, HTTP, and WSDL. Therefore, Web services provide real platform innocence, you can call Web services from any client platform, regardless of server platform or Web services implementation technology. • Security IIS is a standard host selected for ASP.NET component, so web service applications created using ASP.NET can automatically use security features in IIS, such as supporting Windows Authentication, Security Sockets (SSL) encryption And logging. You can use IIS host .NET remote processing components so they can utilize the same security mechanism. However, if you are not in IIS, you must implement your authentication, authorization, and privacy mechanism yourself. • Cache has added IIS cache support to the Web service in the IIS. Efficient cache can significantly improve the performance advantage of .NET remote processing, depending on the data type you want to cache. The cache is most effective for the public data of repeated requests, and the validity will be reduced when cached private data or dynamic data. .NET? Remote handling does not have built-in support for cache, even when IIS host remote processing components. Therefore, like security, you must manually establish cache support. • Easy to create Visual Studio .NET makes it easy to create and use Web services. To create a web service, you need to create an ASP.NET Web service project and implement methods with the [WebMethod] property. To use a web service, create any type of item in Visual Studio .NET and add a web reference to your Selected Web Services, Visual Studio .NET produces a client agent to simplify access to Web services.

If these factors are important to you, the Web service may be better than the point-to-peer-to-peer-to-peer-to-peer.

Back to top

summary

This chapter describes a method of providing a point-to-peer-to-peer-to-peer-to-peer-to-peer-to-peer-to-date. It includes .NET remote processing and how you can use runtime bridges (such as JNBridgePro and Ja.net) links .NET Framework and Java. It then studies the rapid development of web services and describes how emerging standards such as UDDI and XML can simplify links to Java and .NET Framework components. In the next chapter, you will examine interoperability technology based on the message queue. Back to top

Reference

For more information on XML Web services, see:

SIMON GUEST Microsoft .Net and J2ee Interoperability Toolkit, Microsoft Press, ISBN 0-7356-1922-0, Book 5, 6

Scott Short's Building XML Web Service for the Microsoft .NET Platform, Microsoft Press, ISBN 0-7356-1406-7

For more information about Jnbridge JNBridgePro, see http://www.jnbridge.com

For more information on JSR specifications, see the Java Community Process Web site http://www.jcp.org/en/jsr/All

For more information on Apache Axis, see http://ws.apache.org/axis/

For information on IBM's web services, see the developerWorks Web site http://www-106.ibm.com/developerWorks/webservices/

For more information on Web services implementations for SYSTINET, see http://www.systinet.com/products/wasp_jserver/overview

For more information on Glue for Mind Electric, see http://www.themindelectric.com/

For more information on Web services on .NET Framework, see http://msdn.microsoft.com/webservices/

For more information on how to implement web services on .NET Framework, see "Creating XML Web Services in Managed Code" http://msdn.microsoft.com/library/default.asp?url=/library/EN-US /VBCON/HTML/vbconWebServicePublishing.asp

For more information about .NET remote processing, see "Microsoft .NET Remoting: a Technical overview" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotNet/html /HawkRemoting.asp

For more information on .NET remote processing profile, see "Format for .NET Remoting Configuration Files" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotNET/ HTML / RemotingConfig.asp

For more information on the remote object in IIS, see "Hosting Remote Objects in Internet Information Services (IIS) http://msdn.microsoft.com/library/default.asp?url=/library/EN-US /cpguide/html/cpconhostingremoteobjectsininternetinformationservicesiis.asp For more information about security Web services, see Web services Developer Center in the "security" http://msdn.microsoft.com/webservices/building/security/default.aspx

For more information on the implementation of the service interface, see "Enterprise Solution Patterns: Implementing Service Interface In .NET" http://msdn.microsoft.com/practices/type/patterns/enterprise/impserviceInterfaceInnetWasp/

For more information on implementing WSE, see the following article in MSDN: "Web Service Enhancements 1.0 and Java Interoperability, Part 1" http://msdn.microsoft.com/webservices/building/wse/default.aspx?pull= /library/en-us/dnwebsrv/html/wsejavainterop.asp

- with -

"Web Service Enhancements 1.0 and Java Interoperability, Part 2" http://msdn.microsoft.com/webservices/building/wse/default.aspx?pull=/library/en-us/dnwebsrv/html/wsejavainterop2.asp

For more information on UDDI services on the IBM platform, see "understanding uddi" http://www-106.ibm.com/developerWorks/webservices/-ibrary/ws-featuddi/#what IS% 20UDDI?

For the corresponding information about GLUE, see the Glue UDDI Web site http://www.themindelectric.com/docs/glue/guide/uddi/index.html To install UDDI on Windows Server 2003, see Windows Server 2003 Family Help "Using UDDI Services" topic.

Go to the original English page

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

New Post(0)