From ec5b00bc567fec223f39b6aea73a342817aa51fd Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Wed, 23 Nov 2022 15:52:04 +0100 Subject: [PATCH] Update validator call for websockets. Signed-off-by: Dennis Labordus --- src/compas-services/CompasValidatorService.ts | 36 ++++++++++--------- src/validators/CompasValidateSchema.ts | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/compas-services/CompasValidatorService.ts b/src/compas-services/CompasValidatorService.ts index eaeff8481..d84b899c1 100644 --- a/src/compas-services/CompasValidatorService.ts +++ b/src/compas-services/CompasValidatorService.ts @@ -15,15 +15,6 @@ export function CompasSclValidatorService() { return CompasSettings().compasSettings.sclValidatorServiceUrl; } - function createRequest(doc: Document): string { - return ` - - - `; - } - function useWebsocket(): boolean { return CompasSettings().useWebsockets(); } @@ -35,23 +26,34 @@ export function CompasSclValidatorService() { doc: Document ): Promise { if (useWebsocket()) { - return websocket( - element, - 'CompasValidatorService', + const request = ` + + + `; + const svsUrl = getWebsocketUri(getSclValidatorServiceUrl()) + - '/validate-ws/v1/' + - type, - createRequest(doc) - ); + '/validate-ws/v1/' + + type; + + return websocket(element, 'CompasValidatorService', svsUrl, request); } + const request = ` + + + `; const svsUrl = getSclValidatorServiceUrl() + '/validate/v1/' + type; + return fetch(svsUrl, { method: 'POST', headers: { 'Content-Type': 'application/xml', }, - body: createRequest(doc), + body: request, }) .catch(handleError) .then(handleResponse) diff --git a/src/validators/CompasValidateSchema.ts b/src/validators/CompasValidateSchema.ts index 624223eeb..ffd7fc0dd 100644 --- a/src/validators/CompasValidateSchema.ts +++ b/src/validators/CompasValidateSchema.ts @@ -43,7 +43,7 @@ export default class CompasValidateSchema extends LitElement { private processValidationResponse(response: Document): void { const validationErrors = Array.from( - response.querySelectorAll('SclValidateResponse > ValidationErrors') ?? [] + response.querySelectorAll('ValidationErrors') ?? [] ); // Check if there are validation errors, if there are we will process them. if (validationErrors.length > 0) {