订单处理流程无疑是最核心的应用,我们从简到繁,先实现一个最简单的逻辑:收到订单后,什么都不做,直接写到一个文件里。
SOA 应用设计如下:
重要步骤说明:
1. 增加receivePO Service
Service的接口定义一般都是根据一个xsd文件,这里使用的是po.xsd,其定义如下:
<?xml version= '1.0' encoding= 'UTF-8' ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.oracle.com/ns/order"
xmlns:po="http://xmlns.oracle.com/ns/order" elementFormDefault="qualified">
<element name="PurchaseOrder" type="po:PurchaseOrderType"/>
<complexType name="PurchaseOrderType">
<sequence>
<element name="CustID" type="string"/>
<element name="ID" type="string"/>
<element name="productName" type="string" minOccurs="0"/>
<element name="itemType" type="string" minOccurs="0"/>
<element name="price" type="decimal" minOccurs="0"/>
<element name="quantity" type="decimal" minOccurs="0"/>
<element name="status" type="string" minOccurs="0"/>
<element name="ccType" type="string" minOccurs="0"/>
<element name="ccNumber" type="string" minOccurs="0"/>
</sequence>
</complexType>
</schema>
完成后,会生成receivePO.wsdl,其内容如下:
<?xml version= '1.0' encoding= 'UTF-8' ?>
<wsdl:definitions
name="receivePO"
targetNamespace="http://oracle.com/sca/soapservice/POProcessing/POProcessing/receivePO"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:inp1="http://xmlns.oracle.com/ns/order"
xmlns:tns="http://oracle.com/sca/soapservice/POProcessing/POProcessing/receivePO"
>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://xmlns.oracle.com/ns/order" schemaLocation="xsd/po.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="requestMessage">
<wsdl:part name="part1" element="inp1:PurchaseOrder"/>
</wsdl:message>
<wsdl:portType name="execute_ptt">
<wsdl:operation name="execute">
<wsdl:input message="tns:requestMessage"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
可以看出这是一个one-way 调用(只有输入参数,没有输出参数),是一个fire-and-forget服务。
2. 增加Mediator
3. 增加External References:WriteApprovalResults(使用File Adapter)
这里使用File Adapter的Write操作来实现文件的写入,其中文件内容的格式由interalorader.xsd定义:
<?xml version= '1.0' encoding= 'UTF-8' ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.oracle.com/ns/order"
xmlns:po="http://xmlns.oracle.com/ns/order" elementFormDefault="qualified">
<element name="Order" type="po:OrderType"/>
<complexType name="OrderType">
<sequence>
<element name="customerId" type="string"/>
<element name="orderId" type="string"/>
<element name="prodName" type="string" minOccurs="0"/>
<element name="itemType" type="string" minOccurs="0"/>
<element name="price" type="decimal" minOccurs="0"/>
<element name="qty" type="decimal" minOccurs="0"/>
<element name="status" type="string" minOccurs="0"/>
<element name="creditCardInfo" type="po:ccInfo" minOccurs="0"/>
</sequence>
</complexType>
<complexType name="ccInfo">
<sequence>
<element name="cardNumber" type="string"/>
<element name="cardType" type="string"/>
</sequence>
</complexType>
</schema>
完成后,会生成WriteApprovalResults.wsdl,其内容如下:
<wsdl:definitions
name="WriteApprovalResults"
targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/POProcessing/POProcessing/WriteApprovalResults"
xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/file/POProcessing/POProcessing/WriteApprovalResults"
xmlns:imp1="http://xmlns.oracle.com/ns/order"
xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
>
<plt:partnerLinkType name="Write_plt" >
<plt:role name="Write_role" >
<plt:portType name="tns:Write_ptt" />
</plt:role>
</plt:partnerLinkType>
<wsdl:types>
<schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/POProcessing/POProcessing/WriteApprovalResults"
xmlns="http://www.w3.org/2001/XMLSchema" >
<import namespace="http://xmlns.oracle.com/ns/order" schemaLocation="xsd/internalorder.xsd" />
</schema>
</wsdl:types>
<wsdl:message name="Write_msg">
<wsdl:part name="body" element="imp1:Order"/>
</wsdl:message>
<wsdl:portType name="Write_ptt">
<wsdl:operation name="Write">
<wsdl:input message="tns:Write_msg"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
4. 连接recivePO Service和Mediator,以及 Mediator 和WriteApprovalResults Reference
5. 在Mediator中增加Transformation做数据转换
由于receivePO Service 和WriteApprovalResults Reference数据的格式不同,因此需要在Mediator中增加Transformation做数据转换。
因为是one-way调用,因此只有Request方向的数据格式的转换。
6. 部署POProcessing Project
7. 测试
Project 下载:Lab03 POProcessing.7z
没有评论:
发表评论