Document Description Title:
E-IB: Example for PeopleSoft REST provider service (GET/POST methods) (Doc ID 1533318.1)
Example for PeopleSoft REST provider service (GET/POST methods)
1. Setup REST service target location
2. Create Document/Message definition (template and request/response messages)
1) Template message
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
1
2) Request/response message
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
2
NOTE: below is the exported schema for your reference
<?xml version="1.0"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="[Link]
xmlns="[Link]
xmlns:xsd="[Link]
<xsd:element name="currency" type="currency_TypeShape"/>
<xsd:complexType name="currency_TypeShape">
<xsd:sequence>
<xsd:element minOccurs="0" name="currency_cd" type="currency_cd_TypeDef"/>
<xsd:element minOccurs="0" name="effdt" type="effdt_TypeDef"/>
<xsd:element minOccurs="0" name="eff_status" type="eff_status_TypeDef"/>
<xsd:element minOccurs="0" name="desc" type="desc_TypeDef"/>
<xsd:element minOccurs="0" name="descshort" type="descshort_TypeDef"/>
<xsd:element minOccurs="0" name="country" type="country_TypeDef"/>
<xsd:element minOccurs="0" name="cur_symbol" type="cur_symbol_TypeDef"/>
<xsd:element minOccurs="0" name="decimal_positions" type="decimal_positions_TypeDef"/>
<xsd:element minOccurs="0" name="scale_positions" type="scale_positions_TypeDef"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="currency_cd_TypeDef">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="3"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="effdt_TypeDef">
<xsd:restriction base="xsd:date">
<xsd:pattern value="(\d{4}-\d{2}-\d{2})"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="eff_status_TypeDef">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="desc_TypeDef">
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
3
<xsd:restriction base="xsd:string">
<xsd:maxLength value="30"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="descshort_TypeDef">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="country_TypeDef">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="3"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="cur_symbol_TypeDef">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="4"/>
<xsd:whiteSpace value="preserve"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="decimal_positions_TypeDef">
<xsd:restriction base="xsd:integer">
<xsd:totalDigits value="2"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="scale_positions_TypeDef">
<xsd:restriction base="xsd:integer">
<xsd:totalDigits value="1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
3. Create REST service definition
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
4
4. REST service operation definitions
1) GET method
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
5
2) POST method (request/response messages are optional)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
6
5. REST provider service handler code for GET/POST method
import PS_PT:Integration:IRequestHandler;
class InboundSyncRequestHandler implements PS_PT:Integration:IRequestHandler
method InboundSyncRequestHandler();
method onRequest(&MSG As Message) Returns Message;
method onError(&MSG As Message) Returns string;
end-class;
method InboundSyncRequestHandler
end-method;
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
7
method onRequest
/+ &MSG as Message +/
/+ Returns Message +/
/+ Extends/implements PS_PT:Integration:[Link] +/
Local Message &response;
Local Document &Doc_Tmpl, &Doc1;
Local Compound &COM1;
Local Record &rec1;
Local string &curr_cd;
Local SQL &SQL1;
/*****HTTP GET method************/
If &[Link] = %IntBroker_HTTP_GET Then
/* read URI Document to get parms out */
&Doc_Tmpl = &[Link]();
&curr_cd = &Doc_Tmpl.[Link]("currency_cd").Value;
/*Create the response message */
&response = CreateMessage(Operation.CURRENCY_GET, %IntBroker_Response);
&Doc1 = &[Link]();
&COM1 = &[Link];
/*** Create SQL object to retrieve the values from the rowset ***/
&rec1 = CreateRecord(Record.CURRENCY_CD_TBL);
&SQL1 = CreateSQL("%selectall(:1) where CURRENCY_CD = :2", &rec1, &curr_cd);
If &[Link](&rec1) Then
&[Link]("currency_cd").Value = &rec1.CURRENCY_CD.Value;
&[Link]("effdt").Value = &[Link];
&[Link]("eff_status").Value = &rec1.EFF_STATUS.Value;
&[Link]("descr").Value = &[Link];
&[Link]("descrshort").Value = &[Link];
&[Link]("country").Value = &[Link];
&[Link]("cur_symbol").Value = &rec1.CUR_SYMBOL.Value;
&[Link]("decimal_positions").Value = &rec1.DECIMAL_POSITIONS.Value;
&[Link]("scale_positions").Value = &rec1.SCALE_POSITIONS.Value;
End-If;
End-If;
/*****HTTP POST method************/
If &[Link] = %IntBroker_HTTP_POST Then
/* Get the document message */
&Doc1 = &[Link]();
&COM1 = &[Link];
/* Create record and populate from document*/
&rec1 = CreateRecord(Record.CURRENCY_CD_TBL);
&[Link](Field.CURRENCY_CD).Value = &[Link]("currency_cd").Value;
&[Link]([Link]).Value = &[Link]("effdt").Value;
&[Link](Field.EFF_STATUS).Value = &[Link]("eff_status").Value;
&[Link]([Link]).Value = &[Link]("descr").Value;
&[Link]([Link]).Value = &[Link]("descrshort").Value;
&[Link]([Link]).Value = &[Link]("country").Value;
&[Link](Field.CUR_SYMBOL).Value = &[Link]("cur_symbol").Value;
&[Link](Field.SCALE_POSITIONS).Value = &[Link]("decimal_positions").Value;
&[Link](Field.DECIMAL_POSITIONS).Value = &[Link]("scale_positions").Value;
&[Link]();
/*Create the response message */
&response = CreateMessage(Operation.CURRENCY_POST, %IntBroker_Response);
End-If;
Return &response;
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
8
end-method;
method onError
/+ &MSG as Message +/
/+ Returns String +/
/+ Extends/implements PS_PT:Integration:[Link] +/
Local integer &nMsgNumber, &nMsgSetNumber;
Local string &str;
&nMsgNumber = &[Link];
&nMsgSetNumber = &[Link];
&str = &[Link];
Return &str;
end-method;
6. Test with sendmaster
1) REST get test
2) REST post test
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
9
NOTE: the xml contain the changes, e.g. DESCRSHORT=”TEST”
<?xml version="1.0"?>
<currency xmlns="[Link]
<currency_cd>USD</currency_cd>
<effdt>1900-01-01</effdt>
<eff_status>A</eff_status>
<desc>US Dollar</desc>
<descshort>TEST</descshort>
<country>USA</country>
<cur_symbol>$</cur_symbol>
<decimal_positions>0</decimal_positions>
<scale_positions>2</scale_positions>
</currency>
Call Get method again to verify the change was done.
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
10
7.
Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
11