Topic
  • 3 replies
  • Latest Post - ‏2012-04-23T13:24:07Z by HermannSW
msmps
msmps
193 Posts

Pinned topic Update the tables

‏2012-04-19T17:06:46Z |
few questions
Can we update the entries in database tables through dp:sql-execute? Is it possible

How to send a HTTP Post request from datapower where the request is not an xml.
for example
POST /login.jsp HTTP/1.1
        Host: www.mysite.com
        Content-Length: 27
        Content-Type: application/x-www-form-urlencoded
 
        userid=joe&password=guessme
Updated on 2014-03-25T02:57:35Z at 2014-03-25T02:57:35Z by iron-man
  • HermannSW
    HermannSW
    4657 Posts

    Re: Update the tables

    ‏2012-04-21T13:54:17Z  
    Hi Robert,

    > Can we update the entries in database tables through dp:sql-execute? Is it possible
    >
    yes, see a sample in this posting of Alex (which discusses caching results in addition):
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14622098#14622098

    > How to send a HTTP Post request from datapower where the request is not an xml.
    > for example
    >
    
    POST /login.jsp HTTP/1.1 >  Host: www.mysite.com >       Content-Length: 27 >         Content-Type: application/x-www-form-urlencoded > >       userid=joe&password=guessme
    

    >
    You can process HTTP form data sent to DataPower (by either POST or GET) with the convert-http action.
    See a description of a minimal setup in this posting:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14527508#14527508

    Only binary file uploads cannot be handled by convert-http.
    If you need that, find a solution on slide 16 of this WSTE webcast:
    http://www-01.ibm.com/support/docview.wss?uid=swg27019118

     
    Hermann<myXsltBlog/>
  • msmps
    msmps
    193 Posts

    Re: Update the tables

    ‏2012-04-23T04:02:44Z  
    • HermannSW
    • ‏2012-04-21T13:54:17Z
    Hi Robert,

    > Can we update the entries in database tables through dp:sql-execute? Is it possible
    >
    yes, see a sample in this posting of Alex (which discusses caching results in addition):
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14622098#14622098

    > How to send a HTTP Post request from datapower where the request is not an xml.
    > for example
    > <pre class="jive-pre"> POST /login.jsp HTTP/1.1 > Host: www.mysite.com > Content-Length: 27 > Content-Type: application/x-www-form-urlencoded > > userid=joe&password=guessme </pre>
    >
    You can process HTTP form data sent to DataPower (by either POST or GET) with the convert-http action.
    See a description of a minimal setup in this posting:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14527508#14527508

    Only binary file uploads cannot be handled by convert-http.
    If you need that, find a solution on slide 16 of this WSTE webcast:
    http://www-01.ibm.com/support/docview.wss?uid=swg27019118

     
    Hermann<myXsltBlog/>
    Thanks for the reply
    Regarding second question can datapower send the http post in that way to backend instead of xml
  • HermannSW
    HermannSW
    4657 Posts

    Re: Update the tables

    ‏2012-04-23T13:24:07Z  
    • msmps
    • ‏2012-04-23T04:02:44Z
    Thanks for the reply
    Regarding second question can datapower send the http post in that way to backend instead of xml
    > Regarding second question can datapower send the http post in that way to backend instead of xml
    >
    Yes, just set the Content-Type, and output whatever you want to backend.

    This is the sample invocation of the service:
    
    $ curl --data-binary 
    "<foobar/>" http:
    //dp1-l2:7001; echo userid=joe&password=guessme $
    


    Service listening on port 7001 just executes stylesheet form.xsl with backend 127.0.0.1:7002.
    The service listening on port 7002 is just a pass-thru loopback XML FW simulating the backend.

    This is stylesheet form.xsl:
    
    <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
    "http://www.datapower.com/extensions" extension-element-prefixes=
    "dp" > <xsl:output method=
    "text" /> <xsl:template match=
    "/"> <dp:set-http-request-header name=
    "'Content-Type'" value=
    "'application/x-www-form-urlencoded'"/>   <xsl:text>userid=joe&amp;password=guessme</xsl:text> </xsl:template> </xsl:stylesheet>
    


    I did take a packet capture on loopback interface, opened it with Wireshark, did select "tcp.port==7002" and did a "Follow TCP stream" then.
    The output shows that DataPower does send the HTTP POST as you need:
    
    POST / HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2 Host: 127.0.0.1:7002 Accept: *
    /* Content-Type: application/x-www-form-urlencoded origHost: dp1-l2:7001 Via: 1.1 post Connection: Keep-Alive X-Client-IP: 9.152.201.86 Content-Length: 27 userid=joe&password=guessme ...
    


     
    Hermann<myXsltBlog/>