- Este debate tiene 1 respuesta, 2 mensajes y ha sido actualizado por última vez el hace 8 años por
Cristina Nicolàs.
-
AutorEntradas
-
30 junio 2018 a las 10:02 #6067
Navision2018
ParticipanteBuenos días a todos, necesito ayuda vuestra con el problema que tengo y que necesito sacar adelante.
Desde Navision 2018 tengo que llamar a un Web Services externo y pasarle una variable de texto con varios campos separados por el sigo #,
En estos momentos tengo el siguiente código realizado pero al entrar en el Web Services, la variable llega vacía.
Os adjunto el código que llama al Web Services por si veis lo que tengo mal o por si se ha de implementar de otra forma.
Espero noticias vuestras.
Un saludo y gracias.
Miguel
[code]
LOCAL CreateQuizWeb(pRecordQuizs : Record Quizs) ReturnValue : Boolean
Window.OPEN(‘Creando encuesta…’);data := ‘<soap:Envelope xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:tem=”http://tempuri.org/”><soap:Header/><soap:Body><tem:CrearEncuesta>’;
data += ‘<tem:pCourse>’ + pRecordQuizs.”Course No.” + ‘#’ + ‘</tem:pCourse>’;
data += ‘<tem:pCall>’ + pRecordQuizs.”Call No.” + ‘#’ + ‘</tem:pCall>’;
data += ‘<tem:pLine>’ + FORMAT(pRecordQuizs.”Line No.”) + ‘#’ + ‘</tem:pLine>’;
data += ‘<tem:pQuizName>’ + pRecordQuizs.”Quiz name” + ‘#’ + ‘</tem:pQuizName>’;
data += ‘<tem:pQuestion1>’ + pRecordQuizs.”Question 1″ + ‘#’ + ‘</tem:pQuestion1>’;
data += ‘<tem:pQuestionType1>’ + FORMAT(pRecordQuizs.”Question type 1″) + ‘#’ + ‘</tem:pQuestionType1>’;
data += ‘<tem:pQuestionPoint1>’ + FORMAT(pRecordQuizs.”Question Point 1″) + ‘#’ + ‘</tem:pQuestionPoint1>’;
data += ‘<tem:pQuestion2>’ + pRecordQuizs.”Question 2″ + ‘#’ + ‘</tem:pQuestion2>’;
data += ‘<tem:pQuestionType2>’ + FORMAT(pRecordQuizs.”Question type 2″) + ‘#’ + ‘</tem:pQuestionType2>’;
data += ‘<tem:pQuestionPoint2>’ + FORMAT(pRecordQuizs.”Question Point 2″) + ‘#’ + ‘</tem:pQuestionPoint2>’;
data += ‘<tem:pQuestion3>’ + pRecordQuizs.”Question 3″ + ‘#’ + ‘</tem:pQuestion3>’;
data += ‘<tem:pQuestionType3>’ + FORMAT(pRecordQuizs.”Question type 3″) + ‘#’ + ‘</tem:pQuestionType3>’;
data += ‘<tem:pQuestionPoint3>’ + FORMAT(pRecordQuizs.”Question Point 3″) + ‘#’ + ‘</tem:pQuestionPoint3>’;
data += ‘<tem:pQuestion4>’ + pRecordQuizs.”Question 4″ + ‘#’ + ‘</tem:pQuestion4>’;
data += ‘<tem:pQuestionType4>’ + FORMAT(pRecordQuizs.”Question type 4″) + ‘#’ + ‘</tem:pQuestionType4>’;
data += ‘<tem:pQuestionPoint4>’ + FORMAT(pRecordQuizs.”Question Point 4″) + ‘#’ + ‘</tem:pQuestionPoint4>’;
data += ‘<tem:pQuestion5>’ + pRecordQuizs.”Question 5″ + ‘#’ + ‘</tem:pQuestion5>’;
data += ‘<tem:pQuestionType5>’ + FORMAT(pRecordQuizs.”Question type 5″) + ‘#’ + ‘</tem:pQuestionType5>’;
data += ‘<tem:pQuestionPoint5>’ + FORMAT(pRecordQuizs.”Question Point 5″) + ‘#’ + ‘</tem:pQuestionPoint5>’;
data += ‘<tem:pQuestion6>’ + pRecordQuizs.”Question 6″ + ‘#’ + ‘</tem:pQuestion6>’;
data += ‘<tem:pQuestionType6>’ + FORMAT(pRecordQuizs.”Question type 6″) + ‘#’ + ‘</tem:pQuestionType6>’;
data += ‘<tem:pQuestionPoint6>’ + FORMAT(pRecordQuizs.”Question Point 6″) + ‘#’ + ‘</tem:pQuestionPoint6>’;
data += ‘<tem:pQuestion7>’ + pRecordQuizs.”Question 7″ + ‘#’ + ‘</tem:pQuestion7>’;
data += ‘<tem:pQuestionType7>’ + FORMAT(pRecordQuizs.”Question type 7″) + ‘#’ + ‘</tem:pQuestionType7>’;
data += ‘<tem:pQuestionPoint7>’ + FORMAT(pRecordQuizs.”Question Point 7″) + ‘#’ + ‘</tem:pQuestionPoint7>’;
data += ‘<tem:pQuestion8>’ + pRecordQuizs.”Question 8″ + ‘#’ + ‘</tem:pQuestion8>’;
data += ‘<tem:pQuestionType8>’ + FORMAT(pRecordQuizs.”Question type 8″) + ‘#’ + ‘</tem:pQuestionType8>’;
data += ‘<tem:pQuestionPoint8>’ + FORMAT(pRecordQuizs.”Question Point 8″) + ‘#’ + ‘</tem:pQuestionPoint8>’;
data += ‘<tem:pQuestion9>’ + pRecordQuizs.”Question 9″ + ‘#’ + ‘</tem:pQuestion9>’;
data += ‘<tem:pQuestionType9>’ + FORMAT(pRecordQuizs.”Question type 9″) + ‘#’ + ‘</tem:pQuestionType9>’;
data += ‘<tem:pQuestionPoint9>’ + FORMAT(pRecordQuizs.”Question Point 9″) + ‘#’ + ‘</tem:pQuestionPoint9>’;
data += ‘<tem:pQuestion10>’ + pRecordQuizs.”Question 10″ + ‘#’ + ‘</tem:pQuestion10>’;
data += ‘<tem:pQuestionType10>’ + FORMAT(pRecordQuizs.”Question type 10″) + ‘#’ + ‘</tem:pQuestionType10>’;
data += ‘<tem:pQuestionPoint10>’ + FORMAT(pRecordQuizs.”Question Point 10″) + ‘</tem:pQuestionPoint10>’;
data += ‘</tem:CrearEncuesta></soap:Body></soap:Envelope>’;
stringContent := stringContent.StringContent(data,encoding.UTF8,’text/xml’);
ReturnValue := TRUE;
ReturnValue := CallRESTWebService(‘http://w2012serverr2.cloudapp.net:150/wskschoolquiz.asmx’,’wskschoolquiz.asmx?op=CrearEncuesta’,’POST’,stringContent,HttpResponseMessage);
IF NOT ReturnValue THEN ERROR(‘No se ha podido crear la encuesta’);
Window.CLOSE;LOCAL [TryFunction] CallRESTWebService(BaseUrl : Text;Method : Text;RestMethod : Text;VAR HttpContent : DotNet “System.Net.Http.HttpContent”;VAR HttpResponseMessage : DotNet “System.Net.Http.HttpResponseMessage”)
HttpClient := HttpClient.HttpClient();
HttpClient.BaseAddress := Uri.Uri(BaseUrl);CASE RestMethod OF
‘GET’: HttpResponseMessage := HttpClient.GetAsync(Method).Result;
‘POST’: HttpResponseMessage := HttpClient.PostAsync(Method,HttpContent).Result;
‘PUT’: HttpResponseMessage := HttpClient.PutAsync(Method,HttpContent).Result;
‘DELETE’: HttpResponseMessage := HttpClient.DeleteAsync(Method).Result;
END;HttpResponseMessage.EnsureSuccessStatusCode(); // Throws an error when no success
[/code]
2 julio 2018 a las 15:29 #6080
Cristina NicolàsSuperadministradorHola,
Espero que alguien pueda contestar a esta pregunta.
Yo he utilizado los WebServices de NAV pero siempre siendo NAV quien los publica y una aplicación externa la que los llama. Nunca he llamado a WebServices externos desde NAV.Un saludo,
Cristina Nicolàs -
AutorEntradas
- Debes estar registrado para responder a este debate.