
<!doctype html>
<html>
<head>
<title>Calling Web Service from jQuery</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnCallWebService").click(function (event) {
var wsUrl = "http://ABAP:8080/sap/bc/srt/rfc/sap/ztest/001/ztest/rfc_read_table";
var soapRequest = '<?xml version="1.0" encoding="UTF-8"?>' +
'<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">' +
'<env:Body>' +
'<ns1:RFC_READ_TABLE xmlns:ns1="urn:sap-com:document:sap:rfc:functions">' +
'<DATA />' +
'<FIELDS />' +
'<OPTIONS />' +
'<QUERY_TABLE>USR01</QUERY_TABLE>' +
'</ns1:RFC_READ_TABLE>' +
'</env:Body>' +
'</env:Envelope>';
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
headers: {
"Authorization": "Basic " + btoa("bcuser:minisap"),
"Accept": "*/*",
"Host": "ABAP"
},
data: soapRequest,
success: processSuccess,
});
error: processError
});
});
function processSuccess(data, status, req) {
alert('success');
if (status == "success")
alert(req.responseText);
}
function processError(data, status, req) {
alert(req.responseText + " " + status);
}
</script>
</head>
<body>
<h3>
Calling SAP Web Services via JavaScript with jQuery/AJAX
</h3>
<input id="btnCallWebService" value="Call web service" type="button" />
</body>
</html>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |