Forum Discussion

AKUMA_234040's avatar
AKUMA_234040
Icon for Nimbostratus rankNimbostratus
Apr 29, 2019

How to use irule or iRule LX to call external soap web service which use wss4j for security

How to use irule or iRule LX to call external soap web service, the web service which use wss4j for authentication, the following is the soapenv:Envelope which can be used to call the webservice:

 

http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="; http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; xmlns:wsu="; ? ?

 

 

2 Replies

  • If you just want to do the POST and do something with the data you can use iRulesLX. It could look like something like this. Please note, that this is just an example. This code is not tested and will need probably need some modification to fit your needs.

     

    iRule:

     

    when SOME_EVENT {
        set var1 "var1"
        set var2 "var2"
        set var3 "var3"
        
        set rpc_handle [ ILX::init xml_plugin ext_xml ]
        if {[ catch { ILX::call $rpc_handle sendXML $var1 $var2 $var3 } result ] } {
            log local0. "sendXML failed, ILX failure: $result"
            return
        }
        
         do something with the result
        log local0. "Result: $result"
    }

    iRuleLX

     

    const http = require("http");
    var f5 = require("f5-nodejs");
    var ilx = new f5.ILXServer();
    
    ilx.addMethod('sendXML', function(req, res) {
        var var1 = req.params()[0];
        var var2 = req.params()[1];
        var var3 = req.params()[2];
    
        var postData = ' ... ';
    
        var options = {
            hostname: 'cnsvwshvm01023.csvw.com',
            port: 80,
            path: '/cmit/services/dataService.dataServiceHttpSoap11Endpoint/',
            method: 'POST',
            headers: {
               'Content-Type': 'text/xml',
               'Content-Length': postData.length,
            }
        };
    
        var request = http.request(options, (response) => {
            response.on('data', (d) => {
                /* data received, maybe do something with the data */
                return res.reply('successful');
            });
        });
    
        request.on('error', (e) => {
            console.log(e);
            return res.reply('failed');
        });
    
        request.write(postData);
        request.end();
    
    });
    
    ilx.listen();
    
    • Nikoolayy1's avatar
      Nikoolayy1
      Icon for MVP rankMVP

      That is great and if Content-Type is changed to something like

      application/json
      then also REST calls probably could be send as I see no issues! Just postData should also be json not xml.