Preparation of the operating environment of the application – Internet
Information Services (IIS).

First check if all necessary Windows components
are activated. Otherwise install/add the lacking components. Open by using Control
Panel Programs and Features and select Turn Windows features on or off.

Switch on the following components:

Common HTTP Features

Directory Browsing and Static Content

As the development of the interfacing component
takes place with the ‘Top Down’ method, the WSDL file of the dataservice must
be published on the server. By adding this component, we grant to the security
server access to static files. This is used by users of the service as well as
security server administrators.

Application Development Features

.NET Extensibility

ASP.NET

X-Road security servers do not transmit
SOAPAction header. Therefore, it must be assumed that interfacing components
manage incoming SOAP messages by body sub-element. An extension must be
added in the WCF framework which enables the same behaviour, SOAPAction header
is used by default. A description of the solution to this problem will be
provided below.

.NET Framework Advanced Services

ASP.NET

WCF Services

HTTP Activation

Note! WCF or ASP.NET services may generate the WSDL
file automatically if a request is submitted to the address

http://localhost:port/teenusenimi?wsdl.

However, automatically generated files lack
obligatory elements of the X-Road namespace. Therefore, the original service
description file used for generating the code must be published.

For the realisation of the described steps, the following console command can also be used to install all necessary components.

For the realisation of the described steps, the following console command can also be used to install all necessary components:

We generate a workspace in Visual Studio,
where we start making the application. The first application is an interfacing
component of the service provider or Producer, for which we use the WCF
Service Application template.

We create a new project and select the required template:

Delete:

IService1.cs,

Service1.svc

Service1.svc.cs

the files to have a clean application, and add
necessary files. For the service description file, we should create a directory
with the name ‘wsdl’ and add the previously prepared WSDL file into it.

Enter
a suitable name for the namespace of service objects in the field Namespace.

e.g.: pplService

Click
the Advanced button

Ensure
that Allow generation of asynchronous operations check box is not ticked
(X-Road does not support asynchronous methods)

Tick
the check box Always generate message contracts

Click OK

As a result of this step, pplService folder
should be created under the Service Reference directory.

Note!In the future, if WSDL file has been changed and data types also need updating,pplService must be selected in the application in Service Reference directoryand Configure Service Reference ... in context menu, and then select OK.Thus, svcutil.exe programme is activated and code is created from zero.

This way, service client code is added to the
application, and the first steps are similar when creating a service client
application.

Why does a service provider need this? For
creating a service interface and classes of objects used in the service.

Created objects can
be viewed in Object Browser:

Interface of service provider

Class of the user of service

Objects in the service

Objects of service request and X-Road
message headers.

Note!After adding service reference, the element <client> appears in Web.conf file.As the service provider does not use it, this can be removed.

The service can return a simple static
response, and in order to change the management method of WCF messages, we add
a DispatchByBodyElementBehavior attribute to the class realising the service, which
enables to register operations in request administrator list. Each operation must
be separately marked with the attribute DispatchBodyElement with two arguments:

personList – name of the root element of a SOAP
message (name of service operation)

http://persons_register.x-road.ee – namespace
of service provider (same as in WSDL file).

Furthermore, a WCF extension must be registered
in the Web.Conf file. For changing the configuration file, it is possible to
use the interface Microsoft Service Configuration Editor integrated in
Visual Studio. Select file Web.config and in the context menu Edit WCF
Configuration.

Note! Before using Type Browser, the application must be compiled. Type Browser parses compiled files to find type classes. Therefore, it may lack recently created classes.

Register new extension

Select Advanced->Extensions->behavior
element extensions->New ...

Column Name:CustomMessageFilter.

In column Type, select EndpointBehaviorExtension
type located in WcfExtensions.dll

In the Sites context menu, select Add
Website. A new window appears where directory configuration must be entered

Sitename: persons

Application Pool: select the pool
where .NET framework version is the same/later than the application target framework.

Physical path: folder selected in
step 1.d

IP address: IP address of the local
machine

OK

After these steps, service should be available from the IIS server of the
local machine. (e.g.: http://172.25.200.47/PeopleRegister.svc)

6.2.6
Creation of X-Road client application

Add the new application under the existing solution with which service will be
used (using e.g. Console Application template). First, add a reference to our
service and generate the client code and the objects of data model. There are
several options for doing this:

Use the command line in the programme
vcutil.exe and add the resulting files to the application. If the interface
code should be changed, the operation must be repeated.1. Activate the following command on the
command line:

svcutil /l:cs /o:IPersonService.cs /noConfig persons_register.wsdl

/l: – Language, by default Csharp

/o: – Result file name, by default WSDL file
name

/noConfig – Configuration file is not required.
The last parameter is the WSDL file name