如何在oracle ADF框架下开发测试部署SOAP web services.

本文参考官方文档的解读版:“Creating SOAP Web Services with Application Modules” :https://docs.oracle.com/cd/E51366_01/adf/develop/bcextservices.htm#ADFFD534

官网分为三部分讲述了这个问题:

(一)Service-Enable的Application Modules (AM)

Service-Enabled Application Module通过一个Server Interface给Service Consumer来服务. Service consumer有三种方法来访问一个Service-Enabled AM:

  • 1.Web Service Access
  • 2.Service Component Architechture (SCA) Composite access
  • 3.Another ADF Application Module access

Service Component Architecture (SCA) provides an open, technology-neutral model for implementing remotable services that are defined in terms of business functionality and that make middleware functions more accessible to application developers.

ADF Business Components支持通过有一个service intergface的AM,你可以发布一个SCA兼容的解决方案。

当我们service-enable一个AM时,jdeveloper将会生成一些artifacts,包括:1) The Java interface defining the service, 2) an EJB 3.0 session bean that implements this Java interface, 3) a WSDL file that describes the service's operations, and (4) XML schema documents (XSD) that defines the service's data structures.

SCA定义了两种类型的Service:

  • Remotable services, typically coarse-grained and designed to be published remotely in a loosely coupled SOA architecture
  • Local services, typically fine-grained and designed to be used locally by other implementations that are deployed concurrently in a tightly coupled architecture

ADF Business Components属于第一种,只可以用做remotable services. 由Remote AM定义的ADF Business Components Service可以与其他AM交换信息,包括数据访问和方法调用,这就意味着相同的AM可以使用ADF Data Controls和Web Service Client来支持Interactive Web User Interfaces.

二) 如何发布Service-Enabled Application Modules

这一章节内容比较多,大体列下来供快速预览。

2.1 How to Enable the Application Module Service Interface
2.2 What Happens When You Create an Application Module Service Interface
      2.2.1 Annotations Generated in the Web Service Interface
      2.2.2 Web Service Schema Generated in the Web Service Schema File
      2.2.3 WSDL Generated in the Web Service Definition File
      2.2.4 Stateless Session Bean Specified by the Service Implementation Class
      2.2.5 Lookup Defined in the connections.xml File
2.3 What You May Need to Know About Method Signatures on the ADF Web Service Interface
2.4 What You May Need to Know About Row Finders and the ADF Web Service Operations
2.5 How to Service-Enable Individual View Objects
2.6 How to Customize the SDO Properties of Service-Enabled View Objects
      2.6.1 Excluding Individual SDO Properties in a Generated SDO Component
      2.6.2 Associating Related SDO Properties Using Complex Data Types
2.7 How to Support Nested Processing in Service-Enabled Master-Detail View Objects
2.8 What Happens When You Create SDO Classes
      2.8.1 Property Accessors Generated in the SDO Interface
      2.8.2 View Object Interface Implemented by SDO Class
      2.8.3 View Object Schema Generated in the SDO Schema File
      2.8.4 Container Object Implemented by SDO Result Class and Interface
2.9 How to Expose a Declarative Find Operation Filtered By a Required Bind Variable
2.10 How to Expose a Custom Find Method Filtered By a Required Bind Variable
2.11 How to Generate Asynchronous ADF Web Service Methods
2.12 What Happens When You Generate Asynchronous ADF Web Service Methods
2.13 What Happens at Runtime: How the Asynchronous Call Is Made
2.14 How to Set Preferences for Generating the ADF Web Service Interface
2.15 How to Set Display Names for Service View Instances and Attributes
2.16 How to Secure the ADF Web Service for Access By SOAP Clients
2.17 How to Secure the ADF Web Service for Access By RMI Clients
      2.17.1 Enabling Authentication for RMI Clients
      2.17.2 Configuring Authorization for RMI Clients
2.18 How to Grant Test Users Access to the Service
2.19 How to Enable Support for Binary Attachments for SOAP Clients
2.20 How to Test the Web Service Using Integrated WebLogic Server
2.21 How to Prevent Custom Service Methods from Timing Out
2.22 How to Deploy Web Services to Oracle WebLogic Server

