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
vipin saini
NA
88
0
post soap request and responce
Sep 16 2010 4:57 AM
HttpWebRequest
hwRequest;
HttpWebResponse
hwResponse;
System.IO.
StreamReader
sReader;
XmlDocument
xmlDoc =
new
XmlDocument
();
int
iTimeout = 1;
System.Text.
Encoding
encode = System.Text.
Encoding
.GetEncoding(
"utf-8"
);
// Pipes the stream to a higher level stream reader with the required encoding format.
System.Text.
ASCIIEncoding
encoding =
new
System.Text.
ASCIIEncoding
();
string
strXMLRequest =
@"<?xml version='1.0' encoding='UTF-8'?>"
+
@"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'"
+
@" xmlns:eb='http://www.ebxml.org/namespaces/messageHeader' xmlns:xlink='http://www.w3.org/1999/xlink' "
+
@" xmlns:xsd='http://www.w3.org/1999/XMLSchema'> "
+
@" <SOAP-ENV:Header/> "
+
@" <SOAP-ENV:Body> "
+
@" <DSAvailableHotelRQPL xmlns='urn:Hotel_Search' "
+
@" xmlns:xs='http://www.w3.org/2001/XMLSchema' "
+
@" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' PrimaryLangID='en-us' AltLangID='en-us'> "
+
@" <POS> "
+
@" <Source Username='ID' Password='PWD' PropertyID='ID' /> "
+
@" </POS> "
+
@"<AvailRequestSegments> "
+
@"<AvailRequestSegment> "
+
@" <StayDateRange Start='2009-09-05T12:00:00' End='2009-09-06T12:00:00'/> "
+
@" <RoomStayCandidates> "
+
@" <RoomStayCandidate> <!--for Room 1--> "
+
@" <GuestCounts> "
+
@" <GuestCount Count='2'/> "
+
@" </GuestCounts> "
+
@" <ChildCounts> <!--if no child is selected skip this node --> "
+
@" <ChildAge Age='10'/> "
+
@" <ChildAge Age='09'/> "
+
@" </ChildCounts> "
+
@" </RoomStayCandidate> "
+
@" <RoomStayCandidate> <!--for Room 2--> "
+
@" <GuestCounts> "
+
@" <GuestCount Count='2'/> "
+
@" </GuestCounts> "
+
@" <ChildCounts><!--if no child is selected skip this node --> "
+
@" <ChildAge Age='10'/> "
+
@" <ChildAge Age='09'/> "
+
@" </ChildCounts> "
+
@"</RoomStayCandidate> "
+
@" </RoomStayCandidates> "
+
@" <HotelSearchCriteria> "
+
@" <Criterion> "
+
@" <HotelRef HotelCityName='CITY' HotelName='' Area='' Attraction='' Rating=''/> "
+
@" <Sorting Preference='2'/> "
+
@" <ResponseType Compact='Y'/> "
+
@" </Criterion> "
+
@" </HotelSearchCriteria> "
+
@" </AvailRequestSegment> "
+
@" </AvailRequestSegments> "
+
@" </DSAvailableHotelRQPL> "
+
@" </SOAP-ENV:Body> "
+
@" </SOAP-ENV:Envelope> "
;
XmlDocument
soapEnvelopeXml =
new
XmlDocument
();
soapEnvelopeXml.LoadXml(strXMLRequest);
string
strWebServiceURL =
"http://XYZ.com/default1.aspx"
;
hwRequest = (
HttpWebRequest
)
HttpWebRequest
.Create(strWebServiceURL);
hwRequest.Headers.Add(
"SOAPAction"
,
"http://test.abc.com/soap/testing/TestWebservice/message"
);
hwRequest.ContentType =
"text/xml; charset=utf-8"
;
hwRequest.Accept =
"text/xml"
;
hwRequest.Credentials =
CredentialCache
.DefaultCredentials;
hwRequest.Method =
"POST"
;
hwRequest.Timeout = iTimeout * 1000;
//hwRequest.ContentLength = soapEnvelopeXml.OuterXml.Length;;
using
(
Stream
stream = hwRequest.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
hwResponse = (
HttpWebResponse
)hwRequest.GetResponse();
sReader =
new
StreamReader
(hwResponse.GetResponseStream());
string
strXMLReply = sReader.ReadToEnd();
sReader.Close();
xmlDoc.LoadXml(strXMLReply);
Response.Write(xmlDoc.OuterXml);
plz see it
it is not working plz tell me
Reply
Answers (
8
)
post soap request
The handshake failed due to an unexpected packet