SOAP Request with WSSE-Header in Javascript

332 Views Asked by At

I have the following code to execute a SOAP request with an wsse header but it seems not to work. I get a error response but I am not able to get the fault/error out of the response.

Does the below code look correct or do I miss something?

var request = "<soapenv:Envelope" +
    "xmlns:dlg='http://dlg123Lib'" +
    "xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
    "<soapenv:Header>" +
        "<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'>" +
            "<wsse:UsernameToken wsu:Id='UsernameToken-BF09AFF37A2C36D4AB164000000000000000'>" +
                "<wsse:Username>BLABLABLA</wsse:Username>" +
                "<wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>BLABLABLA</wsse:Password>" +
            "</wsse:UsernameToken>" +
        "</wsse:Security>" +
    "</soapenv:Header>" +
    "<soapenv:Body>" +
        "<dlg:getData>" +
            "<name>AB</name>" +
        "</dlg:getData>" +
    "</soapenv:Body>" +
"</soapenv:Envelope>"

jQuery.ajax({
        url: 'https://endpoint_url/dlg/data',
        type: "POST",
        data: request,
        dataType: "xml",
        contentType: "text/xml; charset='utf-8'",
        success: function (soapResponse) {
            alert("Success");
        },
        error: function (soapResponse) {
            alert("Error");
        }
});

When I execute the exact same request like above in SoapUI without setting an Authorization the request is executed correctly.

So it must be something wrong with the jQuery implementation(?)

enter image description here

UPDATE 15.01.2022 I was told by the customer that the Payload of the request is empty. Anybody an idea why this could happen?

0

There are 0 best solutions below