+
+
Once you have sbt WSDL generating a soap client for you, it is quite straightforward to use. How you access it depends on the service and port names in the WSDL. Consider the following service section from a WSDL:
+
+
+
+
<wsdl:service name="HelloWorldService">
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorld">
+ <soap:address location="http://example.com/helloWorld"/>
+ </wsdl:port>
+</wsdl:service>
+
+
+
+
Assuming that the package name that the client was generated into is com.example
, Play will generate a service class called com.example.HelloWorldService
. This class is actually a Play plugin that allows you to configure the client, including configuring the address for each port to use.
+
+
+
Note that there are some situations where sbt WSDL won’t use the service name from the WSDL, these are when the name of the service conflicts with another class that it generated, such as the name of the service endpoint interface. In that case, sbt WSDL will append _Service
to the end of the service name, for example com.example.HelloWorldService_Service
.
+
+
+
Having located the service class, you can now get a port. In the above WSDL there is one port named HelloWorld
, and, according to the HelloWorldSoapBinding
(not shown above), this returns a service endpoint interface called HelloWorld
. To access the endpoint, simply have it injected into your components or controllers, like so in Scala:
+
+
+
+
class MyComponent @Inject() (helloWorldService: HelloWorldService) {
+ val client: HelloWorld = helloWorldService.helloWorld
+}
+
+
+
+
+
+
public class MyComponent {
+
+ private final HelloWorldService helloWorldService;
+
+ @Inject
+ public MyComponent(HelloWorldService helloWorldService) {
+ this.helloWorldService - helloWorldService;
+ }
+
+ public void someMethod() {
+ HelloWorld client = helloWorldService.getHelloWorld();
+ // use the client somehow
+ }
+}
+
+
+