# Wiki source code of SOAP-based Service

Last modified by uru on 2023/07/11 10:33
Export
Office Formats
Export as PDF Export as ODT Export as RTF
Other Formats

Select the pages to export:

select all/ none

Legend:
  Created Page
  Modified Extension Page
  Clean Extension Page

Export as HTML

Show last authors

author | version | line-number | content
--- | --- | --- | ---
|  | 1 | == How to Use the Service-Based Layout in Your Project ==
|  | 2 |
|  | 3 | One of the goals of KWebS is to provide the KIELER layout to a broader range of users by hiding its java nature behind a web service. As the server uses a SOAP web service, it describes the user interface in a platform independent way using the Web Service Description Language (WSDL). You can use this contract to automatically generate the code necessary to access the operations provided by KWebS. For example, if you have a java based project, you can use the tool wsimport:
|  | 4 |
|  | 5 | {{code}}
|  | 6 | wsimport -p my.kwebs.client -keep http://layout.rtsys.informatik.uni-kiel.de:9442/layout?wsdl
|  | 7 | {{/code}}
|  | 8 |
|  | 9 | Normally, {{code language="none"}}wsimport{{/code}} will derive the package where it puts the generated classes into from the XML name space declared in the contract, but this will in general not fit to your needs. You can declare a different package with the **-p** option, in the given example the classes will be generated to the package {{code language="none"}}my.kwebs.client{{/code}}. The {{code language="none"}}-keep{{/code}} option tells {{code language="none"}}wsimport{{/code}} not to delete the generated java sources after it has compiled them to class files. As a last option, {{code language="none"}}wsimport{{/code}} requires the contract from which it shall generate the code. This may be a file on your local computer, or as an alternative, {{code language="none"}}wsimport{{/code}} can download it from the internet. The public demo service of KWebS is located at **[[http:~~/~~/layout.rtsys.informatik.uni-kiel.de:9442/layout>>url:http://layout.rtsys.informatik.uni-kiel.de:9442/layout||shape="rect"]]**, and you can access its contract by adding {{code language="none"}}?wsdl{{/code}} to this location.
|  | 10 |
|  | 11 | After code generation, you have a bunch of java source and class files. They contain the code necessary for invoking the service-based layout. The most important classes are {{code language="none"}}LayoutService{{/code}} and {{code language="none"}}LayoutServicePort{{/code}}. You need them to create a //proxy// to the service:
|  | 12 |
|  | 13 | {{code theme="Eclipse" language="java"}}
|  | 14 | package my.kwebs.client;
|  | 15 |
|  | 16 | import java.net.URL;
|  | 17 | import javax.xml.namespace.QName;
|  | 18 |
|  | 19 | public class KWebSClient {
|  | 20 |
|  | 21 | // The endpoint address the service is bound to
|  | 22 | private static final String SERVICE_URL
|  | 23 | = "http://layout.rtsys.informatik.uni-kiel.de:9442/layout";
|  | 24 |
|  | 25 | // The qualified name of the service interface
|  | 26 | private static final String SERVICE_QNAME
|  | 27 | = "http://layout.rtsys.informatik.uni-kiel.de/layout";
|  | 28 |
|  | 29 | // The name of the service
|  | 30 | private static final String SERVICE_NAME
|  | 31 | = "LayoutService";
|  | 32 |
|  | 33 | /**
|  | 34 | * Entry point of the client application
|  | 35 | */
|  | 36 | public static void main(final String args[]) {
|  | 37 |
|  | 38 | try {
|  | 39 |
|  | 40 | // Connect to the service
|  | 41 | LayoutService layoutService = new LayoutService(
|  | 42 | new URL(SERVICE_URL + "?wsdl"),
|  | 43 | new QName(SERVICE_QNAME, SERVICE_NAME)
|  | 44 | );
|  | 45 |
|  | 46 | // Create a proxy to access its operations
|  | 47 | LayoutServicePort layoutServicePort = layoutService.getLayoutServicePort();
|  | 48 |
|  | 49 | // Create the serial notation of the source graph
|  | 50 | String graph = ...
|  | 51 |
|  | 52 | // Call the "graphLayout" operation of the service. As result you get the
|  | 53 | // serial notation of the layouted graph in the same serial notation as
|  | 54 | // you used for invoking the layout.
|  | 55 | String layout = layoutServicePort.graphLayout(
|  | 56 | graph, // the source model
|  | 57 | "de.cau.cs.kieler.kgraph", // we use the KGraph format
|  | 58 | null, // we want the result in KGraph format
|  | 59 | null // we don't declare any options
|  | 60 | );
|  | 61 |
|  | 62 | // Handle exceptions here
|  | 63 | } catch (final Exception e) {
|  | 64 | e.printStackTrace();
|  | 65 | }
|  | 66 |
|  | 67 | }
|  | 68 |
|  | 69 | }
|  | 70 | {{/code}}

# Quick Links

KIELER on GitHub
RTSYS Homepage

XWiki 14.4.7