开发与运行环境:JDeveloper 11.1.1.5.0 + SOA Suite 11.1.1.5.0
信用卡信息存储在数据库中,因此要使用DB Adapter。
SOA 应用设计如下:
信用卡信息存储在数据库中,因此要使用DB Adapter。
SOA 应用设计如下:
重要步骤说明:
1. 增加External References:getCreditValidation(使用Database Adapter)
(1)使用的数据库JNDI Name必须和DbAdapter中配置的对应一致:eis/DB/soademoDatabase
(2)因为是获取数据,因此只选择Select操作
(3)设置主键
(4)完成后,将会产生getCreditValidation.wsdl文件
<?binding.jca getCreditValidation_db.jca?>
<wsdl:definitions name="getCreditValidation" targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/CreditCardValidation/validationForCC/getCreditValidation" xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/db/CreditCardValidation/validationForCC/getCreditValidation" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:top="http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation">
<plt:partnerLinkType name="getCreditValidation_plt">
<plt:role name="getCreditValidation_role">
<plt:portType name="tns:getCreditValidation_ptt"/>
</plt:role>
</plt:partnerLinkType>
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/getCreditValidation" schemaLocation="xsd/getCreditValidation_table.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="getCreditValidationSelect_inputParameters">
<wsdl:part name="getCreditValidationSelect_inputParameters" element="top:getCreditValidationSelect_ccnbInputParameters"/>
</wsdl:message>
<wsdl:message name="CreditcardinfoCollection_msg">
<wsdl:part name="CreditcardinfoCollection" element="top:CreditcardinfoCollection"/>
</wsdl:message>
<wsdl:portType name="getCreditValidation_ptt">
<wsdl:operation name="getCreditValidationSelect">
<wsdl:input message="tns:getCreditValidationSelect_inputParameters"/>
<wsdl:output message="tns:CreditcardinfoCollection_msg"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
可以看出,这是一个同步调用(一个Operation 带有输入和输出参数),是一个request-and-reply服务。
2. 增加Mediator
3. 增加Service:getStatusByCC
Service的接口定义一般都是根据一个xsd文件,这里使用的是creditcheck.xsd,其定义如下:
<?xml version= '1.0' encoding= 'UTF-8' ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.globalcompany.com/ns/CCAuthorizationService"
targetNamespace="http://www.globalcompany.com/ns/CCAuthorizationService" elementFormDefault="qualified">
<xsd:element name="creditcardStatusRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CCNumber" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="creditcardStatus" type="xsd:string"/>
<xsd:element name="error" type="xsd:string"/>
</xsd:schema>
完成后,会生成getStatusByCC.wsdl,其内容如下:
<?xml version= '1.0' encoding= 'UTF-8' ?><wsdl:definitions
name="getStatusByCC"
targetNamespace="http://oracle.com/sca/soapservice/CreditCardValidation/validationForCC/getStatusByCC"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:inp1="http://www.globalcompany.com/ns/CCAuthorizationService"
xmlns:tns="http://oracle.com/sca/soapservice/CreditCardValidation/validationForCC/getStatusByCC"
>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.globalcompany.com/ns/CCAuthorizationService" schemaLocation="xsd/creditcheck.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="requestMessage">
<wsdl:part name="part1" element="inp1:creditcardStatusRequest"/>
</wsdl:message>
<wsdl:message name="replyMessage">
<wsdl:part name="part1" element="inp1:creditcardStatus"/>
</wsdl:message>
<wsdl:message name="faultMessage">
<wsdl:part name="part1" element="inp1:error"/>
</wsdl:message>
<wsdl:portType name="execute_ptt">
<wsdl:operation name="execute">
<wsdl:input message="tns:requestMessage"/>
<wsdl:output message="tns:replyMessage"/>
<wsdl:fault name="executefault" message="tns:faultMessage"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
4. 连接getStatusByCC Service和Mediator,以及 Mediator 和getCreditValidation Reference
5. 在Mediator中增加Transformation做数据转换
由于getStatusByCC Service 和getCreditValidation Reference数据的格式不同,因此需要在Mediator中增加Transformation做数据转换。
转换既有Request方向的数据格式的转换,也有Reponse方向的数据格式的转换。
6. 部署ValidationForCC Project
7. 测试
Project 下载:Lab02 CreditCardValidation.7z
没有评论:
发表评论