您可以使用jQuery ajax 使用该服务。
请参阅此示例,从我使用的服务中复制:
// Here you define your message. You can use SOAP or VS to create a message and copy here
var soapMessage = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">.....</s:Envelope>';
$.ajax({
// Method must be POST
type:"POST",
// Here you can also specify the encoding if necessary:
contentType: "text/xml",
url:"http://address/Service.svc/Operation",
dataType: "xml",
data: soapMessage,
// Here you must define the contract and operation:
headers: { "SOAPAction": "http://tempuri.org/Contract/Operation" },
success: function(data){
...
},
error: function(request, error){
...
},
});
如果您使用的是旧版本的 jQuery,则无法支持 headers,您应该改用 beforSend。