Kotlin, Software Development

Kotlin – SOAP Web Service

This post demonstrates how to create a simple SOAP Web Service with Kotlin. Moreover, it uses the same techniques we use to develop SOAP Web Services in Java.


We use the following items for this post.

    • Kotlin 1.1
    • Java Development Kit 8

Kotlin To Java public final methods

By default, methods in Kotlin classes become public final for the underlying Java 8 run time environment. For example, consider these Kotlin codes.

The codes above are equivalent to these Java codes and they will cause a runtime error. Therefore, we will modify the Kotlin class a bit later in this post.

Therefore, using public final methods in SOAP Web Services causes the following error. To fix this problem, simply avoid using public final methods in Kotlin for this case.

Our SOAP Web Service Codes In Kotlin

These are the complete codes for our sample web service. Note that we use the open keyword in our Kotlin class to ensure the JVM can extend it to create a SOAP Web Service. In the same Kotlin file, we create the main function to publish (or start) our web service at a specified port number.

Next, we can retrieve the WSDL to create a SOAP client in Kotlin. To do so, go to HTTP://localhost:8080/?wsdl.

Then, we can test our Web Service using a client in Kotlin.


Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like