Skip to main content

Net

; Net(Def Version:1) (Implem Version:1)

module Net

uses aApplicationSession, aApplicationSessionContext, aDataDocument, aMethodDesc,
aWebServiceMiddleware, aWebServiceMethod, aLightObject, aWebInboundRequest, aDataAdapterFactory,
aType, aDataAdapterContext, aDataValue, aDataElement, aStringDocument, RequiredAnnotation


function wGetSystemAdapterFactory return aDataAdapterFactory external 'WIDEDLL.wGetSystemAdapterFactory'

function wDeserializeObject(value : aDataValue, _type : aType, context : aDataAdapterContext) return aLightObject external 'WIDEDLL.wDeserializeObject'

procedure wSerializeObject(obj : aLightObject, value : aDataValue, context : aDataAdapterContext) external 'WIDEDLL.wDeserializeObject'

function session return aApplicationSession external 'WIDEDLL.wCurrentSystemSession'

function sessionContext return aApplicationSessionContext external 'WIDEDLL.wCurrentSystemSessionContext'

procedure SetHTTPStatus([Required] doc : aDataDocument, status : Int4)
uses wAttributs

doc.SetAttribut(wAttributs.Status).SetInt(status)
endProc

function wTransformDataToHttpResponse(response : aDataElement) return aStringDocument external 'WIDEDLL.wTransformDataToHttpResponse'

procedure wNormalizeDataFromHttpRequest(request : aStringDocument) external 'WIDEDLL.wNormalizeDataFromHttpRequest'

procedure SendEvent(eventType : CString, eventData : aDataDocument)
session.SendEvent(eventType, eventData)
endProc

function SendInternalRequest(request : aWebInboundRequest) return aDataElement
return sessionContext.SendInternalRequest(request)
endFunc

function CreateMiddleware(object : aLightObject, method : aMethodDesc) return aWebServiceMiddleware
return sessionContext.CreateMiddleware(object, method)
endFunc

procedure MapMiddleware(path : CString, middleware : aWebServiceMiddleware)
sessionContext.MapMiddleware(path, middleware)
endProc

function CreateMethod(verbs : IDEName, object : aLightObject, methodDesc : aMethodDesc) return aWebServiceMethod
uses aWF_WebServiceHttpMethod

var method : aWF_WebServiceHttpMethod

if (methodDesc <> Nil) and (object <> Nil)
new(method)
if method.InitMethod(object, methodDesc)
return method.SetVerbs(verbs)
else
dispose(method)
endIf
endIf
endFunc

procedure MapMethod(path : CString, method : aWebServiceMethod)
sessionContext.MapMethod(path, method)
endProc

procedure MapInboundRoute(Route : CString, Verbs : CString, instance : aLightObject,
MethodDesc : aMethodDesc, IsPublic : Boolean)
uses aWebServiceHttpMethod

var method : aWebServiceHttpMethod

method = aWebServiceHttpMethod(CreateMethod(Verbs, instance, MethodDesc))
method.SetPublic(IsPublic)
MapMethod(Route, method)
endProc