0

For the life of me I cannot figure out why this Ajax SOAP request does not work.

This is mostly my version of the code found here: jQuery AJAX SOAP based web services and CORS (cross origin resource sharing)

When the function is run it returns a 500 error in the console. That error returns XML with the following error included:

<faultstring>Unable to handle request without a valid action parameter. Please supply a valid soap action.</faultstring>

Nothing shows up in the server error logs. The XML I'm using to generate that request was created by SOAP UI and returns the correct information without any error in that context.

Additional info: server headers have absolutely been set correctly and I can return the entire XML service with no cross-domain problems. It's only when I try to send in the query represented by the "se" variable that I have troubles. I have tried this code with '?WSDL' both present and absent. I've also tried using both POST and GET (although pretty sure POST is the one to use).

<script type="text/javascript">
        var se = '';
        se += '<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
        se += '<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://XXX.YYYY.com/">';
        se += '<soapenv:Header/>';
        se += '<soapenv:Body>';
        se += '<test:GetCurrentProductRelease/>';
        se += '</soapenv:Body>';
        se += '</soapenv:Envelope>';

                $.ajax({
                url: 'http://xx.xx.xxx.xxxx/XXXAdminDS/XXXAdminDS.asmx?WSDL',
                type: "POST",
                    dataType: "xml",
                    data: se,
                    crossDomain: true,
                    headers: {"X-Requested-With": "XMLHttpRequest"},
                    beforeSend: function(xhr) {
                        xhr.setRequestHeader("SOAPAction", "http://xx.xx.xxx.xxx/XXXAdminDS/XXXAdminDS.asmx?WSDL");
                    },

                    // success: function(xml) {
                    //   some code here
                    // },

                    // failure: function(xml) {
                    //   more code here
                    // },

                    contentType: "charset=UTF-8"
                });
            }
        </script>
Community
  • 1
  • 1
Raydot
  • 1,458
  • 1
  • 23
  • 38

1 Answers1

0

The answer would be very difficult to derive from the information given in the question, but on the off chance anyone has a similar problem I'm going to share my answer:

I was trying to replace the tempuri.org namespace generated from SOAP with a custom namespace, represented above by "xmlns:test="http://XXX.YYYY.com/". The only problem was I didn't tell the people who set up the Web services first, and they weren't aware you shouldn't use tempuri.org in production. So the problem was basically that tempuri.org was the only namespace the Web service recognized.

I solved a problem they didn't know they had and they got me set up with a custom namespace and now the application works!

Raydot
  • 1,458
  • 1
  • 23
  • 38