ShowTable of Contents
Introduction
Any issues that arise from using web services normally can be traced back to the data sent via SOAP. SoapUI is a very powerful application and this walkthrough only covers the basics to capture the SOAP request and response.
Initial Setup
You will need the following to complete this walkthrough.
Setting up the SoapUI project
1. Launch SoapUI.
2. Select the "File -> New Project" menu option.
3. Fill out the following options on the dialog (leave the rest as default). Change SERVER_NAME to match your servers name (eg. localhost, whatever.lan ).
-
Project Name: Test Hello World
-
Initial WSDL/WADL : http://SERVER_NAME/WS.nsf/HWLSP?WSDL
-
Create Requests: SELECTED
-
Create MockService: SELECTED
4. Click OK.
5. SoapUI will load in the WSDL file and then display the "Generate MockService" dialog. Click OK.
6. For the "Specify name of MockService to create" dialog just click OK.
Your project is now created!
Testing the web service provider
1. In SoapUI expand your projects outline and double click the "Request 1" item.
2. The "Request 1" window will open up and has two sub windows in it. One is the SOAP request and should contain the following code.
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:DefaultNamespace">
<soapenv:Header/>
<soapenv:Body>
<urn:HELLO soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<TXT xsi:type="xsd:string">?</TXT>
</urn:HELLO>
</soapenv:Body>
</soapenv:Envelope>
The "?" is the value that will be sent to the web service. Change that to "SOAP Test". Like as follows.
<TXT xsi:type="xsd:string">SOAP Test</TXT>
The second sub window on the right is the SOAP response. It will be blank.
3. Click the run icon (Green Arrow). The SOAP response will show the response sent back by the server.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Body>
<ns1:HELLOResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:DefaultNamespace">
<HELLOReturn xsi:type="xsd:string">Hello SOAP Test</HELLOReturn>
</ns1:HELLOResponse>
</soapenv:Body>
</soapenv:Envelope>
Testing the web service consumer
1. In SoapUI expand your projects outline and double click the "Response 1" item.
2. Paste in the SOAP response you got from testing the provider in the previous section.
3. Close the "Response 1" window.
4. in the SoapUI outline double click the "DominoSoapBinding MockService". This will open the Mock Service window.
5. Select the settings icon (spanner + screwdriver).
6. Make sure the host is set to your servers name and click OK. The settings in this dialog define the endpoint for your mock provider.
Translates to:
http://SERVER_NAME:8088/mockDominoSoapBinding
7. Click the run button. You will see the message "running on port 8088".
8. Open WS.nsf on your server in Domino Designer.
9. Expand the outline and select the Agents item.
10. Select the "TestJava" and copy and paste it. This will create "Copy of TestJava" agent.
11. Open "Copy of TestJava" agent.
12. Open the "JavaAgent.java" file.
13. Just after where stub is created add the following line to the code to define your endpoint (Change SERVER_NAME to your servers name).
stub.setEndpoint("http://SERVER_NAME:8088/mockDominoSoapBinding");
The final file should look like this.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
HwProvider stub = new HwProviderServiceLocator().getDomino();
stub.setEndpoint("http://SERVER_NAME:8088/mockDominoSoapBinding");
String answer = "" + stub.HELLO("world");
System.out.println("The answer is : " + answer);
} catch(Exception e) {
e.printStackTrace();
}
}
}
14. Close and save the JavaAgent.java file.
15. Close and save the "Copy of TestJava" agent.
16. Right click on the agent and select "Run".
17. When the agent completes select "Tools -> Show Java Debug Console" menu option. You will see the message "The answer is : Hello SOAP Test" displayed.
18. Go back to SoapUI and you will that your SOAP request has been logged. Double click it.
19. When the message viewer window opens you can see the web service consumers SOAP request which should be like as follows.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:HELLO soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:DefaultNamespace">
<TXT xsi:type="xsd:string">world</TXT>
</ns1:HELLO>
</soapenv:Body>
</soapenv:Envelope>