Reputation: 419
I would like to know how to create SOAP message, body, and envelope in C#. Any help or links appreciated.
I need to send a SOAP attachment to a third party Web Service. I don't need WCF. I know how it works. My client needs SOAP with attachment.
Upvotes: 3
Views: 5834
Reputation: 51
marc_s: learn SOAP with Attachments before recommending others to learn WCF. SwA is not supported by .Net so he's got to roll his own and that is the background for his question.
Upvotes: 2
Reputation: 1683
Check this link out http://www.xefteri.com/articles/show.cfm?id=15 It describes process for VS.NET, but in VS2010 it is same process. This was an easiest way.
However, if you can construct SOAP message (for example, if you read WSDL and can construct message without any issues or you used something like SOAP UI (http://www.soapui.org/) to generate few mock up messages and got an idea) then you can simply do POST to that URL like in this example http://www.808.dk/?code-csharp-httpwebrequest
Upvotes: 1
Reputation: 754220
Here's a really super-short intro how to do this:
1) Create a new project (any kind - console app, windows app, web app - whatever) - File > New > Project
2) In your Solution Explorer, right-click on References
and choose Add Service Reference
3) In the dialog box that pops up, you need to enter two things:
?wsdl
query string to grab the WSDL - the service description)Then click on Go
- this will talk to that service and see what it has to offer
4) Now, that dialog box should update, and show you the service and its operations, as discovered by Visual Studio:
5) Click on OK
and some code gets generated in the background
6) Now instantiate a client-side proxy in your code, and call a method on it:
That's all you have to do - everything else, all the messy details of creating a SOAP header and message body, can be happily left to the WCF runtime.
Now go learn WCF!
Upvotes: 12