Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 12th, 2006, 04:34 AM
Registered User
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help invoking SOAP web service in C#

New to programming and need help on invoking a SOAP webservice in C#. Basically I need a way to pass in two parameters (Device ID and User ID) in a click event that transforms into a SOAP message, sends the webrequest, an returns the XML results into a dataset.

I'm not getting a response from my Web Request code below. The code I have is calling the webservice WSDL using Http/Querystring style web request. Is the WebRequest/WebReponse object suitable for invoking SOAP webservices? I don't think my request is recognized by the SOAP WSDL as I'm getting an error message during the response.

Please let me know what modifications I need to make. Any help is appreciated. Thanks. - Henry

            public DataSet GetMeter( string DEVICEID, string UID)


                  //create a web request object

                  WebRequest request = WebRequest.Create(ConfigurationSettings.AppSetting s["METERURL"]); //Add MeterPing URL to web.config

                  request.Method = "POST";

                  request.ContentType = "application/x-www-form-urlencoded";

                  Stream aStream = request.GetRequestStream ();

                  StreamWriter aStreamWriter = new StreamWriter(aStream);

                  StringBuilder aStringBuilder = new StringBuilder();

                  XmlDataDocument myDoc = new XmlDataDocument();

                  aStringBuilder.Append("message=<MeterRequest><serv iceRequestTimeStamp>" + System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "</serviceRequestTimeStamp><deviceNumber>" + DEVICEID + "</deviceNumber><deviceType>Generic</deviceType><requestorID>CC" + UID + "</requestorID></MeterRequest>");


                  //Close the output stream and send the data out to the web server


                  //get the response object from the request.

                  WebResponse response = request.GetResponse(); //todo: see if request.timeout default needs to be changed

Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Service Parameter - String vs SOAP attachment ndr1977 .NET Web Services 1 August 31st, 2009 02:02 AM
Invoking a web service on New User creation in AD Anitha Karthik BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 August 28th, 2008 01:15 AM
C# client for SOAP::Lite web service wirespring C# 0 December 8th, 2006 07:14 PM
Invoking service second time but no results aschilles .NET Web Services 0 April 7th, 2005 12:49 PM
JAVA SOAP and service registeration pcfeifei J2EE 0 May 19th, 2004 10:00 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.