Topic
16 replies Latest Post - ‏2014-12-01T19:43:38Z by souciance
Stolbovsky
Stolbovsky
22 Posts
ACCEPTED ANSWER

Pinned topic Using GET in Http Method Types

‏2012-02-16T14:26:53Z |
Hi!
I need to make get http request to a backside server after receiving message from MQ. I tried to use GET method in Results Action to do this, but datapower sends post request anyway.
Is there a way to make get request in such a case?

Regards,
Dmitry
Updated on 2012-10-09T06:00:21Z at 2012-10-09T06:00:21Z by Stolbovsky
  • Liv2luv
    Liv2luv
    573 Posts
    ACCEPTED ANSWER

    Re: Using GET in Http Method Types

    ‏2012-02-16T15:01:37Z  in response to Stolbovsky
    try with setting 'var://service/protocol-method' variable to GET or using the method rewrite action (from advanced) before making a call to the backend.
    • Stolbovsky
      Stolbovsky
      22 Posts
      ACCEPTED ANSWER

      Re: Using GET in Http Method Types

      ‏2012-02-17T07:36:09Z  in response to Liv2luv
      I tried to use <dp:set-variable name="'var://service/protocol-method'" value="'GET'"/> It doesn't rewrite protocol-method service variable. The only thing I see in probe is changed string on top of the window MethodRewriteType=GET, MethodType=GET, MethodType2=POST. Before setting variable MethodType=POST.
      When I using Method Rewrite Action I doesn't see any differences at all.
      Do you know what MethodType2=POST means?
      • HermannSW
        HermannSW
        4320 Posts
        ACCEPTED ANSWER

        Re: Using GET in Http Method Types

        ‏2012-02-17T08:59:30Z  in response to Stolbovsky
        It is important to "setvar" the protocol-method and having NULL as input context of results action.
        See Wireshark "Follow TCP" output of captured backend interface traffic.

        The backend traffic is independent from frontside traffic, so I just did HTTP:
        
        $ curl --data-binary @some.xml http:
        //dp3-l3:2074/ab.xml <a>1<b>2</b>3</a> $
        


        This works:

        match(url=*)
        INPUT--setvar('var://service/protocol-method','GET')
        NULL--results(Method=POST)
        
        GET /ab.xml HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.12.9.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2 Host: dp4-l3.boeblingen.de.ibm.com:80 Accept: *
        /* Content-Type: application/x-www-form-urlencoded origHost: dp3-l3:2074 Via: 1.1 post2get Connection: Keep-Alive X-Client-IP: 9.164.170.51 Content-Length: 0 HTTP/1.1 200 OK Date: Fri, 17 Feb 2012 08:53:10 GMT Server: Apache/2.2.3 (Red Hat) Last-Modified: Thu, 07 Jul 2011 08:52:45 GMT ETag: "f29692-12-d72ef140" Accept-Ranges: bytes Content-Length: 18 Keep-Alive: timeout=15 Connection: Keep-Alive Content-Type: text/xml <a>1<b>2</b>3</a>
        

        This is interesting, a GET request with body content.
        This seems not to be forbidden, search the web for "HTTP GET body" if you are interested.

        match(url=*)
        INPUT--setvar('var://service/protocol-method','GET')
        INPUT--results(Method=GET)
        
        GET /ab.xml HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.12.9.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2 Host: dp4-l3.boeblingen.de.ibm.com:80 Accept: *
        /* Content-Type: application/x-www-form-urlencoded origHost: dp3-l3:2074 Via: 1.1 post2get Connection: Keep-Alive X-Client-IP: 9.164.170.51 Content-Length: 46 <?xml version="1.0" encoding="UTF-8"?> <some/>HTTP/1.1 200 OK Date: Fri, 17 Feb 2012 08:49:38 GMT Server: Apache/2.2.3 (Red Hat) Last-Modified: Thu, 07 Jul 2011 08:52:45 GMT ETag: "f29692-12-d72ef140" Accept-Ranges: bytes Content-Length: 18 Keep-Alive: timeout=15 Connection: Keep-Alive Content-Type: text/xml <a>1<b>2</b>3</a>
        


         
        Hermann<myXsltBlog/>
  • Stolbovsky
    Stolbovsky
    22 Posts
    ACCEPTED ANSWER

    Re: Using GET in Http Method Types

    ‏2012-10-09T06:00:21Z  in response to Stolbovsky
    I tried to use 3 different methods but they dont work.
    1. Using <dp:set-variable name="'var://service/protocol-method'" value="'GET'"/> in Processing Action.
    2. Using Set Variable Action with variable name var://service/protocol-method and variable assignment=GET.
    3. Using Method Rewrite Action with Method=GET.
    The Processing rule in all cases looks like this:
    match
    processing action to transform input from MQ Queue (Input=NULL,Output=NULL)
    set variable action (Context=NULL) or method rewrite method (Method=GET)
    results action (Input=NULL, Output=NULL, Method=GET)
    In all cases DataPower makes POST request to backend server.
    In debug probe variable var://service/protocol-method value was 'POST'
    It seems like a bug.
    What I'm doing wrong?

    Regards,
    Dmitry
    • amae
      amae
      5 Posts
      ACCEPTED ANSWER

      Re: Using GET in Http Method Types

      ‏2014-11-20T11:51:16Z  in response to Stolbovsky

      We are having the exact same issue. Is there any solution for this?

       

      Amanda

      • kenhygh
        kenhygh
        1408 Posts
        ACCEPTED ANSWER

        Re: Using GET in Http Method Types

        ‏2014-11-20T14:16:05Z  in response to amae

        What have you tried?

        • amae
          amae
          5 Posts
          ACCEPTED ANSWER

          Re: Using GET in Http Method Types

          ‏2014-11-20T14:31:15Z  in response to kenhygh

          Everything as explained by Stolbovsky in the previous posts.

           

          I am getting a XML message of a MQ Q that will contain a URL where I have to go get a jpg from. The jpg must then go on the response Q to be saved as a file to a target directory bu the app reading the response Q. 

          I must warn you I am very inexperienced with datapower and the problem might be between the keyboard an the chair. 

          When I do the above HTTP -> HTTPS all works and I see the image in the requesting browser. Then I change my MPGW to MQ FSH -> HTTPs and what I get on the reponse Q is HTML stating that 'POST' is not a valid method for this site. 

          I tried changing var://service/protocol-method to 'GET' in various ways but at the end what is passed to the backend is 'POST' 

          • kenhygh
            kenhygh
            1408 Posts
            ACCEPTED ANSWER

            Re: Using GET in Http Method Types

            ‏2014-11-20T15:47:45Z  in response to amae

            is the input context of your Results action NULL?

            [unfortunately, I do not have access to MQ so I can't test this]

  • souciance
    souciance
    188 Posts
    ACCEPTED ANSWER

    Re: Using GET in Http Method Types

    ‏2014-12-01T19:43:38Z  in response to Stolbovsky

    I got this to work. However I had to resort to do url-open to do a HTTP GET based on MQ FSH.