doedje / jquery.soap

This script uses $.ajax to send a SOAP:Envelope. It can take XML DOM, XML string or JSON as input and the response can be returned as either XML DOM, XML string or JSON too.
352 stars 148 forks source link

404 not found, but works with POSTMAN #103

Closed diegoalmesp closed 7 years ago

diegoalmesp commented 7 years ago

Hello! first of all, great plugin, and thanks for your work!

I have been trying to send a call without success, I'm new to the SOAP world so I'm kind of lost but I've read the documentation and don't know what else to try.

This is the request that I have to send to the server:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:ser="http://mycompanyservice/">
    <soap:Body>
        <ser:resetKey>
            <arg0>
                <billNumber>3333333333</billNumber>
            </arg0>
        </ser:resetKey>
    </soap:Body>
</soap:Envelope>

If I send this with POSTMAN, it works just fine, but not using this plugin. And the weird thing is that I actually copied this code from the one generated with this plugin.

So, I have to think that the xml is ok.

This is the code that I'm using to generate the xml:

    $soap({
        url: 'http://mycompanyurl/',
        appendMethodToURL: false,
        method: 'resetKey',
        envAttributes: {
          'xmlns:ser': 'http://mycompanyservice/'
        },

        data: function(SOAPObject) {
          return new SOAPObject('soap:Envelope')
          .addNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/')
          .newChild('soap:Body')
          .newChild('resetKey')
          .newChild('arg0')
          .addParameter('billNumber', window.$('#_58_login_movil').val())
          .end()
        },
      }).done(function(data, textStatus, jqXHR) {
        console.log('done');
        console.log(data);
        console.log(textStatus);
        console.log(jqXHR);
      }).fail(function(jqXHR, textStatus, errorThrown) {
        console.log('error');
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
      });

The OPTIONS returns 200, but the POST 404. The console goes to the fail and shows: 'not found', as the errorTrown value. I don't know what else to try, hope you can help me.

Thanks in advance!

diegoalmesp commented 7 years ago

We got it!

we just had to add this to the $soap({}) :

    HTTPHeaders: {
        'Content-type': 'application/x-www-form-urlencoded',
    },

and now it works like a charm!

Thanks.