Download presentation
Presentation is loading. Please wait.
Published byAlexander Sanders Modified over 7 years ago
1
Module 6 Practical part: Creation of X-Road dataservice and client based on WSDL (.NET platform) Name Date
2
Preparations Internet Information Services (IIS) Server
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 Application Development Features .NET Extensibility ASP.NET .NET Framework Advanced Services WCF Services HTTP Activation
3
Preparations Application:
Use the WCF Service Application template Producer for creating the application. Remove the files created by default (IService1.cs, Service1.svc,Service1.svc.cs) Create a new folder for WSDL file with the name wsdl and add a sample file into it. Select the project Producer and challenge the context menu, where select Add->New Folder -> folder name: wsdl Select the project Producer and challenge the context menu, where select Add->Existing item-> WSDL file. Add a reference to the WcfExtensions.dll file. References -> in the context menu, Add reference -> in displayed window Reference Manager, select Assemblies ->Browse -> select WcfExtensions.dll file.
4
Application Adapter of service provider: code generation
Add service data classes and interface: Click the References button in the project subdirectory In the context menu, select Add service reference. In the field Address, enter the file name of the service description with the directory name e.g.: F:\Workspace\NET\XRoad\Samples\Producer\wsdl\person_register.wsdl In the field Namespace, enter a suitable name for the namespace of objects of the service. e.g.: pplService Click 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
6
Application Add the file realising the service interface:
In the application context menu, select ‘Add’ -> ‘New Item ...’ -> ‘WCF Service’ -> PeopleRegister.svc IPeopleRegister.cs is generated, which must be removed. Specify the generated interface for the created class using System; using Producer.pplService; namespace Producer { public class PeopleRegister : pplService.person_register public personListResponse personList(personListRequest1 request){ throw new NotImplementedException(); }
7
Application Add a simple realisation to personList
public personListResponse personList(personListRequest1 request){ return new personListResponse{ client = request.client, service = request.service, id = request.id, protocolVersion = request.protocolVersion, userId = request.userId, response = new personListResponseResponse{ person = new person{ birthDate = DateTime.Now, firstName = "Juhan", lastName = "Tamm", personContact = new contact{ address = "Metsa 12", = new phone = new []{"333333"} } };
8
Application Add DispatchByBodyElementBehavior to the class realising the service Each operation must be separately marked with the attribute DispatchBodyElemen [DispatchByBodyElementBehavior] public class PeopleRegister : pplService.person_register { [DispatchBodyElement("personList", " public personListResponse personList(personListRequest1 request) ... } [DispatchBodyElement(“operationName", “producerNamespace")] public OperationResponseMessage operationName(OperationRecuestMessage message)
9
Application Apply WCF extension in Web.Conf file:
Register a new extension (Microsoft Service Configuration Editor) Select Advanced ->Extensions ->behavior element extensions ->New ... In column Name:CustomMessageFilter. In column Type, select EndpointBehaviorExtension type located in WcfExtensions.dll Create a new service Endpoint Behaviour by using registered extension Select Advanced ->Endpoint Behaviors -> New Endpoint Behavior Configuration Name: CustomMessageFilterBehavior In the area Behavior element extension position, click Add ... Add CustomMessageFilter element.
10
Application Register service endpoint
Service ->Create a New service Service type – click Browse … and select Producer.PeopleRegister type in Producer.dll Next Contract field must be automatically filled. Select New binding configuration Communication mode : HTTP Method of interoperability: Basic Web Services interoperability Leave the field Address empty Finish Specify already created Endpoint Behaviour for new service endpoint. Service ->Producer.PeopleRegister ->Endpoints ->(Empty Name) BehaviorConfiguration: CustomMessageFilterBehavior
12
Application Before using the service it must be placed on a IIS server: Compile the application Select an application file and in the context menu click Publish. Publish Web window appears. Select Custom and name the profile. Publish method:File System Target location: create and select new directory in IIS application folder e.g.: C:\inetpub\wwwroot\persons Next Configuration: Release Next->Publish
13
Publish service on IIS server
Compile the application Select an application file and in the context menu click Publish. Publish Web window appears. Select Custom and name the profile. Publish method:File System Target location: create and select new directory in IIS application folder e.g.: C:\inetpub\wwwroot\persons Next Configuration: Release Next->Publish Create a new directory on the IIS server. Open IIS Manager 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
14
Creation of X-Road client application
Use Console Application template for creating the Consumer application. Add service data classes and interface: Click the References button in the project subdirectory In the context menu, select Add service reference. In the field Address, enter the service description file with the directory name e.g: F:\Workspace\NET\XRoad\Samples\Producer\wsdl\person_register.wsdl In the field Namespace, enter a suitable name for the namespace of objects of the service. e.g: pplService Click 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
15
Adapter of service provider: setting endpoint
Endpoint settings of the client must be changed in Web.Conf file: Change address (Microsoft Service Configuration Editor): Select Client ->Endpoints -> by default (Empty name) ->Address Enter correct address of service provider
16
Adapter of the service provider: creating the client
Create an object of the client and challenge the service methods: Header objects: var protocolVersion = "4.0"; var id = Guid.NewGuid().ToString(); var userId = "EE "; var service = new XRoadServiceIdentifierType { xRoadInstance = "ee-dev", memberClass = "COM", memberCode = " ", subsystemCode = "aktorstest-db01", serviceCode = "personList", serviceVersion = "v1", objectType = XRoadObjectType.SERVICE }; var client = new XRoadClientIdentifierType { subsystemCode = "misp2-01", objectType = XRoadObjectType.SUBSYSTEM
17
Create an object the of client and challenge the service methods:
Request the object and client object var request = new personList { request = new personListRequest { givenName = "", surname = "Tamm" } }; var serviceClient = new pplService.aktorstestPortTypeClient(); var response = serviceClient.personList( client: ref client, service: ref service, protocolVersion: ref protocolVersion, id: ref id, userId: ref userId, personList1: request);
18
Thank You! First name Surname firstname.surname@amet.ee
The training materials for developers of X-Road interfaces have been compiled with funding from the structural funds support scheme “Raising Public Awareness about the Information Society” of the European Regional Development Fund.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.