You are here: Web Services > Consuming Web Services > Tutorial 3 - Interoperability with .NET Using Web Services > Writing your WindowsUserServices RDMLX Reusable Part

Writing your WindowsUserServices RDMLX Reusable Part

Create a reusable part called ExternalWindowsUserServices.

Adjust the reusable part definition to inherit ExternalWindowsServiceBase you defined earlier.

Now redefine the SetupUrlBuilder method to add the path component for the user services.

Recall the URL of the user services:

http://localhost:9001/user/

The base URL for user services' path has an additional path component 'user'. So in the SetupUrlBuilder method of the ExternalWindowsUserServices, you need to append 'user to the URL:

Mthroutine Name(SetupUrlBuilder) Options(*REDEFINE)

   * Invoke the ancestor's SetupUrlBuilder first

   #COM_ANCESTOR.SetupUrlBuilder UrlBuilder(#UrlBuilder)

   * Now this class' implementation

   #UrlBuilder.AddPathComponent( 'user' )

Endroutine

Let's now implement the Authenticate method in our RDMLX reusable part.

Mthroutine Name(Authenticate)

   * Parameters

   Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#Domain)

   Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#UserName)

   Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#Password)

   Define_Map For(*RESULT) Class(#PRIM_DC.UnicodeString) Name(#Result)

   * Variables

   Define_Com Class(#XPRIM_UriBuilder) Name(#Url)

   Define_Com Class(#XPRIM_HttpRequest) Name(#Request)

   Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Json)

   * Setup the URL's base properties

   #COM_SELF.SetupUrlBuilder Urlbuilder(#Url)

   * Add the 'authenticate' path component

   #Url.AddPathComponent Pathcomponent('authenticate')

   * Add the form parameters

   #Url.AddQueryString( 'domain' 'syd' )

   #Url.AddQueryString( 'username' 'tony' )

   #Url.AddQueryString( 'password' 'test' )

   * Execute the HTTP request

   #Request.DoGet Url(#Url)

   * Get the authentication result

   #Json.SetSourceHttpResponse( #Request.Response )

   #Result := #Json.ReadStringWithName( 'result' )

Endroutine

Next: Retrieving Error Messages after Service Invocation