Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2007

Tip: Looking for answers? Try searching our database.

Manually Send SOAP Envelope?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lucius - 23 Feb 2007 18:18 GMT
I would like to manually send/post a SOAP envelope to a remote web
service without binding to a WSDL. I would do this with .NET Framework
1.1 by referencing the Microsoft.Web.Services2.SoapEnvelope class
within the Microsoft.Web.Services2.dll.

The envelope looks like this:

<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
<testCall xmlns=""http://testdomain.com/svc/svc"" >
<paramOne>aaa1</paramOne>
</testCall>
</soap:Body>
</soap:Envelope>

I would now like to do the same but use what is built into .NET
Framework 2.0. How can I just pass the above envelope (using HTTP
POST) and get a result?

Thanks.
John Saunders - 23 Feb 2007 18:40 GMT
> I would like to manually send/post a SOAP envelope to a remote web
> service without binding to a WSDL.

I presume that you want to send more than just the envelope, but the body as
well?

In that case, just rememebr that SOAP is XML. So, "manually send/post a SOAP
envelope" is the same as "manually send/post XML".

John
Steven Cheng[MSFT] - 26 Feb 2007 02:11 GMT
Hello lucius,

As John has suggested, you can post the webservice request message as plain
XML text. Generally, all the webservice method calls are serialized as XML
soap message that be transferred over wire(http or tcp channel), therefore,
if the soap message is not quite complex which can be constructed
manually(through XML api), you can directly use network component to send
such XML soap message. In .net framework, the httpwebrequest class is a
encapsulated one for send http request. Here are some articles & thread
discussing on send text data through httpwebrequest.

http://www.netomatix.com/Development/XmlWebRequest.aspx

http://www.thescripts.com/forum/thread427794.html

Here is a simple test code fragment that use httpwebrequest to send
webservice request
================
static void TestWebMethod()
       {
           HttpWebRequest req =
WebRequest.Create("http://localhost:3697/MainService/simpleservice.asmx")
as HttpWebRequest;

           req.ContentType = "application/soap+xml";
           req.Method = "POST";

           StreamWriter sw = new StreamWriter(req.GetRequestStream(),
Encoding.UTF8);

           StreamReader sr = new StreamReader(@"..\..\soap_template.xml",
Encoding.UTF8);
           string soap = sr.ReadToEnd();
           sr.Close();

           sw.Write(soap);

           sw.Close();

           HttpWebResponse rep = req.GetResponse() as HttpWebResponse;

           sr = new StreamReader(rep.GetResponseStream(), Encoding.UTF8);

           Console.WriteLine(sr.ReadToEnd());

           sr.Close();
           
       }
=========================

=======soap_template.xml=====
<?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>
   <HelloWorld xmlns="http://tempuri.org/" />
 </soap12:Body>
</soap12:Envelope>
=====================

also, for .net framework 2.0, the coupled WSE is version 3.0, you can also
use its SoapSender to send soap message.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
Steven Cheng[MSFT] - 28 Feb 2007 09:45 GMT
Hello Lucius,

Does the information in previous reply helps you some? If you still need
any further assistance on this ,please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.