Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
SolvedPrivate

C# simple soap example call

Posted on 2015-01-28
3
Medium Priority
?
44 Views
Last Modified: 2016-02-16
Can you provide a simple c# example soap call
0
Comment
Question by:Brant Snow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 668 total points
ID: 40576543
A sample tutorial is shown here
The tutorial is for VS2010 but these are the same steps for Vs2013 as well. Steps 4 to 7 add Web Reference to your target SOAP web service.
0
 
LVL 4

Assisted Solution

by:Praveen Kumar Bonala
Praveen Kumar Bonala earned 668 total points
ID: 40576553
//snippet of c# calling webservice using soap 1.2
string xmlstr = @"<?xml version=""1.0"" encoding=""utf-8""?> <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"">
 
<soap12:Body>
 
<GetPlannedWorkSummary xmlns=""http://tempuri.org/"">
 
<timestamp>2010-01-10</timestamp>
 
</GetPlannedWorkSummary>
 
</soap12:Body>
 
</soap12:Envelope>";
 
//call web service funciton
 
SampleWebServiceCall(xmlstr,url);
 
//sample function
public static void SampleWebServiceCall(string requestXML, string url) {
//declarations
string response = string.Empty;
byte[] requestBuffer = null;
HttpWebRequest webRequest = null;
HttpWebResponse webResponse = null;
Stream postStream = null;
Stream responseStream = null;
StreamReader responseReader = null;
DateTime startTime = new DateTime();
DateTime endTime = new DateTime();
 
try
{
 
requestBuffer = Encoding.ASCII.GetBytes(requestXML);
webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.ContentType = "text/xml";
webRequest.ContentLength = requestBuffer.Length;
postStream = webRequest.GetRequestStream();
postStream.Write(requestBuffer, 0, requestBuffer.Length); postStream.Close();
webResponse = (HttpWebResponse)webRequest.GetResponse(); responseStream = webResponse.GetResponseStream();
responseReader = new StreamReader(responseStream);
response = responseReader.ReadToEnd();
}
catch (Exception ex)
{
 
}
finally
{
if (postStream != null)
{
postStream.Dispose();
}
if (webResponse != null)
{
webResponse.Close();
}
}
0
 
LVL 1

Assisted Solution

by:echobridge
echobridge earned 664 total points
ID: 40577554
0

Featured Post

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question