Synergex / HarmonyCore

Harmony Core is a framework that consists of libraries, CodeGen templates, and conventions that enable you to expose Synergy logic and data as a RESTful web service using OData and ASP.NET Core
BSD 2-Clause "Simplified" License
23 stars 14 forks source link

"DataType":512 #368

Closed shiblydangdang closed 2 months ago

shiblydangdang commented 3 months ago

Guys

I'm back on HC now so apologies!

I've made some changes to a shim today and added a few parameters. I was getting this error.....

SYSTEM.INVALIDOPERATIONEXCEPTION: Invalid operation: Not a string at HARMONY.TRADITIONALBRIDGE.ROUTINEDISPATCHER.GETTEXT(@SYSTEM.TEXT.JSON.JSONELEMENT)@SYSTEM.STRING in RoutineDispatcher.dbl:line 8.684 at TRADITIONALBRIDGE.DISPATCHERS.ASP.V2_CORRSP_SAVE_DISPATCHER.DISPATCHINTERNAL(@SYSTEM.STRING,@SYSTEM.TEXT.JSON.JSONELEMENT,@JSON.DISPATCHSERIALIZER,@HARMONY.TRADITIONALBRIDGE.ROUTINEDISPATCHER) in aspMethodDispatchers.dbl:line 2.13407 at HARMONY.TRADITIONALBRIDGE.ROUTINESTUB.DISPATCH(@SYSTEM.STRING,@SYSTEM.TEXT.JSON.JSONELEMENT,@JSON.DISPATCHSERIALIZER,@HARMONY.TRADITIONALBRIDGE.ROUTINEDISPATCHER) in RoutineDispatcher.dbl:line 8.1199 at HARMONY.TRADITIONALBRIDGE.ROUTINEDISPATCHER.PROCESSCALLBLOCK(@SYSTEM.TEXT.JSON.JSONELEMENT,@JSON.DISPATCHSERIALIZER)I in RoutineDispatcher.dbl:line 8.1128

I trapped the payload between HC and host.dbr and got this for example.......

{"jsonrpc":"2.0","id":3,"method":"v2_corrsp_save","params":[{"ReturnedValue":true,"DataType":16},{"PassedValue":"TDE","DataType":1},{"DataType":512},{"PassedValue":"VGVzdAo=","DataType":1}]}

I remember seeing a message earlier about PassedValue missing or similar which pointed me to the above DataType 512 without a PassedValue. I've now changed it to this (added the missing PassedValue) and passed to host.dbr and it's working.......

{"PassedValue":"TDE","DataType":1},{"PassedValue":"","DataType":512},{"PassedValue":"VGVzdAo=","DataType":1}

We're still on an oldish version of HC so not sure if that's the issue. Can you tell me what DataType 512 is so I can check my json being passed to HC in case I'm missing something?

Thanks

hippiehunter commented 3 months ago

512 is a String data type you can see the enum here https://github.com/Synergex/HarmonyCore/blob/bc60ae3b938e0bef0567f997fd3621919eb2b4ea/TraditionalBridge/FieldDataDefinition.dbl#L62

I cant really help you though until you give me more context. It sounds like you've modified generated code on either the client or the server and are now getting this error. I'd need to see the client and server code and I would like to understand why you're changing generated code rather than using the system as designed.

shiblydangdang commented 3 months ago

Thanks for coming back to me Jeff. We've not modified any generated code. We've captured the message on the linux server to try and work out what has happened.

This is what I'm sending from Postman........

{"arguments":[{"p_corrsp_unique":"","p_analysis":"","p_topic":"EdocsAddInTest","p_expose_to_web":0,"p_pre_alert":0,"p_invoice_support":0,"p_transport_support":0,"p_pod_signature":0,"p_pod_signature_merged":0,"p_suppress_header":0,"p_index_key2":"","p_index_key3":"","p_docnum":0, "p_base64_file":"VGVzdAo=", "p_corrsp_file_name":"tony.txt", "p_corrsp_type_code":"00", "p_master_reference":"TDE", "p_trans_ref":""}],"invocationId":"23","target":"v2_corrsp_save","type":1}

...and this is a cut down version of what ends up being passed to host.dbr........

