tags:

views:

129

answers:

3

I am investigating an existing system that relies on SOAP messages to be passed between the various executables. I am trying to replace one of those applications with one of my own, and looking at the documentation, I am running into a difficulty.

I haven't worked with SOAP prior to this and am not sure what tools to use to accomplish this task, nor even what keywords I should be searching for. What I need to do is to be able to create a SOAP message that looks like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema"
> <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt; <GetSpecialList xmlns="SpecialManagerAPI"/> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

And, I need to send it via TCP to the local IP (127.0.0.1) port 1234 and get responses from it. How do I create above message and what is an easy way to send it?

+1  A: 

I strongly recommend you take some time to learn at least a little about web services. You are already off on the wrong track in terms of thinking about creating and sending messages.

One good resource is Getting Started with Windows Communication Foundation. Also, see the webcast Overview (Level 100).

John Saunders
A: 

System.Web.HttpRequestClass would be the bare bones way of doing this. You'll need to set the headers appropriately (especially the "SOAPAction" header). However I'd advise you against doing this! Find the wsdl for the service and use it to build your classes with either AddWebReference in Visual Studio or Wsdl.exe. This will build a well formed class for you (or several) to work with!

C. Ross
A: 

You have three basic options:

  1. If the service has a WSDL or DISCO service description you can connect to it via Add Service Reference (VS 2008 and VS 2005 with certain WCF addons) or Add Web Reference (VS 2005). The command line equivalents of those tools to generate soap client classes are svcutil.exe and wsdl.exe respectively.
  2. You can do as C. Ross suggested in his answerand use the HttpRequestClass using a custom built string.
  3. You can is the XmlDocument class to create the xml message and use the HttpRequest class to send it. I suggest you make a template xml document and save it as an embedded resource in your executable. You can then do xpath queries to modify the parameters.
Justin Dearing