Simplest SOAP example

前端 未结 13 1649
死守一世寂寞
死守一世寂寞 2020-11-22 01:32

What is the simplest SOAP example using Javascript?

To be as useful as possible, the answer should:

  • Be functional (in other words actually work)
  • <
13条回答
  •  温柔的废话
    2020-11-22 01:56

    You can use the jquery.soap plugin to do the work for you.

    This script uses $.ajax to send a SOAPEnvelope. 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.

    Example usage from the site:

    $.soap({
        url: 'http://my.server.com/soapservices/',
        method: 'helloWorld',
    
        data: {
            name: 'Remy Blom',
            msg: 'Hi!'
        },
    
        success: function (soapResponse) {
            // 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) {
            // show error
        }
    });
    

提交回复
热议问题