{"jsonrpc":"2.0","id":3,"method":"v2_corrsp_save","params":[{"ReturnedValue":true,"DataType":16},{"PassedValue":"TDE","DataType":1},{"DataType":512},{"PassedValue":"VGVzdAo=","DataType":1}]}

....as you can see, DataType:512 has no PassedValue with it - should it have?

if I add PassedValue:"' to this message and push it through host.dbr then it works as expected.

Thanks

hippiehunter commented 3 months ago

Without the code involved I don't have a way to correlate the json you're sending with the json-rpc call that's being produced. I can tell you that you cant read that data type without a value like that, but I would need to see why the argument is effectively not passed.

I've made some changes to a shim today and added a few parameters

can you tell me what changes you made?

shiblydangdang commented 3 months ago

added these.....

    {xfParameter(name="p_corrsp_file_name")}
    optional in    p_corrsp_file_name, a256
    {xfParameter(name="p_corrsp_type_code")}
    optional in    p_corrsp_type_code, a2
    {xfParameter(name="p_master_reference")}
    optional in    p_master_reference, a50
    {xfParameter(name="p_trans_ref")}
    optional in    p_trans_ref, a7
    {xfParameter(name="p_base64_file")}
    required in    p_base64_file, string
shiblydangdang commented 3 months ago

We're just doing the trace again our end to make sure that what I've explained above is definitely happening!

hippiehunter commented 3 months ago

please just send me the code for the .NET call where it's invoking CallMethod and the Traditional Side somewhere near here aspMethodDispatchers.dbl:line 2.13407

shiblydangdang commented 3 months ago

;;------------------------------------------------------------------------- ;;;

