如何在javascript中处理soap fault

时间:2013-02-19 06:21:15

标签: javascript web-services httprequest

您好我使用javascript来调用.net中的Web服务。我使用http请求来调用Web服务,我想在javascript中处理soap错误,怎么做?

1 个答案:

答案 0 :(得分:0)

您可以使用jQuery Soap,一个使用SOAP与Web服务进行通信的插件

"此脚本使用$ .ajax发送SOAP:Envelope。它可以将XML DOM,XML字符串或JSON作为输入,并且响应也可以作为XML DOM,XML字符串或JSON返回。"

我还没有尝试过,但它看起来很健壮,很容易上手。

示例:

$.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
}
});

来源:https://github.com/doedje/jquery.soap