Announcement

Collapse
No announcement yet.

Custom HTTP Response

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom HTTP Response

    OK I'm trying to do a custom HTTP response and read a few other threads that put me in the right direction but I can't quite get it working.

    OK Channel name is "TESTER"
    http listener: Port 2116
    Respond from: "FW"

    Destinations:
    Name: "FW"
    Type: File Writer
    Name/Dir: Whatever you want.

    Transformer on FW
    Code:
    //This is just for logging
    logger.info("TESTER: " + ResponseFactory.getSuccessResponse('message'));
    //This is where I try to do a custom http response
    responseMap.put('FW', 'this is my test custom http response ' + ResponseFactory.getSuccessResponse('message'));

    I also attached my channel.

    I'm testing by opening the web browser and going to http://localhost:2116?Method=TEST

    (Method=TEST is just so i can see how mirth handles that data)

    Any help is appreciated.

    I don't realy know what all responseMap.put('',''); wants. TESTER.xml (4344 bytes)

  • #2
    Re:Custom HTTP Response

    In your post processor you can create a custom response. Just a quick example:
    Code:
    var ack = "This is a sample custom response!";
    responseMap.put("FW", ResponseFactory.getSuccessResponse(ack));
    When you enter the preprocessor you can get the value from FWs destination response (responseMap.get("FW").getMessage() or .getStatus()). You can then pass that back directly or you can modify the response by replacing it's value in the responseMap.
    Chris Lang

    Comment


    • #3
      Re:Custom HTTP Response

      Thanks chris, that did it. I uploaded my sample channel to the inbound channels for others. It's "HTTP Sample Custom Response"

      Thanks again.

      Comment


      • #4
        Re:Custom HTTP Response

        In a comment/response above, you mentioned a post-processor. Where is the post-processor? Did you actually mean pre-processor?

        Comment


        • #5
          Re:Custom HTTP Response

          The post processor script. Go to a channel and then go to scripts and you have a postprocessor script in the drop down.

          Comment


          • #6
            Re:Custom HTTP Response

            Sorry, try as I might, I can not find the post-processing script. I am using version 1.6. Am I missing something?

            Post edited by: [email protected], at: 09/07/2007 14:11

            Comment


            • #7
              Re:Custom HTTP Response

              Looks like you are still using a 1.5 client. Try clearing your Java cache - go to Control Panel, Java and clear the webstart cache.
              Chris Lang

              Comment


              • #8
                Re:Custom HTTP Response

                Thanks! You are right. I had installed the 1.6, but somehow the 1.5 client was still there.

                Comment


                • #9
                  Re:Custom HTTP Response

                  How can you get this to be conditional based on the sucess or failure of the destination channel ? I tried using if (responseMap.get("FW").getStatus() == "ERROR") { but no luck.

                  --

                  Comment


                  • #10
                    Re:Custom HTTP Response

                    How can you get this to be conditional based on the sucess or failure of the destination channel ? I tried using if (responseMap.get("FW").getStatus() == "ERROR") { but no luck.

                    --

                    Comment


                    • #11
                      Re:Custom HTTP Response

                      How can you get this to be conditional based on the sucess or failure of the destination channel ? I tried using if (responseMap.get("FW").getStatus() == "ERROR") { but no luck.

                      --

                      Comment

                      Working...
                      X