;;; Dispatcher for method asp.v2_corrsp_save ;;; public class v2_corrsp_save_Dispatcher extends RoutineStub

  public method v2_corrsp_save_Dispatcher
  proc
      ;;Initialize the meta data for any data objects that are used by parameters to the method
  endmethod

  protected override method DispatchInternal, void
      required in name,       string
      required in callFrame,  JSON_ELEMENT
      required in serializer, @DispatchSerializer
      required in dispatcher, @RoutineDispatcher
      record
          requestId,          int
          arguments,          JSON_ELEMENT
          argumentDefinition, @ArgumentDataDefinition

          ;;Argument 1 (REQUIRED IN p_corrsp_unique a12)
          arg1,               a12
          ;;Argument 2 (REQUIRED IN p_analysis a8)
          arg2,               a8
          ;;Argument 3 (REQUIRED IN p_topic a80)
          arg3,               a80
          ;;Argument 4 (REQUIRED IN p_expose_to_web d2)
          arg4,               d2
          ;;Argument 5 (REQUIRED IN p_pre_alert d1)
          arg5,               d1
          ;;Argument 6 (REQUIRED IN p_invoice_support d1)
          arg6,               d1
          ;;Argument 7 (REQUIRED IN p_transport_support d1)
          arg7,               d1
          ;;Argument 8 (REQUIRED IN p_pod_signature d1)
          arg8,               d1
          ;;Argument 9 (REQUIRED IN p_pod_signature_merged d1)
          arg9,               d1
          ;;Argument 10 (REQUIRED IN p_suppress_header d1)
          arg10,               d1
          ;;Argument 11 (REQUIRED IN p_index_key2 a20)
          arg11,               a20
          ;;Argument 12 (REQUIRED IN p_index_key3 a20)
          arg12,               a20
          ;;Argument 13 (REQUIRED IN p_docnum d3)
          arg13,               d3
          ;;Argument 14 (OPTIONAL IN p_corrsp_file_name a256)
          arg14,               a256
          ;;Argument 15 (OPTIONAL IN p_corrsp_type_code a2)
          arg15,               a2
          ;;Argument 16 (OPTIONAL IN p_master_reference a50)
          arg16,               a50
          ;;Argument 17 (OPTIONAL IN p_trans_ref a7)
          arg17,               a7
          ;;Argument 18 (REQUIRED IN p_base64_file string)
          arg18,               string
          ;;Argument 19 (REQUIRED OUT return_status d1)
          arg19,               d1
          ;;Argument 20 (REQUIRED OUT return_message a500)
          arg20,               a500
      endrecord

  proc

      ;;------------------------------------------------------------
      ;;Prepare variables for arguments

      arguments = callFrame.GetProperty("params")

      ;;Argument 1 (REQUIRED IN p_corrsp_unique a12)

      arg1 = dispatcher.GetText(arguments[1])

      ;;Argument 2 (REQUIRED IN p_analysis a8)

      arg2 = dispatcher.GetText(arguments[2])

      ;;Argument 3 (REQUIRED IN p_topic a80)

      arg3 = dispatcher.GetText(arguments[3])

      ;;Argument 4 (REQUIRED IN p_expose_to_web d2)

      arg4 = dispatcher.GetDecimal(arguments[4])

      ;;Argument 5 (REQUIRED IN p_pre_alert d1)

      arg5 = dispatcher.GetDecimal(arguments[5])

      ;;Argument 6 (REQUIRED IN p_invoice_support d1)

      arg6 = dispatcher.GetDecimal(arguments[6])

      ;;Argument 7 (REQUIRED IN p_transport_support d1)

      arg7 = dispatcher.GetDecimal(arguments[7])

      ;;Argument 8 (REQUIRED IN p_pod_signature d1)

      arg8 = dispatcher.GetDecimal(arguments[8])

      ;;Argument 9 (REQUIRED IN p_pod_signature_merged d1)

      arg9 = dispatcher.GetDecimal(arguments[9])

      ;;Argument 10 (REQUIRED IN p_suppress_header d1)

      arg10 = dispatcher.GetDecimal(arguments[10])

      ;;Argument 11 (REQUIRED IN p_index_key2 a20)

      arg11 = dispatcher.GetText(arguments[11])

      ;;Argument 12 (REQUIRED IN p_index_key3 a20)

      arg12 = dispatcher.GetText(arguments[12])

      ;;Argument 13 (REQUIRED IN p_docnum d3)

      arg13 = dispatcher.GetDecimal(arguments[13])

      ;;Argument 14 (OPTIONAL IN p_corrsp_file_name a256)

      arg14 = dispatcher.GetText(arguments[14])

      ;;Argument 15 (OPTIONAL IN p_corrsp_type_code a2)

      arg15 = dispatcher.GetText(arguments[15])

      ;;Argument 16 (OPTIONAL IN p_master_reference a50)

      arg16 = dispatcher.GetText(arguments[16])

      ;;Argument 17 (OPTIONAL IN p_trans_ref a7)

      arg17 = dispatcher.GetText(arguments[17])

      ;;Argument 18 (REQUIRED IN p_base64_file string)

      arg18 = dispatcher.GetText(arguments[18])

      ;;Argument 19 (REQUIRED OUT return_status d1)

      ;;Argument 20 (REQUIRED OUT return_message a500)

      ;;------------------------------------------------------------
      ;; Call the underlying routine

      xcall v2_corrsp_save_shim(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20)

      ;;--------------------------------------------------------------------------------
      ;;Argument 19 (REQUIRED OUT return_status d1)

      serializer.ArgumentData(19,arg19,FieldDataType.DecimalField,1,0,false)

      ;;--------------------------------------------------------------------------------
      ;;Argument 20 (REQUIRED OUT return_message a500)

      serializer.ArgumentData(20,%atrim(arg20),FieldDataType.AlphaField,500,0,false)
  endmethod
hippiehunter commented 3 months ago

FYI you don't have codegen for optional parameters turned on and I doubt you want it. We don't outright error because it's quite common for older code to have optional parameters declared from the xfNetLink COM days, even though they've been ignored for 15+ years. I still want to see the .NET side and your cutdown json packet is preventing me from lining up the dispatcher with the json you're sending in.

shiblydangdang commented 3 months ago

