TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bindu
NA
40
64k
post xml request to rest services using javascript
Nov 20 2012 2:05 AM
Hi...
i am very new to javascript. how to call rest services using javascript.
Collapse | Copy Code
function CreateXMLHttpRequest() {
if (typeof XMLHttpRequest != "undefined") {
//All modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) uses XMLHttpRequest object
return new XMLHttpRequest();
}
else if (typeof ActiveXObject != "undefined") {
//Internet Explorer (IE5 and IE6) uses an ActiveX Object
return new ActiveXObject("Microsoft.XMLHTTP");
}
else {
throw new Error("XMLHttpRequestnot supported");
}
}
function CallService() {
var objXMLHttpRequest = CreateXMLHttpRequest();
objXMLHttpRequest.onreadystatechange = function () {
if (objXMLHttpRequest.readyState == 4)
objXMLHttpRequest.responseText;
}
objXMLHttpRequest.open("POST", "http://localhost:2546/abc.svc/json/GetXml", true);
objXMLHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// objXMLHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
var packet = '<?xml version="1.0"encoding="utf-8"?><CompanyRequest xmlns="http://schemas.datacontract.org/2004/07/abc.DomainModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><CompanyName>company1</CompanyName></CompanyRequest>';
objXMLHttpRequest.send(packet);
}
i need to send xml request and response should also be xml. i am getting null response can anybody give me sample programs for this
thanks in advance...
Reply
Answers (
0
)
image upload
what is abc