Comments (3)
Should be fixed in #1033
from soapcore.
Yes, that should be a TryParse.
The configured WriteEncoding will be used as a fallback if this method returns null, so there is already logic for that.
With that said it can be necessary to add a custom middleware to set Content-Type anyways.
In my legacy service a few clients sent SOAP1.2 envelopes without Content-Type set and that fails.
I solved that with a regular asp.net middleware (affects performance, but in my case it's much more important to stay backwards compatible than to maximize performance.
const string Soap12NS = "http://www.w3.org/2003/05/soap-envelope";
app.Use(async (context, next) =>
{
if (context.Request.Method == "POST")
{
//This line allows us to set the reader for the request back at the beginning of its stream.
context.Request.EnableBuffering();
//We convert the byte[] into a string using UTF8 encoding...
var bodyAsText = Encoding.UTF8.GetString(await context.Request.Body.ReadFullyAsync());
try
{
var xdoc = XDocument.Parse(bodyAsText);
bodyAsText = xdoc.ToString();
context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(bodyAsText));
//Logging!
await SoapMessageLog.WriteLog(context, bodyAsText);
//Upgrade Content-Type if Envelope is Soap1.2
if (context.Request.Headers["Content-Type"] != "application/soap+xml")
{
var envelope = xdoc.Descendants().FirstOrDefault(x => x.Name.LocalName == "Envelope");
if (envelope != null && envelope.Name.ToString().Contains(Soap12NS))
{
context.Request.Headers["Content-Type"] = "application/soap+xml";
}
}
}
catch
{ }
//..and finally, assign the read body back to the request body, which is allowed because of EnableRewind()
context.Request.Body.Position = 0;
}
await next();
}
);
from soapcore.
Ha, the use case I have is not a standard SoapCore use case, so I did the "dumb" workaround by simply using request.ContentType ?? "application/xm; charset=utf-8"
using ReadMessageAsync
within SoapMessageEncoder
Appreciate the rapid change!
from soapcore.
Related Issues (20)
- Upgrade the supported frameworks to .NET 8.0 HOT 5
- 500 Error code for a Bad XML body HOT 1
- XmlSerializer: Empty `<xsd:import />` tag in generated WSDL
- performance issue as well while reading the body for the soap request, i got the memory dump, and this is the img HOT 19
- Response of 'HttpGet' requests does not return the response HOT 1
- Disable information logging on all receive/request HOT 2
- WSA Envelope Headers HOT 2
- Set license expression on nuget package HOT 1
- Optimise dependency based on TFM HOT 1
- Is it expected behavior to use ServiceContractAttribute namespace as SOAP Response body namespace? HOT 2
- Soap core .NET 8 throws an exception when navigating to the service endpoint.
- CaseInsensitivePath is not respected when comparing the operation name HOT 2
- Complex data types HOT 4
- More descriptive InvalidOperationException message in MetaBodyWriter class HOT 2
- Using AdditionalEnvelopeXmlnsAttributes does not work. HOT 1
- Can't use webmethod with accent HOT 7
- ambiguous method for UseSoapEndpoint HOT 2
- Empty attributes namespace with parent node namespace HOT 4
- DataContract.Name is ignored for generic types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from soapcore.