摘录一些概念以供理解。

The SDO framework upon which the SDO components are based abstracts the data of the view object and standardizes the way that data structures are passed between Java and XML. 就是说SDO组件基于SDO框架将VO的数据抽象出来,从而标准化了java和XML直接的数据机构转化。目前Jdeveloper只支持为service-enabled的AM来生成SDO components.其他ADF Business Component并不支持。

Service-Enabled的AM暴露了VO,custom motheds, built-in data manipulation operations, 以及specialized find methods based on View Criteria,供client使用。一旦我们enabled了AM service Interface,我们需要创建一个ADF Business Component Service Interface deployment profile, 并将这个profile部署到目标application server上去。我们还可以暴露the view instance data manipulation operations供一个BPEL process service component使用。BPEL一个语言,将多个service组合在一个形成一个end-to-end的process。

2.1 如何enable Application Module Service Interface

在AM-> overview -> Service Interface -> Enable Support for Service Interface -> 定义一个同步或异步的web service methods  ->  Service Categories  ->  Generate Object and Attribute Control Hints Operation  ->  Generate Last update time operation  ->  Generate Entity List Operation  ->  Service Custom Methods  ->  Include Warnings in Return Service Data Object  -> Service View Instances -> Basic Operations tab -> View Criteria Find Operations.

这就会在AM的serviceinterface节点目录下生成四个文件:

  1. xxxService.java  : Web Service Interface. 这里使用了JSR-181 web service specification的metadata annotations.
  2. xxxService.xsd : Web Service Schema file
  3. xxxService.wsdl : Web Service definition File
  4. xxxServiceImpl.java : Web Service implemenation class. 这是一个EJB3.0 stateless session bean,实现了web service interface.继承了oracle.jbo.server.svc.ServiceImpl.

除了上面这四个新生成的文件外,还会修改connection.xml来定义lookup。ADF Business Component service factory提供了一种机制,允许service client来look up这个service。而service factory依赖ADF connection architecture以及这个connection.xml。比如说下面的例子。

<Reference name="{http://www.globalcompany.com}StoreFrontService"
                    className="oracle.jbo.client.svc.Service" xmlns="">
   <Factory className="oracle.jbo.client.svc.ServiceFactory"/>
   <RefAddresses>
      <StringRefAddr addrType="serviceInterfaceName">
         <Contents>oracle.fodemo.storefront.store.service.common.serviceinterface.
                           StoreFrontService</Contents>
      </StringRefAddr>
      <StringRefAddr addrType="serviceEndpointProvider">
         <Contents>ADFBC</Contents>
      </StringRefAddr>
      <StringRefAddr addrType="jndiName">
         <Contents>oracle.fodemo.storefront.store.service.common.
                           StoreFrontServiceBean</Contents>
      </StringRefAddr>
      <StringRefAddr addrType="serviceSchemaName">
         <Contents>StoreFrontService.xsd</Contents>
      </StringRefAddr>
      <StringRefAddr addrType="serviceSchemaLocation">
         <Contents>oracle/fodemo/storefront/store/service/common/
                                     serviceinterface/</Contents>
      </StringRefAddr>
   </RefAddresses>
</Reference>

2.2 需要了解的关于AM的web service interface 和 client interface

AM可以定义两种不同类型的interface: client interface和service interface. Client interface供ADF Model层来使用,保护一些AM的方法供clients来使用AM。Service interface供application集成使用,给外部的web service或其他application server使用。这两种不同的interface在支持的Data types是不同的。参数和返回值支持的data types是不同的。service interface支持的data type仅限于java primitive types和它们的wrapper types(如,int, Integer, Long).

2.3 如何deploy web service to Oracle weblogic Server

deploy之前需要知道这些事项:

1. 如果你的project包含了一个standard web service(A java class or interface with the @WebService), 在deploy business conponent web service之前必须将这个annotation从这个java class上移除。标准的web service和Business component web service不能共存于同一个project,否则部署失败。

