CREATING REAL TIME SERVICE AS A WEB SERVICE AND TESTING IT VIA SOAPUI
In the following blog, a Real Time Job is created in ‘SAP Data Services’. The Job is then added as a Real Time Web Service through ‘Data Services Management Console’ and further tested via SoapUI 5.4.0.
1) Create XML schema files:
This blog uses a basic REQUEST-RESPONSE scenario, where an ‘OrderNumber’ will be sent under Request and an ‘OrderNumber’ with its ‘Status’ will be returned as the Response.
Therefore, I have created only two XML schemas as shown below:
<?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="WS_INPUT" > <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="GetOrderStatus" minOccurs="1" maxOccurs="2"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="GetOrderStatus"> <xs:complexType> <xs:sequence> <xs:element name="OrderNumber" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
<?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="WS_RESULT" > <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="OrderStatus" minOccurs="1" maxOccurs="2"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="OrderStatus"> <xs:complexType> <xs:sequence> <xs:element name="OrderNumber" type="xs:string"/> <xs:element name="Status" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
Save the above schemas as two XML files in your system as they will be required in the next step while creating Nested Schemas.
2) Create Nested Schemas in BODS:
2.1) Go to Formats -> Nested Schemas -> Right Click -> New -> XML Schema
2.2) By following the above step, create two XML schemas by the name of REQUEST and RESPONSE
3) Create a Real-Time Job in BODS:
3.1) Go to Jobs -> Real-Time Jobs -> New -> Name the Job as per your choice. I have called it ‘REAL_TIME_TEST’
3.2) Double click on the new job to open it
3.3) Now, add a ‘Data Flow’ by using the third button from the palette on the right-hand side. Further, double click on the New Data Flow. You will receive a blank white screen
3.4) Go to Formats -> Nested Schemas. Drag REQUEST schema to the blank white screen on the right and choose ‘Make Message Source’
3.5) Next, add a ‘Query Transform’ by using the fifth button from the palette on the right-hand side. Further, connect ‘REQUEST’ and ‘Query’
3.6) Double Click on Query and then right click on ‘WS_INPUT_nt_1’ to choose ‘Map to Output’
On right-hand/output side, rename ‘WS_INPUT_nt_1’ to ‘WS_RESULT_nt_1’ by right clicking and choosing properties. Rename ‘GetOrderStatus’ to ‘OrderStatus’ by right clicking ‘Make Current’ (this will enable Properties option) and then choosing ‘Properties’ to rename.
3.7) Add one more output column called ‘Status’ by right clicking ‘OrderStatus’ on right hand side and choosing ‘New Output Column’
3.8) Click on ‘Status’ and under ‘Mapping’, use substring function to get a part of ‘OrderNumber’ as ‘Status’. You can use any ‘Mapping’ here
3.9) Now, Go to Formats -> Nested Schemas. Drag RESPONSE schema to the right and choose ‘Make Message Target’. Connect ‘Query’ and ‘RESPONSE’
3.10) Save all your work and move to the next step by clicking on ‘Data Services Management Console’
4) Add Real Time Job as a Real Time Service AND Real-Time Service as a Web Service:
4.1) Login using your credentials for SAP Data Services and choose ‘Administrator’ after logging in
4.2) Go to ‘Real-Time Services’ and click on ‘Real-Time Services Configuration’ tab. Scroll down and choose ‘Add’ from the bottom of screen
4.3) Enter ‘Service Name’ as per your choice (I have called it REAL_TIME_TEST_HA) and click on ‘Browse Jobs’ to choose your Real-Time Job. Further click on ‘Add’ and then ‘Apply’
4.4) Further, go to ‘Real-Time Service Status’, choose your service and click ‘Start’ present at the bottom of screen. A successful start will show a green tick in front of the service name after a few moments
4.5) Now, go to Web Services -> Web Services Configuration tab -> Choose ‘Add Real-Time Service’ from the bottom of screen-> Apply -> Choose your service and click ‘Add’
4.6) You will receive a message saying ‘Web Service Provider for Real-Time Service Successfully Added’
4.7) Next, go to Web Services -> Web Services Status -> Choose ‘View WSDL’ from the bottom of screen. Save this as ‘.wsdl’ file on your system
5) Testing Real-Time Service as Web Service from SoapUI 5.4.0
5.1) Go to Real-Time Services -> Real-Time Services Status -> Choose your service -> Click ‘Start’ present at the bottom of screen
5.2) Go to SoapUI and click on ‘SOAP’ at the top. Provide a name to your project and choose the ‘.wsdl’ file, which you saved earlier and click ‘OK’
5.3) Your Project will start appearing on the left-hand side. Go to ‘Real-Time_Services’ and double-click on ‘Request 1’ under your service name
5.4) Enter ‘OrderNumber’ on the ‘Request 1’ screen and click on the leftmost green button to ‘Submit request to specified endpoint URL’
5.5) You will receive ‘OrderNumber’ and ‘Status’ (First Four Digits of Order Number) as the Response
Receiving correct response ensures the successful creation and testing of Real-Time service as a Web Service.