escapingloadrunner

LoadRunner VUGen escaping


When I create a Soap web service test in SoapUI and also create a saml token on the same test it looks something like this:

Action()

{

web_set_max_html_param_len("80000");



  lr_start_transaction ("get something");



  web_reg_save_param("ResponseBody",

    "LB=<actorREF>",

    "RB=</actorREF>",

    "Search=Body",

    "IgnoreRedirections=Yes",

LAST);



 web_custom_request("UserHistory",

            "URL=http://e34jbsl00120.devillo.no:8080/UserHistory/services/UserHistoryServicePort/v1",

            "Method=POST",

            "Resource=0",

            "RecContentType=text/xml",

            "Referer=",

            "Snapshot=t1.inf",

            "Mode=HTML",

            "EncType=text/xml;charset=UTF-8",

            "Body=<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://hey.com/service/point/UserHistory/v1/\">\n"

        "<soapenv:Header>\n"

                    "<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">\n"

                 "<saml2:Assertion xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" ID=\"1231231231231231321\" IssueInstant=\"2013-03-20T11:16:16.488Z\" Version=\"2.0\"><saml2:Issuer>dokumentinnsending</saml2:Issuer><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"/><ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><ds:Reference URI=\"#1231231231231231321\"><ds:Transforms><ds:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/><ds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"><ec:InclusiveNamespaces xmlns:ec=\"http://www.w3.org/2001/10/xml-exc-c14n#\" PrefixList=\"xs\"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><ds:DigestValue>oo2Pw2UFGReV4tScwiduZhp9hmU=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>TWP1dXZofLtkQBYB/wGcjv1yQKZNtRVvEMJFq1B/32a8fEi53g02Lr0XwKeAae6cpmUdfsRURAectwGF9AvzhSFMllzxW1uJp/MqMOD6kBEVcw7YXSY2aLlih4JTu6zYEm7zf963rplOFPLRfeSMapZBPqBIV/2ge+AhBBKeuybhcYmwuDpjm2hkIYmFZgk/98v8G2SeUfFnopyrqyArQb2KMgh3NtyZJgjsHA7woqonnsAtX8RQj09PIYyBtulwvJ1w70GtCxQli/bhrjEzhl7zPjPuQR81WciGZPmDDglMUUVhytFOh82wnvZkaDIOqzir2cg9N7GLsms6+D6CyQ==</ds:SignatureValue><ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIIGdTCCBV2gAwIBAgIKFYRkaQAAAAAByTANBgkqhkiG9w0BAQUFADBSMRUwEwYKCZImiZPyLGQB\n"

                                    "GRYFbG9jYWwxGTAXBgoJkiaJk/IsZAEZFgl1dHZpa2xpbmcxHjAcBgNVBAMTFU5BViBJc3N1aW5n\n"

                                    "IENBIGludGVybjAeFw0xMzAxMjQwODU5MDBaFw0xNTAxMjQwOTA5MDBaMFsxCzAJBgNVBAYTAk5P\n"

                                    "MQ0wCwYDVQQIEwRPc2xvMQ0wCwYDVQQHEwRPc2xvMQwwCgYDVQQKEwNOQVYxIDAeBgNVBAMTF2Uz\n"

                                    "NGpic2wwMDIwOS5kZXZpbGxvLm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxIhr\n"

                                    "CrHr5ID4LXfehljlZTf8kAzEmLJTMy1d1B0dpWDT7/cUWaKMMK23OTBoIex/3ye61zc8U7zO8q0G\n"

                                    "n8Bc/rd//rGaYVukTHjnsofIeOmJwSEmkfp46Nnpcpbbd0/cK1OyXynRPQ0RDT0zV+NwLaZWP2i0\n"

                                    "GGD9osmX2H6G0UmdbYJ8ZDIxT6wn9Gt64ipS65b0qzNoenqxpxlOS0VG2YUpZreAuEHUuYFgIum/\n"

                                    "2TOY8Y8PvBe5TgXHMf1t+kU859BZ4M7C93NPqisrOP3vx6/gue1pw/yr+7jJ6azHlhZcnqYbZ80g\n"

                                    "/mypVXDNfc/HpWsmGf8nr02GGVKzmYmjnwIDAQABo4IDQjCCAz4wHQYDVR0OBBYEFLr25AUqP4pa\n"

                                    "8Wcw411d5I9G9nyKMB8GA1UdIwQYMBaAFK8t6pOwpoVfyb56R7GyCnk3FtkkMIIBJQYDVR0fBIIB\n"

                                    "HDCCARgwggEUoIIBEKCCAQyGgclsZGFwOi8vL2NuPU5BViUyMElzc3VpbmclMjBDQSUyMGludGVy\n"

                                    "bixDTj1FMjVEUlZXMDE5LENOPUNEUCxDTj1QdWJsaWMlMjBrZXklMjBTZXJ2aWNlcyxDTj1TZXJ2\n"

                                    "aWNlcyxDTj1Db25maWd1cmF0aW9uLERDPXV0dmlrbGluZyxEQz1sb2NhbD9jZXJ0aWZpY2F0ZVJl\n"

                                    "dm9jYXRpb25MaXN0P2Jhc2U/b2JqZWN0Q2xhc3M9Y1JMRGlzdHJpYnV0aW9uUG9pbnSGPmh0dHA6\n"

                                    "Ly9jcmwudXR2aWtsaW5nLmxvY2FsL0NybC9OQVYlMjBJc3N1aW5nJTIwQ0ElMjBpbnRlcm4uY3Js\n"

                                    "MIIBOgYIKwYBBQUHAQEEggEsMIIBKDCBvgYIKwYBBQUHMAKGgbFsZGFwOi8vL2NuPU5BViUyMElz\n"

                                    "c3VpbmclMjBDQSUyMGludGVybixDTj1BSUEsQ049UHVibGljJTIwa2V5JTIwU2VydmljZXMsQ049\n"

                                    "U2VydmljZXMsQ049Q29uZmlndXJhdGlvbixEQz11dHZpa2xpbmcsREM9bG9jYWw/Y0FDZXJ0aWZp\n"

                                    "Y2F0ZT9iYXNlP29iamVjdENsYXNzPWNlcnRpZmljYXRpb25BdXRob3JpdHkwZQYIKwYBBQUHMAKG\n"

                                    "WWh0dHA6Ly9jcmwudXR2aWtsaW5nLmxvY2FsL0NybC9FMjVEUlZXMDE5LnV0dmlrbGluZy5sb2Nh\n"

                                    "bF9OQVYlMjBJc3N1aW5nJTIwQ0ElMjBpbnRlcm4uY3J0MA4GA1UdDwEB/wQEAwIF4DA9BgkrBgEE\n"

                                    "AYI3FQcEMDAuBiYrBgEEAYI3FQiEjNF5gsK9MoWNkx6G7fB4hPXEXhCE+6BHgfSTbQIBZAIBBDAd\n"

                                    "BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwJwYJKwYBBAGCNxUKBBowGDAKBggrBgEFBQcD\n"

                                    "ATAKBggrBgEFBQcDAjANBgkqhkiG9w0BAQUFAAOCAQEAo57ShcfVZQlYDPZsAvISBICZ2XE2HhKh\n"

                                    "vxmBFWLVUOm0IzXKzXDnQX4ZWsvP4d2FtZnGjPsLAwn93QOtrPCgZgYZPfD4+E457NQgypbAkqMA\n"

                                    "6LQfoWm3jWCluTGmR2k67GZaDhDCMoctIEK8zoNp592pv5EjsazO3nXdDfp/NIEsTudWgoGurzXO\n"

                                    "uIdru/WWZMtt2ztn9B4vG2IviH07FG+O+izf7n8CT1L2UkfrQI5y+L9F4COqmiQS/mgyiPlag+vN\n"

                                    "LmSDPMG/xh9CjpYJbeSYLKg7AZ4e4FGFk0WzoBuQ5PqeK57YPyEexYQhdTcQQyzE7YlxUpJWWheh\n"

                                    "iXn/Vg==</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature><saml2:Subject><saml2:NameID Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified\" NameQualifier=\"www.nav.no\">24068149964</saml2:NameID><saml2:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"/></saml2:Subject><saml2:Conditions NotBefore=\"2013-03-20T11:16:16.488Z\" NotOnOrAfter=\"2017-03-19T11:16:16.488Z\"/><saml2:AttributeStatement><saml2:Attribute Name=\"authenticationLevel\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\"><saml2:AttributeValue xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xs:string\">4</saml2:AttributeValue></saml2:Attribute><saml2:Attribute Name=\"identType\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\"><saml2:AttributeValue xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xs:string\">external</saml2:AttributeValue></saml2:Attribute><saml2:Attribute Name=\"consumerId\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\"><saml2:AttributeValue xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xs:string\">dokumentinnsending</saml2:AttributeValue></saml2:Attribute></saml2:AttributeStatement></saml2:Assertion>\n"

                    "</wsse:Security>\n"

                    "</soapenv:Header>\n"

        " <soapenv:Body>\n"

        " <v1:getUserListRequest>\n"

        " <aktoerID>24068149964</aktoerID>\n"

        " </v1:getUserListRequest>\n"

        " </soapenv:Body>\n"

        " </soapenv:Envelope>",

            LAST);



  lr_output_message("Birth date: %s", lr_eval_string("{ResponseBody}"));



    lr_think_time(3);



lr_xml_extract("XML={ResponseBody}", 

"XMLFragmentParam=OutputParameter", 

"Query=//actorREF", LAST);

    lr_output_message("Tha response is: %s", lr_eval_string("{OutputParameter}"));



   lr_end_transaction ("get something", LR_AUTO);







return 0;

}

However, wanting to paste this into LoadRunner I experience a lot of work with using escapeing. Any tips to help me solve this manual labour intensive work? Can I create a template in LoadRunner for this?


Solution

  • When you say "escaping" I assume you mean adding the backslashes to the quotation marks to make them read as part of the string, is that right? So " to \", yes?

    Just copy the body code into textpad and do a replace all, just replace all the quotes with a backslash quote and copy the code back to LR.