要访问Web服务,请求需要身份验证而不需要用户名和密码,如何将它们添加到我的代码中:
function sendReq()
{ var wsUrl = "*******";
var soapRequest ='<?xml version="1.0" encoding="utf-8"?>'+
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
'<soap:Body>'+
'<UpdateImage xmlns="*******">'+
'<urlSite>*********</urlSite>'+
'<iListName>{*****}</iListName>'+
'<iUpdateMode>****</iUpdateMode>'+
'<iMetaData><Fields><Field Name="Title" >'+my_var1+'</Field></Fields></iMetaData>'+
'<iAttachments><Attachments><Attachment Name="Nom du fichier 1">'+my_var2+'</Attachment></Attachments></iAttachments>'+
'<iOverWrite>*****</iOverWrite>'+
'</UpdateImage>'+
'</soap:Body>'+
'</soap:Envelope>';
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml; charset=utf-8",
dataType: "xml",
data: soapRequest,
beforeSend: function (xhr){
xhr.setRequestHeader("SOAPAction", "****/UpdateImage");
},
contentType: "text/xml; charset=utf-8",
success: processSuccess,
error: processError
});
返回false;