is that what you need?

   public async method v2_corrsp_save, @Task<asp.v2_corrsp_save_Response>
       required in args, @asp.v2_corrsp_save_Request
   proc
       ;;Prepare the response object
       data response = new asp.v2_corrsp_save_Response()

       ;;Make the JSON-RPC call the traditional Synergy routine
       data resultTuple = await CallMethod("v2_corrsp_save"
       &   ,args.p_corrsp_unique
       &   ,args.p_analysis
       &   ,args.p_topic
       &   ,args.p_expose_to_web
       &   ,args.p_pre_alert
       &   ,args.p_invoice_support
       &   ,args.p_transport_support
       &   ,args.p_pod_signature
       &   ,args.p_pod_signature_merged
       &   ,args.p_suppress_header
       &   ,args.p_index_key2
       &   ,args.p_index_key3
       &   ,args.p_docnum
       &   ,ArgumentHelper.MayBeOptional(args.p_corrsp_file_name)
       &   ,ArgumentHelper.MayBeOptional(args.p_corrsp_type_code)
       &   ,ArgumentHelper.MayBeOptional(args.p_master_reference)
       &   ,ArgumentHelper.MayBeOptional(args.p_trans_ref)
       &   ,args.p_base64_file
       &   ,response.return_status
       &   ,ArgumentHelper.MaybeNull(response.return_message)
       &   )

       data resultList, @List<Object>, resultTuple.Item2.ToList()

       ArgumentHelper.Argument(19, resultTuple, response.return_status)
       ArgumentHelper.Argument(20, resultTuple, response.return_message)

       ;;Return the response
       mreturn response

   endmethod
hippiehunter commented 3 months ago

if the contents are sensitive you can omit the contents of the passed value fields but i really need the full json message.

shiblydangdang commented 3 months ago

its all in here......

{"arguments":[{"p_corrsp_unique":"","p_analysis":"","p_topic":"EdocsAddInTest","p_expose_to_web":0,"p_pre_alert":0,"p_invoice_support":0,"p_transport_support":0,"p_pod_signature":0,"p_pod_signature_merged":0,"p_suppress_header":0,"p_index_key2":"","p_index_key3":"","p_docnum":0, "p_base64_file":"VGVzdAo=", "p_corrsp_file_name":"tony.txt", "p_corrsp_type_code":"00", "p_master_reference":"TDE", "p_trans_ref":""}],"invocationId":"23","target":"v2_corrsp_save","type":1}�

hippiehunter commented 3 months ago

sorry the json-rpc

shiblydangdang commented 3 months ago

{ "jsonrpc": "2.0", "id": 3, "method": "v2_corrsp_save", "params": [ { "ReturnedValue": true, "DataType": 16 }, { "PassedValue": "", "DataType": 1 }, { "PassedValue": "", "DataType": 1 }, { "PassedValue": "Edocs Addin Test", "DataType": 1 }, { "PassedValue": 0, "DataType": 8 }, { "PassedValue": 0, "DataType": 8 }, { "PassedValue": 0, "DataType": 8 }, { "PassedValue": 0, "DataType": 8 }, { "PassedValue": 0, "DataType": 8 }, { "PassedValue": 0, "DataType": 8 }, { "PassedValue": 0, "DataType": 8 }, { "PassedValue": "", "DataType": 1 }, { "PassedValue": "", "DataType": 1 }, { "PassedValue": 0, "DataType": 8 }, { "DataType": 512 }, { "DataType": 512 }, { "DataType": 512 }, { "DataType": 512 }, { "PassedValue": "VGVzdAo=", "DataType": 1 }, { "PassedValue": 0, "DataType": 8 }, { "PassedValue": "", "DataType": 1 } ] }

shiblydangdang commented 3 months ago

I'm just mapping them across all of the above processes and it looks like the MaybeOptional ones are the culprits

hippiehunter commented 3 months ago

Ah, its all the parameters marked as optional. As mentioned earlier please don't mark them as optional, you havent enabled that feature and you dont want it.

shiblydangdang commented 3 months ago

Doesn't that then mean anywhere else that uses this method will have to pass those extra params as blank? That's what I was trying to avoid by making them optional.

hippiehunter commented 3 months ago

depending on the age of your templates, it will default those parameters to "". Do you actually intend to use ^passed with them in the dbl code?

shiblydangdang commented 3 months ago

Let me have a play with our calling code and see. Thanks for all your help.

shiblydangdang commented 2 months ago

This is all working now that I've changed from optional params. Thanks again for your help Jeff.