1.CodeComment removed
// To allow ASP. Net ajax to call this web service from a script, cancel the comments to the downstream.
// [System. Web. Script. Services. scriptservice]
2. The JS call method is as follows:
VaR request = '<? XML version = "1.0" encoding = "UTF-8"?> '; Request + =' <soap12: envelope xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema" xmlns: soap12 = "http://www.w3.org/2003/05/soap-envelope"> 'request + = '<soap12: body> 'request + = '<updatefacultativere xmlns = "http://tempuri.org/"> 'request + =' <facnum> 12313 </facnum> 'request + = '<facverstion> 2 </ facverstion> 'request + = '<date> string </date> 'request + =' <description> string </description> 'request + = '</updatefacultativere> 'request + = '</soap12: body> 'request + = '</soap12: envelope> 'var Req = new XMLHttpRequest (); req. open ("Post", 'HTTP: // localhost: 34869/crmservice. asmx ', true) // responses will return XML. it isn' t possible to return JSON. // req. setRequestHeader ("accept", "application/XML, text/XML, */*"); req. setRequestHeader ("Content-Type", "application/soap + XML; charset = UTF-8"); req. setRequestHeader ("Content-Length:", request. length); req. setRequestHeader ("soapaction", "http://tempuri.org/UpdateFacultativere"); req. onreadystatechange = function () {DOR (req, successcallback, errorcallback) ;}; req. send (request );
3. jquery calls the following method:
$. ajax ({URL: 'HTTP: // localhost: 34869/crmservice. asmx/updatefacultativere ', data: {facnum: '000000', facverstion: 10, Date: '000000 ', description: '000000' }, datatype: "XML" , type: " Post ", success: function (XML) { debugger alert (XML) ;}, error: function (XML, status) { debugger }});