0

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?

  • 1
    Hi, the request in its entirety is fine for SoapUI, but I've found that when building the request in Javascript with ajax or fetch, you need to add the headers separately. See Headers in jQuery's docs at https://api.jquery.com/jquery.ajax/. For examples, see https://www.educba.com/jquery-ajax-headers/ – Chris Adams Mar 11 '22 at 07:27
  • thank you for your reply. See my update above. Do you have an idea why this can happen? – Paul Richardson Mar 15 '22 at 14:31
  • 1
    In SoapUI, after you submit your request, click on the Raw tab which will show you exactly what SoapUI passed to the web service. That may give a clue. – Chris Adams Mar 15 '22 at 14:51

0 Answers0