Home Forums Integration Channels GETrequest on commit

Viewing 11 reply threads
  • Author
    Posts
    • #17003
      Saurabh MulikSaurabh Mulik
      Participant

      I am calling a rest API using post method. I get the response and when commit is called, I see a GET request being sent on the channel. This request is only seen if commit is called after API call.

      As API does not support GET, HTTP code 500 is returned and transaction fails to commit.

      In the Channel I have specified GET = false.

      Not sure why GET request is called on commit, and not sure how GET goes through the channel if GET = false.

       

      Any pointers will be helpful

      0
    • #17013
      Ed ShawEd Shaw
      Keymaster

      Would it be possible to share a code snippet? The commit behaviour is expected as integration channels are transactional. But if you are sending a POST it should remain a POST, not change to a GET. Are you sure the method property on your request is POST?

      0
    • #17019
      Saurabh MulikSaurabh Mulik
      Participant

      Hi Ed, thank you.

      Yes Method on my request is POST, but when commit is called I can see request as GET. Please see attached log.

      Code is 1- Invoke service

      Step 2- Commit.

       

      0
    • #17026
      Saurabh MulikSaurabh Mulik
      Participant

      ++ debug log

      0
      Attachments:
      You must be logged in to view attached files.
    • #17034
      Ed ShawEd Shaw
      Keymaster

      I see your log output, but it would be helpful if you could post the HTTP invocation code you are executing. Thanks, Ed

      0
    • #17040
      Saurabh MulikSaurabh Mulik
      Participant

      Hi Ed,

      Please find code below.

      Code :-

      (invokeService “T24_SA_CashCCY”
      (message
      (: :class “T24_SA_CashCCY”)
      (: bu “0201”)
      (: cif “1100324”)
      (: portfolioNumber “1100324-2” )
      (: accountOfficer “1104”)
      (: availableCashAccounts “1”)

      (: accountCurrencies col)
      ; (: accountCurrencies (message
      ; (: :class “T24_SA_CashCCY_CCY”)
      ; (: accountCurrencies col )
      ;
      ; )
      ; )

      )
      “T24_SA_CashCCY”)

      (commit)

      0
      Attachments:
      You must be logged in to view attached files.
    • #17048
      Ed ShawEd Shaw
      Keymaster

      Thanks, could you show me the code that sends the message in the “T24_SA_CashCCY” service?

      0
    • #17054
      Saurabh MulikSaurabh Mulik
      Participant

      do you mean the code for invokeService method ? Please see below.

      (define (invokeService service-name message output . args)
      ((apply SysService ‘invoke
      service-name
      message
      output
      args
      )’result
      )
      )

      0
    • #17061
      Ed ShawEd Shaw
      Keymaster

      Saurabh,

      What I’m looking for are the contents of the T24_SA_CachCCY.service file.

      Thanks,

      Ed

      0
    • #17067
      Saurabh MulikSaurabh Mulik
      Participant

      Thank you. Please find it below

      Interface and channel name is same .

      <Service layout=”startX:420;startY:100;endX:414;endY:600″ variables=”ex”>
      <TryCatch layout=”w:191;y:160;h:401;x:320″ name=”tryCatch” variable=”ex”>
      <Try>
      <Log layout=”y:34;x:70″ level=”&quot;info&quot;” name=”log”/>
      <SendReceive interface=”T24_SA_CashCCY” layout=”y:150;x:44″ name=”sendReceive” output=”&quot;T24_SA_CashCCY&quot;”/>
      <Log layout=”y:280;x:42″ level=”&quot;dump&quot;” name=”log response”/>
      </Try>
      <Catch layout=”w:150;h:100;y:311;x:640″ name=”catch”>
      <Script layout=”y:10;x:10″ name=”log Exception”><![CDATA[(logger’error “Cash Account error: ” ex)
      ;(throw ex)
      ;this]]></Script>
      </Catch>
      </TryCatch>
      </Service>

       

       

       

      0
    • #17074
      Ed ShawEd Shaw
      Keymaster

      I think I need to see the interface and the .message file associated with the class “T24_SA_CashCCY”. I’m not sure what transformations are being made by the interface. As it stands, you are passing a “T24_SA_CashCCY” transfer object to the service. There is no method part to the message so it makes sense that it is defaulting to GET because I don’t see POST being set anywhere. The typical approach is something like…

      (define msgBody ; your message payload in raw internal format
      (message
      (: :class “MyMessageType”)
      (: part1 “mypart”)
      (: part2 “mypart2”)

      )
      )
      (define reqest
      (message
      (: :class “HTTP”)
      (: method “POST”) ; must set the method explicitly
      (: headers ; set security and type headers that the target API expects
      (message (: content-type “application/json”))
      )
      (: body (format-message msgBody)) ; uses the message type to format to the wire format e.g. JSON or XML
      )
      )
      (define ret ((integration-send-receive request “MyChannel” ()))) ; equivalent to using the SendReceive step in a service
      ; you may optionally use an interface to automatically parse the return value which is the third parameter above
      (define bod (ret’body))

      0
    • #17081
      Saurabh MulikSaurabh Mulik
      Participant

      Hi Ed,

      It worked . thanks a lot.

      what I infer from this is,

      1- the method that I used (invokeService) is transactional. so when commit was getting called, it makes the API call with GET method.

      2- My call was going with POST method as I was using a channel in which POST was set to true ( GET was not set to true)

      3- Commit is using GET method as POST method was not specified in the request message (still my first request goes as POST ).

      One difference that I see in the logs with my code , before the GET call channel logs sending a request on channel, with response type message (T24_SA_CashCCY_Response).

      where as before the POST call  I can see log as sending message on channel with correct object

       

      Se both logs below.

       

      GET call log.

      ; 16:42:14,131 DEBUG [UnitOfWork] (NexJ-ContainedProcess) Committing 0 instance(s)
      ; 16:42:14,131 DEBUG [UnitOfWork] (NexJ-ContainedProcess) Sending 1 message(s) on channel “T24_SA_CashCCY”
      ; 16:42:14,131 DEBUG [T24_SA_CashCCY] (NexJ-ContainedProcess) Sending a request on channel “T24_SA_CashCCY”
      ; 16:42:14,131 DUMP [T24_SA_CashCCY] (NexJ-ContainedProcess) TO<T24_SA_CashCCY_Response, @650985704>(
      status=”SUCCESS”
      )
      ; 16:42:14,131 DEBUG [HTTPClient] (NexJ-ContainedProcess) Connecting to sglt9010200.ap.hedani.net/10.164.168.16:8088
      ; 16:42:14,131 DEBUG [T24_SA_CashCCY] (NexJ-ContainedProcess) Activated HTTPConnection(socket=572a6f17[TLS_DHE_RSA_WITH_AES_128_CBC_SHA: Socket[addr=sglt9010200.ap.hedani.net/10.164.168.16,port=8088,localport=53922]], time=2021-05-20 15:42:14.130000000)
      ; 16:42:14,131 DEBUG [HTTPClient] (NexJ-ContainedProcess) HTTP request: GET https://sglt9010200.ap.hedani.net:8088/api/cs/pb/saudi/pronghorn/v1/createAccount HTTP/1.1

       

       

       

      POST call log

       

      ; 16:42:12,004 DEBUG [T24_SA_CashCCY] (NexJ-ContainedProcess) Sending a message on channel “T24_SA_CashCCY”
      ; 16:42:12,004 DUMP [T24_SA_CashCCY] (NexJ-ContainedProcess) TO<, @778351515>(
      body=”{“bu”:”0201″,”cif”:”1100324″,”portfolioNumber”:”1100324-2″,”accountOfficer”:”1104″,”availableCashAccounts”:”1″,”accountCurrencies”:[“CHF”]}”
      )
      ; 16:42:12,004 DEBUG [HTTPClient] (NexJ-ContainedProcess) Connecting to sglt9010200.ap.hedani.net/10.164.168.16:8088
      ; 16:42:12,182 DEBUG [T24_SA_CashCCY] (NexJ-ContainedProcess) Created HTTPConnection(socket=572a6f17[SSL_NULL_WITH_NULL_NULL: Socket[addr=sglt9010200.ap.hedani.net/10.164.168.16,port=8088,localport=53922]])
      ; 16:42:12,182 DEBUG [HTTPClient] (NexJ-ContainedProcess) HTTP request: POST https://sglt9010200.ap.hedani.net:8088/api/cs/pb/saudi/pronghorn/v1/createAccount HTTP/1.1

       

      0
Viewing 11 reply threads
  • You must be logged in to reply to this topic.