PROTOCOL:http-client Headers How to change

Clovertech Forums Cloverleaf PROTOCOL:http-client Headers How to change

  • Creator
    Topic
  • #118636
    John Hamilton
    Participant

      New to using this protocol.
      Can someone guide me on how to modify the headers.
      Specifically I need to change the Content-Type: application/x-www-form-urlencoded from the message header to Content-Type: text/xml.

      I copied the httpQuery tcl script and tried from there but can’t seem to get a handle on it.
      So any guidance or help would be appreciated.

    Viewing 9 reply threads
    • Author
      Replies
      • #118637
        Charlie Bursell
        Participant

          I have not tested it but it seems to me if you are sure the current header is Content-Type: application/x-www-form-urlencoded , then in the httpQuery proc right after the statement:  set newHeaders “”; keylget httpCtl HEADERS newHeaders
          and before statement:  if [clength $newHeaders] { keylset val HEADERS $newHeaders }
          do this:

          set newHeaders [string map “Content-Type: application/x-www-form-urlencoded” “Content-Type: text/xml”]

          This is a bit convoluted and specific but best I can do without more knowledge of the situation.  I have not been a big fan of the httpQuery script and prefer to roll my own.

        • #118638
          Robert Kersemakers
          Participant

            In the http-client Protocol Properties screen you can define the headers in the field ‘Headers’, under ‘URL’. The field is a keyed list, so use something like:
            {Content-Type “text/xml; charset=utf-8”} {User-Agent “CIS”} {Authorization “Basic **encodedpassword**”}

            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

          • #118645
            John Hamilton
            Participant

              Still not working.

              I have included a snipit of the procedure I’m using.  All I’m tying to do is send a simple SOAP message to an internal server for SIU-S26 messages so we can track patient no-show. As Robert suggested I used the HTTP:Client headers that didn’t work either.

              As well as a snip of the engine log and network trace. No matter how I approcah it aI can change the Content:Type.    Maybe someone has better eyes than I do and can see where I’m going wrong.

              Any help would be appreciated.

              Attachments:
              You must be logged in to view attached files.
            • #118648
              John Hamilton
              Participant

                Need to upload trc log.

                Attachments:
                You must be logged in to view attached files.
              • #118650
                Charlie Bursell
                Participant

                  Your original problem was to change Content Type to text/xml.  It looks like you have done that based on the log “{HEADERS {{Content-Type: text/xml; charset=utf-8}”

                  Why are you executing 2 times ?:    keylget args CFGS cfgs

                  The error returned is:  HTTP/1.1 400 Bad Request

                  Why not ask the receiver what it is he does not like about the message?

                  I ran the code through a code sniffer: https://squizlabs.github.io/HTML_CodeSniffer/

                  No errors or warnings so the message seems to be formed OK

                • #118653
                  John Hamilton
                  Participant

                    They are telling me it s the Content-Type needs to be “Text/XML”

                    And it keeps showing up as application/x-www-form-urlencoded.

                    The engine log and code show it as Text/xml… But the network trace shows it as “application/x-www-form-urlencoded”.

                  • #118662
                    Charlie Bursell
                    Participant

                      Is there a SMAT message?

                      If you will be doing many web interfaces, you really need an Analyzer such as IEInspector.  I think it is around $150.

                      EInspector HTTP Analyzer is such a handy tool that allows you to monitor, trace, debug and analyze HTTP/HTTPS traffic in real-time.

                      https://www.ieinspector.com/httpanalyzer/

                    • #118666
                      John Hamilton
                      Participant

                        Calling Curl directly with the same url headers and data works just fine.
                        When I try call it via httppost it changes the CONTENT:Type.

                        So I give up.   just going to stick with Curl.

                         

                      • #118673
                        Charlie Bursell
                        Participant

                          Can’t say as I blame you 🙂

                          How about opening a Support ticket to make sure this is not a bug (enhancement?)

                        • #118674
                          Robert Kersemakers
                          Participant

                            I think you are confusing things.
                            In the proc SoapEnv_NoShow you are creating the message to be sent, but also doing an ‘httppost’. You have based this SoapEnv_NoShow on httpQuery, but httpQuery should be used in a very specific place (Query TPS on the http-client Protocol options) and with very specific parameters.

                            What you want to do (imho) is to use SoapEnv_NoShow only to create the SOAP message that you want to send out. So let it CONTINUE the SOAP message you made.
                            Send this message to the http-client and use httpQuery in ‘Query TPS’ with parameters {MSGUSE DATA}. Also define the needed HTTP-headers in ‘Headers’ and fill out all other fields. ‘Driver Mode’ should me ‘Message Driven’.

                            Another option would be to use java/ws-rawclient instead of http-client.

                            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

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