prepareWebServiceCall Event

Summary

Event that occurs before any web service request is made to the server to allow the user to add or modify headers.

Syntax

TypeScript
JavaScript
Object.defineProperty(WebServiceCall, 'prepareWebServiceCall',  
	get: function(), 
	set: function(value) 
) 
static prepareWebServiceCall: LeadEvent; 

Remarks

A user can add a handler to this event, which will fire before every web service request the Leadtools.Controls.Medical.js library makes.

For example, this event is fired from a resulting web service call from setting the MRTIImage.ImageUri property to a URI.

The event data is of type PrepareWebServiceCallEventArgs.

Assign the headersObject a javascript object representing any headers that are to be added/modified to the web.

As an example, this event can be used to add an authorization bearer token by doing the following:

  1. Add this line of code to your code (for example at the end of app.run in MedicalViewerDemo.js).

    lt.Controls.Medical.WebServiceCall.add_prepareWebServiceCall(myWebServicePreparationHandler); 
  2. Define this function

    function myWebServicePreparationHandler(args) { 
       args.headersObject = { 'Authorization': 'Bearer MY_BEARER_TOKEN' }; 
       args.cancel = false;  
        } 

The following is a second example that adds two headers to the web service call:

	function myWebServicePreparationHandler(args) { 
	   args.headersObject = { 
        'Content-Type': 'application/terry', 
        'Authorization': 'Bearer YOUR_TOKEN_HERE' 
    } 

Event Data

Member Value
sourceClass Name of the class making the request. For example, this will be MRTIImage for MRTIImage.imageUri.
sourceMethod Name of the method making the request. For instance, this will be imageUri for MRTIImage.imageUri.
cancel Can be set to true by the event handler to cause the request to return immediately.
serviceCall A string which contains the full path and all parameters of the service call. For example, serviceCall might contain the value "http://localhost/MedicalViewerServiceAsp23/api/retrieve/GetImageTile?auth=BXRlcnJ56bBNY2Nu3Ej%2B%2F%2F8PAAA%3D&instance=1.2.840.114257.3.6.5.5.18900282&frame=0&x=768&y=256&w=42&h=120&xr=810&yr=376&wldata=true"
headersObject This is a JavaScript object that contains zero or more properties, where each property is a key-value pair. These pairs represent the headers of a web service call. Keys are strings that represent the header names, and values are strings that represent the header content. This object is used to configure the HTTP headers sent in any web service request, facilitating the communication of additional information such as content types, authentication tokens, and other metadata required by the server.

Requirements

Target Platforms

See Also

WebServiceCall Class

WebServiceCall Members

Leadtools.Controls.Medical Namespace

Help Version 23.0.2024.5.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls.Medical Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.