Click here to Skip to main content
13,800,402 members
Click here to Skip to main content
Add your own
alternative version


27 bookmarked
Posted 14 Feb 2005
Licenced CPOL

Consume WebService Using SOAP

, 27 Feb 2005
Rate this:
Please Sign up or sign in to vote.
Consume WebService Using SOAP


Web Services are thought of as a means to provide easily accessible services over a network. We can use VS.NET IDE to create a Web Service.

While there are different techniques to communicate with a Web Services, SOAP is regarded as the actual standard. SOAP messages are being sent to service endpoints. This can simply be SOAP over HTTP.

Information Regarding Exsiting Web Service

.Asmx file for that WebService (URL):



http://localhost/AddNumbers/Service1.asmx ?wsdl

Namespace of web service:



int AddTwoNumbers (int, int)



Steps For Consuming Web Service Using SOAP

  1. Start a new ASP.NET web application.
  2. Install msxml.msi, then click on “Add reference “ and then select “Interop.MSXML2.dll” and click on add.

    You can download the English version of the msxml.msi install file via this link:

  3. Create one label to display result (ID = lablel1).
  4. Declare objXMLHttp of type MSXML2.ServerXMLHTTP40.
    Protected MSXML2.ServerXMLHTTP40 objXMLHttp
  5. Declare one string strSoapEnvelope which contains soap request.
    string strSoapEnvelope= "";
  6. Create SOAP Envelope strSoapEnvelope like this:
    strSoapEnvelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
    strSoapEnvelope += "<soap:Envelope ";
    strSoapEnvelope += "xmlns:xsi = \"\" ";
    strSoapEnvelope += "xmlns:xsd= \"\" ";
    strSoapEnvelope += "xmlns:soap= \"\">";
    strSoapEnvelope += "<soap:Body>";
    strSoapEnvelope += "<AddTwoNumbers  
    strSoapEnvelope +="<a>10</a>";
    strSoapEnvelope += "<b>12</b>"
    strSoapEnvelope += "</AddTwoNumbers >";
    strSoapEnvelope += "</soap:Body>";
    strSoapEnvelope += "</soap:Envelope>";
  7. Create an instance of ServerXMLHTTP40.
    objXMLHttp = new ServerXMLHTTP40();
  8. Set the header of SOAP request."POST",,false,"","")
    objXMLHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
  9. Send the SOAP request.
  10. Wait for some time.
  11. Take response in string outXML.
    string outXML = objXMLHttp.responseText.ToString();
  12. Display result in label(ID= label1):
    Label1.Text = outXML.ToString();


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Vimal Kamothi
Web Developer
India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralCall SOAP service over the HTTPS Pin
anrorathod3-Oct-13 0:15
memberanrorathod3-Oct-13 0:15 
QuestionSwA with MIME Pin
sharath.molagavalli23-Jul-13 8:42
membersharath.molagavalli23-Jul-13 8:42 
GeneralWorks great! Pin
jasonee15-Mar-11 5:59
memberjasonee15-Mar-11 5:59 
GeneralMy vote of 5 Pin
Mickey-MinThein26-Jul-10 22:59
professionalMickey-MinThein26-Jul-10 22:59 
GeneralMy vote of 1 Pin
Tawani Anyangwe27-Apr-09 10:26
memberTawani Anyangwe27-Apr-09 10:26 
GeneralMy vote of 1 Pin
Fuzzychaos23-Mar-09 4:48
memberFuzzychaos23-Mar-09 4:48 
GeneralMy vote of 1 Pin
virusstorm3-Mar-09 5:41
membervirusstorm3-Mar-09 5:41 
GeneralMy vote of 1 Pin
Dave Sexton20-Feb-09 5:42
memberDave Sexton20-Feb-09 5:42 
Questionerror Pin
aminbeheshti4-Feb-09 20:10
memberaminbeheshti4-Feb-09 20:10 
GeneralSystem.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction. Pin
Anujit17-Nov-08 19:18
memberAnujit17-Nov-08 19:18 
GeneralSOAP request to a webservice Pin
webmavin1-May-07 2:41
memberwebmavin1-May-07 2:41 
GeneralRe: SOAP request to a webservice Pin
RedDiamonds22-Jan-09 22:57
memberRedDiamonds22-Jan-09 22:57 
GeneralGreat Article Pin
Satisht75-Mar-07 16:59
memberSatisht75-Mar-07 16:59 
QuestionSystem.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction. Pin
sunil0474919-Dec-06 3:08
membersunil0474919-Dec-06 3:08 
GeneralNice work... but.... Pin
pinoyBug26-Feb-05 0:17
memberpinoyBug26-Feb-05 0:17 
GeneralRe: Nice work... but.... Pin
Vimal Kamothi28-Feb-05 17:41
memberVimal Kamothi28-Feb-05 17:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.181214.1 | Last Updated 27 Feb 2005
Article Copyright 2005 by Vimal Kamothi
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid