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 147 forks source link

Not issue, just help please. #7

Closed closdesign closed 11 years ago

closdesign commented 11 years ago

Hello, I am having an issue invoking from my SOAP service. We want to pass a value into our SOAP service and get the data back for that record. I have attached screen shots of what we need to do, but more or less, I need to know how pass our value into the jquery.soap in order to get the XML back from the SOAP. BTW, this plugin is awesome. Much appreciated. Here is my code below. I don't think it is correct for what we need it to do.

$.soap({
    url: 'http://myservice.mysite.com/myservice.asmx/',
    //method: 'ConnectedToDatabase', // this is a simple bool. this works
    method: 'GetMembership', //Need to get THIS Working.
    namespaceQualifier: 'xlmns',
    namespaceUrl: 'http://tempuri.org',
    params: {consituentId: 123456789}, //Don't know if I am doing this correctly
    success: function (soapResponse) {
         console.log (soapResponse.toString());

        // do stuff with soapResponse
        // if you want to have the response as JSON use soapResponse.toJSON();
        // or soapResponse.toString() to get XML string
        // or soapResponse.toXML() to get XML DOM
    },
    error: function (SOAPResponse) {

        console.log("well that was an error");

        // show error
    }
});

As you can see below (click on the image for larger view), we want to pass an ID into our textbox and then get the value back the data for the record. Eventually this will be JSON, BUT for now, consuming a SOAP service would be a great proof of concept. Any and all help is greatly appreciated.

getdatasoap

doedje commented 11 years ago

As far as I can see by quickly scanning your message I see a problem.

$.soap({
    url: 'http://myservice.mysite.com/myservice.asmx/',
    method: 'GetMembership', //Need to get THIS Working.
    namespaceQualifier: 'xlmns',
    namespaceUrl: 'http://tempuri.org',
    params: {
        constituentId: 123456789
    },
    ....
  }
});

Will send the params inside a soap envelope:

<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xlmns="http://tempuri.org">
    <soap:Body>
        <xlmns:GetMembership>
            <consituentId>123456789</consituentId>
        </myns:GetMembership>
    </soap:Body>
</soap:Envelope>

By the looks of your example of the HTTP POST your server expects the constituentId to be one of the POST-VARS. But it will not be there. If you control the code on the server, you can try to look inside the soap envelope and get the id from there. If you don't have the possibility of changing the code on the server and have to send the constituentId as a POST-VAR I think you will have better results using jquery's native $.post():

$.post({
    url: 'http://myservice.mysite.com/myservice.asmx/GetMembership',
    dataType: 'xml', // the type of data you expect to get back from the server
    data: {
        constituentId: 123456789
    }
});

Hope this helps...

closdesign commented 11 years ago

@doedje , Yes that helps a lot. Thank you for the explanation.

Carlos

doedje commented 11 years ago

you're welcome =]