2.如果创建的是个异步web service, 还必须先配置queues用来保持request和reponse.

3. 如果为web service配置了authorization,先要修改weblogic-application.xml来定义application ID parameters,以及ejb-jar.xml中定义JpsInterceptor

<weblogic-application xmlns="http://www.bea.com/ns/weblogic/weblogic-application"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                        "http://www.bea.com/ns/weblogic/weblogic-application.xsd">
   <application-param>
      <param-name>jps.policystore.applicationid</param-name>
      <param-value>ApplicationName</param-value>
   </application-param>
   ...
</weblogic-application>

这个ApplicationName还要与jazn-data.xml一致。

<jazn-data>
   <policy-store>
        <applications>
            <application>
                <name>ApplicationName</name>
                <app-roles>
                    ...
                </app-roles>
                <jazn-policy>
                    ...
                </jazn-policy>
            </application>
        </applications>
    </policy-store>
</jazn-data> 

在ejb-jar.xml中添加JpsInterceptor

<?xml version = '1.0' encoding = 'windows-1252'?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
         http://java.sun.com/xml/ns/j2ee/ejb-jar_3_0.xsd" version="3.0" 
         xmlns="http://java.sun.com/xml/ns/javaee">
  <enterprise-beans>
    ...
  </enterprise-beans>
  <interceptors>
     <interceptor>
        <interceptor-class>
            oracle.security.jps.ee.ejb.JpsInterceptor
        </interceptor-class>
           <env-entry>
              <env-entry-name>application.name</env-entry-name>
              <env-entry-type>java.lang.String</env-entry-type>
              <env-entry-value>ApplicationName</env-entry-value>
              <injection-target>
                  <injection-target-class>
                      oracle.security.jps.ee.ejb.JpsInterceptor
                  </injection-target-class>
                  <injection-target-name>
                      application_name
                  </injection-target-name>
              </injection-target>
           </env-entry>
     </interceptor>
     ...
  <interceptors>
  <assembly-descriptor>
     <interceptor-binding>
        <ejb-name>*</ejb-name>
        <interceptor-class>
             oracle.security.jps.ee.ejb.JpsInterceptor
        </interceptor-class>
     </interceptor-binding>
  </assembly-descriptor>
</ejb-jar>

 

(三) 如何通过Service-Enabled Application Modules来访问远程数据 

3.1 How to Use Service-Enabled Entity Objects and View Objects
      3.1.1 Creating Entity Objects Backed by SDO Services
      3.1.2 Using Complex Data Types with Service-Backed Entity Object Attributes
      3.1.3 Creating View Objects Backed by SDO Services
3.2 What Happens When You Create Service-Backed Business Components
3.3 How to Update the Data Model for Service-Backed Business Components
3.4 How to Configure the Service-Backed Business Components Runtime
      3.4.1 Adding the SDO Client Library to the Classpath
      3.4.2 Registering the ADF Business Components Service in the Consuming Application's connections.xml for the EJB RMI Protocol
      3.4.3 Registering the ADF Business Components Service in the Consuming Application's connections.xml for the SOAP Protocol
      3.4.4 Registering the ADF Business Components Service in the Consuming Application's connections.xml for Fabric SDO Binding
3.5 How to Test the Service-Backed Components in the Business Component Browser
3.6 How to Invoke Operations of the Service-Backed Components in the Consuming Application
3.7 What You May Need to Know About Creating Service Data Objects in the Consuming Application
3.8 What You May Need to Know About Invoking Built-In Service Methods in the Consuming Application
3.9 What Happens at Runtime: How the Application Accesses the Published Application Module
3.10 What You May Need to Know About Service-Backed Entity Objects and View Objects

 

最后,一些英文术语缩写:

SDO: Service Data Object

SCA: Service Component Architecture

OASIS: Orgnization for Advancement of Structure Information Standards

CSA: Composite Service Architecture

BPEL: Business Process Execution Language

 

发表评论