Create a reusable part called ExternalFileServices.![]()
Adjust the reusable part definition to inherit ExternalServiceBase you defined earlier.![]()
Now redefine the SetupUrlBuilder method to add the path component for the files service.
Recall the URL of the file copy service: http://localhost:8080/lansa-tutorial/files/copy![]()
The base URL for file services' path has an additional path component 'files'. So in the SetupUrlBuilder method of the ExternalFileServices, you need to append 'files' 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( 'files' )
Endroutine
Let's now implement the copy method in our RDMLX reusable part.
Mthroutine Name(Copy)
* Parameters
Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#SourcePath)
Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#TargetPath)
* Variables
Define_Com Class(#XPRIM_UriBuilder) Name(#Url)
Define_Com Class(#XPRIM_HttpRequest) Name(#Request)
* Setup the URL's base properties
#COM_SELF.SetupUrlBuilder Urlbuilder(#Url)
* Add the 'copy' path component
#Url.AddPathComponent Pathcomponent('copy')
* Add the form parameters
#Request.Content.AddUrlEncodedFormValue Name('sourcePath') Value(#SourcePath)
#Request.Content.AddUrlEncodedFormValue Name('targetPath') Value(#TargetPath)
* Execute the HTTP request
#Request.DoPost Url(#Url)
Endroutine
Next: Retrieving Error Messages after Service Invocation