- Create/Run receiver side’s SOAP/HTTP mock services
- Setup SAP PI for the created services
- Basic testing scenario with LOADUI
Mock service will make your computer to pretend to be the service server and reply the requests from clients connected to you. This requires connection and firewall settings to allow the requests from local network.
Possibilities and situations to use the mock services
1) as SAP
SOAP UI Mock service could be used as SAP Systems on the receiver end of
the scenarios. In this type of mocking, the service structure should be
exported from SAP (RFC).
2) as Web Service
Normally the mock service mimics the behavior of web servers’ service. The service
structure could be created from any web services within SOAP standard.
For both types of mock testing, the response message can be defined either conditionally or constantly in SOAPUI.
Mock Services Creation
1) Prepare request/response structure (WSDL)
According to Introduction, before creating any mock service, there is at least one XML structure required to define the request message. There will be another structure to define the response message if it is synchronous interface. Those structures are from the system we tend to mock. The methods to achieve the structures will not be discussed in this article.
SOAPUI supports the many WSDL/XML formats of service structure. Mostly every XML format file that can be imported to SOAPUI can also be used to create mock service.
Check if the service structure is importable to SOAPUI
2) Create the Mock services
After the normalrequest message is imported, right –click at the Request and click “Generate MockService.”
The MockService generation dialog appears. In this dialog, Path (a part of mock service URL) and Port are need. The port must be any port that is not currently used by other processes.
After finishing the process, the mock service entry will appear.
Double-click at the Response entry; the response structure will appear on the right side of the request/response screen. According to the testing concept, this test focuses on interfacing capability not the functionality. Therefore, the constant response entered here will be used for replying every request message.
The other specific parameters, such as the delay time before sending response, of the service could be set at the right bottom of screen after click on the Response entry.
3) Run the services
After all configurations, double-click at the mock service entry the service control dialog will appear. Click the green start button to run the service.
4) Test the services
Double-click on the sub-entry of the service, another service dialog will appear. Click “Opens a Request for MockOperation” to test the service.
The request/response dialog will appear. Please note that the request URL consists of your computer name that might not be able to access by other objects in the network. However, for this step, just click the submit button to see the result.
If the response message, which you have defined in the step before, is displayed correctly, your new mock service is successfully created.
At this time, if you double-click at the Response entry, you will see the request message that you just sent in the left panel.
In order to enable your service to other computers in the network, you have to specify your IP address in the service URL instead of your computer’s name.
Edit the current URL to test the service again.
Check if the service is working correctly through new URL.
The instructions above are commonly used for both synchronous and asynchronous interfaces. SOAPUI knows the type of structures since they are imported.
The difference between synchronous and asynchronous is the response message. The asynchronous message might require only just SOAP envelope for the response.
SAP PI Settings
After the service is running, the steps above show the direct connection to service. In this section, we will connect to the service by using SAP PI as the middleware. The request messages will be sent from mock sender (your computer) to SAP PI. Then SAP PI will deliver those messages to mock receiver (your computer) and wait for the response to reply back to the sender (if it is the synchronous interface).
This example uses the SOAP sender/receiver channels to behave like SOAP -> SAP PI -> SAP ECC synchronous interface.
1) Prepare the communication channels
Since the createdservice is acting as SAP ECC’s BAPI, normally we use RFC communication channel or SAP Proxy to interact with SAP, but it easier to change the communication channel type to SOAP in order to connect to the mock service. So a SOAP receiver is to be created.
Please note that the Target URL of the SOAP Receiver is pointed to newly created service. That means SAP PI will transfer every transaction that enter this interface to your computer.
Update the Receiver Agreement to use the created SOAP receiver.
Check if the communication channels, both sender and receiver, are updated and running.
2) Test and check the result
You can use normal SOAP sender and structure to send the message to SAP PI and see if the response message is as same as the prepared.
The message is sent through SAP PI to the created service.
There are many ways to simulate load transactions for SAP PI. A convenient method is using LOADUI which receive SOAPUI project file and test case. Following steps will show how to create constant load transactions from mock sender to SAP PI.
1) Create SOAPUI test suite and test case
After editing the request message content and authentication of a request message in SOAPUI. Right-click at the Request entry and click “Add to TestCase”.
If there is no created test suite, SOAPUI will ask to create new one. After the test suite and test case are created, right-click at the root of the structure. Click “Save Project As” to save the XML file of SOAP UI Project.
Create the SOAPUI project XML file
2) Import SOAPUI Project to LOADUI
Create new project in LOADUI and import the project XML file to the soapUI runner component.
3) Necessary components for testing
Drag other necessary components such as generator and statistics panel to the stage and connect them together. Then run the program and check the result.