Web服务中函数的参数:
POST /_vti_bin/******.ConnectorService.asmx HTTP/1.1
Host: www.*****.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.*****.com/SaveFile"
<?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>
<SaveFile xmlns="http://www.proged.tn">
<urlSite>string</urlSite>
<iListName>string</iListName>
<iUpdateMode>NotVerified or FillEmpty or Replace or NotReplace</iUpdateMode>
<iMetaData>xml</iMetaData>
<iAttachments>xml</iAttachments>
<iOverWrite>boolean</iOverWrite>
</SaveFile>
</soap:Body>
</soap:Envelope>
我的js代码:
function sendReq()
{
var my_title="title";
var c='<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhE.....AAAElFTkSuQmCC" />';
var b= false;
var wsUrl = "http://www.proged.tn/sites/toyourbusiness/_vti_bin/PROGED.ConnectorService.asmx?op=UpdateListItem";
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>'+
'<SaveFile xmlns="http://www.*****.com">'+
'<urlSite>http://www.*****.com/***/***</urlSite>'+
'<iListName>{*****}</iListName>'+
'<iUpdateMode>NotVerified</iUpdateMode>'+
'<iMetaData><Fields><Field Name="Title" >'+my_title+'</Field></Fields></iMetaData>'+
'<iAttachments><Attachments><Attachment Name="name of the file">'+c+'</Attachment></Attachments></iAttachments>'+
'<iOverWrite>'+b+'</iOverWrite>'+
'</SaveFile >'+
'</soap:Body>'+
'</soap:Envelope>';
var xmlhttp = createXMLHttpRequest();
xmlhttp.open("POST", wsUrl, true,"username","password");
xmlhttp.setRequestHeader ("Post", "/_vti_bin/****.ConnectorService.asmx HTTP/1.1");
xmlhttp.setRequestHeader ("Host", "www.****.com");
xmlhttp.setRequestHeader("Access-Control-Allow-Origin", "*");
xmlhttp.setRequestHeader ("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("Content-Length", soapRequest.length);
xmlhttp.setRequestHeader ("SOAPAction", "http://www.****.com/SaveFile");
xmlhttp.onerror = function(e) {
alert("Error ocurred. Error = " + e.message);
}
xmlhttp.ontimeout = function(e) {
alert("Timeout error!");
}
xmlhttp.onreadystatechange = function () {
alert(xmlhttp.readyState);
if (xmlhttp.readyState==4)
{
alert(xmlhttp.responseText);
alert(xmlhttp.status);
// if "OK"
if (xmlhttp.status==200 || xmlhttp.status==0)
{
alert(xmlhttp.responseXML);
//[Get xmlhttp.responseXML.xml and do something with it]
}
else
{
//[Get xmlhttp.responseXML.xml and do something with it in the case of an error]
}
}
}
xmlhttp.send(soapRequest);
}
这会返回xmlhttp.responseXML = null,status = 0,有什么不对!!