Tag: Hypertext Transfer Protocol (HTTP)

Create Webservice Mock Service with SOAP UI

Create Webservice Mock Service with SOAP UI

Scenario

If you want to see the message which is send by a SOAP, REST, XI or HTTP Receiver Communication Channel, you can use SOAP UI to create a Mock Service to log the headers and payloads of the message.

Create Mock Service with SOAP UI

  1. Create a new Project or open an existing one
  2. Right click on your request and select “New REST/SOAP MockService” (SOAP service will respond with a SOAP envelope, REST service will send back an empty response) and name it
  3. If you like to specify port and path, click on the gearwheel and specify both. Otherwise your endpoint will be listening on https://localhost:8080/

    SOAP UI: Configure Mock Service parameters
    SOAP UI: Configure Mock Service parameters
  4. Open the “OnRequest Script” Tab and paste the following line into the editor
    log.info(mockRequest.getRequestContent())
  5. Open the “Script Log” Tab and start your Mock Service with the green play button

    SOAP UI Mock Service: Log Payload of requests
    SOAP UI Mock Service: Log Payload of requests

Configure Receiver Communication Channel

  1. Find out your local IP Address (for example with this website)
  2. Make sure that your PC is reachable from PI (Firewall)
  3. Add your IP Address with the above configured port and path to the URL of your Receiver Communication Channel
  4. Send a request to your endpoint. The payload will be shown in the “Script Log”

Additional options

You can use the full scope of Groovy to write your scripts. Please find below two useful snippets to log your requests.

To log the headers use:

log.info(mockRequest.getRequestHeaders())

To write the request data into a file use:

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def projectroot = groovyUtils.projectPath
def inputFile = new File(projectroot + "\\request.txt")

log.info("Writing request to file: " + projectroot + "\\request.txt")
inputFile.setBytes(mockRequest.getRawRequestData())

For more information of the mockRequest class in SOAP UI, check the class documentation.

Also it is possible to send custom responses, please check the SOAP UI Documentation for more information.

Generate WSDLs and decoded URLs for webservices

Generate WSDLs and decoded URLs for webservices

When creating an Interface with SAP Process Integration or SAP Process Orchestration which provides a webservice, you need the WSDL file or at least the URL of your webservice. Otherwise, your partner doesn’t know how to connect to your webservice.

Generate WSDL file

SAP PI and PO has a great feature do generate Web Service Description Language (WSDL) files for configurations with HTTP, XI, SOAP or WS Sender Communication Channels.

To generate a WSDL file:

  1. Open an Integrated Configuration (ICO) (or a Sender Agreement) in the Integration Builder, which is in status “Active”
  2. Click on “Integrated Configuration” in the top menu
  3. Click on “Display WSDL”
Detail View of Integrated Configuration

Detail view of Integrated Configuration (ICO) in Integration Directory (DIR)

A popup should open which displays the WSDL file and an URL to the WSDL file. Now, you can either download the file, use the URL to the WSDL file or directly get the information you need.

Get webservice URL

You can provide the whole WSDL file to your partner or just the URL. If you need the URL only, scroll to the end of the WSDL file . There you can find the HTTP and the HTTPS ports with the webservice URL in the location attribute of the address element. It looks like:

https://pisystem:50001/XISOAPAdapter/MessageServlet?senderParty=&senderService=service&receiverParty=&receiverService=&interface=SI_out&interfaceNamespace=urn%3Anamepspace

Shows Display WSDL window with address section highlighted in Integration Directory (DIR)
Display WSDL window – address section highlighted

Depending on you system configuration and your network structure, you maybe have to change domain and port of your URL before you can provide it to your partner. In case there is a Web Application Firewall, a Web Dispatcher, a Reverse Proxy or something similar in place, you should ask your system administrator for the correct domain and port. If you are communicating over an unprotected network, like the internet, you should always use SSL encryption.

Decode webservice URL

Due to different implementations of URL processing it is sometimes necessary to decode the URL, provided in the WSDL file. For example for the Chrome browser extension Boomerang you need to decode the URL before you can successfully connect to your webservice. If you do not know how your application handles URLs you can test the normal and the decoded URL. For one URL you will get an error like this:

com.sap.aii.af.service.cpa.CPAObjectNotFoundException: Couldn’t retrieve inbound binding for the given P/S/A values: FP=;TP=;FS=null;TS=;AN=null;ANS=null;

To get the decoded URL, just paste your URL in the textbox below and click on the “Decode URL” button.


If you are trying to reach the webservice in a browser you should see something like this:

Message Servlet is in Status OK

Status information:

Servlet com.sap.aii.adapter.soap.web.MessageServlet (Version $Id: //tc/xpi.adapters/NW731EXT_15_REL/src/_soap_application_web_module/webm/api/com/sap/aii/adapter/soap/web/MessageServlet.java#1 $) bound to /MessageServlet
Classname ModuleProcessor: null
Lookupname for localModuleProcessorLookupName: localejbs/ModuleProcessorBean
Lookupname for remoteModuleProcessorLookupName: null
ModuleProcessorClass not instantiated
ModuleProcessorLocal is Instance of com.sun.proxy.$Proxy523
ModuleProcessorRemote not instantiated