How to SOAP as web service (import)

How to SOAP as web service (import)?

Step-by-step guide

Prerequisites: An endpoint and some methods running on SoapUI 5.5.0, Studio

All the steps on how to setup a endpoint are described in the article: "How to SOAP on http/https"

1. Once everything from prerequisites are in place open Studio and start by creating a new Library!

1.jpg

2. From main window use New Service function:

2.jpg

3. On File or Link field copy/paste the address of your endpoint WSDL (ie: https://orch2018:8443/mockNumberConversionSoapBinding?WSDL)

Usually there's no need to specify any Namespace as this will be auto-filed on Loading. (press Load)

3.jpg

4. After loading check operations available, namespace is automatically completed and will be used later on. Click Save.

4.jpg

5. On the Project tab a new service should be created under Services with a json describing operations, namespace etc.

5.jpg

6. Also in Activities tab a new section with the Namespace name will be created.

6.jpg

7. Drag both operation to a new sequence and create variables for both operations (below example shows only 1 set of variable for operation NumberToWords):

7.jpg

Easiest way is to use CTRL+K command on properties tab and create a Request and a Response varible. This must be completed for all included operations. Note the EndPoint link present and the Variable Type definition.

The variable type definition is defined in the web service and it's real type falls back to a supported .net primitive ones (as shown later on).

8. Checking the above info in the SoapUI 5.5.0 we notice the following information:

8.jpg

The endpoint should be running and the response for service can be altered (as shown above) and tested on the correct address. In this case a call to NumberToDollars will respond NbrTo$$ Eug_test, and the NumberToWords will respond NbrToWords_Eugentest.

Also we note the body of the request, on one case the type of message is web:dNUM and the other is web:ubiNum. (We'll explain those below).

9. As mentioned above we'll need to define 1 Response variable and 1 Request variable for each of the operation (4 total for this example), and those should respect the type as described by the service. Looking at Imports in the project, notice the NumberConversion which is our namespace instance in which variables must be instantiated.

9.jpg

To complete our variable definition, in the default section of the variable type new . and notice the suggestions classes ![Class Icon](upload://q6guxI7vTfT9tubDqyKAItD9l3A.gif)NumberToWords . Here only requests are needed since the response will be populated from endpoint.

Example : new NumberConversion.NumberToWordsRequest

10.jpg

10. Before each operation defined, use an Assign activity and specify the request variable previously defined (here Request1N2W). By accessing object properties the field (variable)![Field Icon](upload://dSOI4aOYAQ23JVCQ1QBQwcX6mUJ.gif)name will be shown on autocomplete.

Example Request1N2W.ubiNum

11.jpg

Notice that ubiNum is in fact a Ulong type which is defined my Microsoft as part of System.Uint64 .NET type. Check here

Also this is a Unsigned 64-bit integer (unsignedLong) as defined by the host of endpoint. Check here

Checking on Uint64 struct we notice that is has a ![Declaration Symbol](upload://jWatLky3qQIlrtzJhn5OxRhLY0Q.gif)Parse(String) method defined. Check here

This is also visible in project on autocomplete:

12.jpg

To complete the value definition use ![Declaration Symbol](upload://jWatLky3qQIlrtzJhn5OxRhLY0Q.gif)Parse("string") method and put in a number:

13.jpg

11. After the operation definition, we will need to verify the response, and in this example a LogMessage activity was used.

Similar with above example it will show a custom field![Field Icon](upload://dSOI4aOYAQ23JVCQ1QBQwcX6mUJ.gif)NumberToWordsResult:

14.jpg

12. Our final view over the first operation section will be similar with this.

15.jpg

Unless there's no other operation used, the workflow can stop at this point and a request>response test can be made.

13. Assigning variables for the second operation (NumberToDollars). At first inspection we see that ![Field Icon](upload://dSOI4aOYAQ23JVCQ1QBQwcX6mUJ.gif)dNum custom field/variable is used.

16.jpg

From host definition on this notice the definition: decimal

Also from here we can see that Decimal constructor accepts UInt64, so the same ![Declaration Symbol](upload://jWatLky3qQIlrtzJhn5OxRhLY0Q.gif)Parse(String) method can be used and for string a decimal number (can be anything in this example since the response was modified for the mock endpoint).

17.jpg

14. Same as first operation section, current operation needs an output after it's body. This time the second variable ![Field Icon](upload://dSOI4aOYAQ23JVCQ1QBQwcX6mUJ.gif)NumberToDollarsResult will be used:

18.jpg

This ends the setup for the 2 operations in our workflow.

15. Last step - Testing the workflow in order to check the responses for both operations:

Notice that output log response is the same as the responses set in step 8.

19.jpg

**Note: Full example added including dependencies, but endpoint service must be recreated.

2 Likes

A post was split to a new topic: What is the error fix for " CREATE_INVOICEDOCUMENT: Missing wsse:Security in SOAP Header"