Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to POST a SOAP message on web api (asp.net core ->web api)

I want to post a SOAP XML based message to Web API which i have created in ASP.NET core project template.

Right now i am getting unsupported media type error when i post with with content-type as application/soap+xml.

I know that we should be sending SOAP message to WCF based service but our requirement is like this only. I should be able to consume SOPA message in web API.

Thanks, Sudama

like image 982
Sudama Tripathi Avatar asked Feb 01 '26 18:02

Sudama Tripathi


2 Answers

Here is a two-part answer:

Exposing SOAP services with ASP.NET Core:

  • Microsoft is not looking into porting SOAP-capable services in ASP.NET Core, not in a near future (look at this other SO answer which states the same).

  • That being said, nothing is preventing you from using the plain .NET Framework, which supports SOAP either using old ASMX or WCF which are part of .NET Framework 4.5.x at least (with support ending in 2023).

  • Lastly, SOAP seems just a technical requirement for you, so you can build a thin SOAP layer just transfering calls to your main ASP.NET Core service.

The only limitation would be to support deploying this on Linux, on which the full .NET Framework does not natively run on; if not, you're good to go.

Consuming SOAP services win ASP.NET Core:

ASP.NET Core supports consuming SOAP Services in ASP.NET Core through the use of WCF Connected services.

like image 69
Benjamin Soulier Avatar answered Feb 04 '26 11:02

Benjamin Soulier


I know this was answered however, for future reference, I also implemented a similar solution to Sudama.

I had a requirement for a SOAP message to be consumed that was transmitted from Salesforce, no other options were available so I implemented a SOAP Formatter in .Net Core that transformed the incoming request.

There were a few technical challenges with the read-once stream for the body of the request but if you find it useful I have included a link to the project code below:

https://github.com/TNDStudios/TNDStudios.Salesforce.OutboundReceiver

like image 20
Joe Walters Avatar answered Feb 04 '26 10:02

Joe Walters



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!