Skip to content

"utf-8" Quotation Marks at encoding leads to error // Fix Found? #19

Description

@M4nju

The old Mtom Soap Service we need to use in our .net core project returns as Content-Type this value:
Content-Type: application/xop+xml; type="application/soap+xml"; charset="utf-8"

Error Message:
Encoding is not supported ""utf-8""

The quotation marks lead to an error while trying to find the correct charset encoding. At one place in this library the quotation marks are replaced, but this seems not to be enough. I made a small change inside the class "MtomPart" at the Property ContentType, which did the job:

 public MediaTypeHeaderValue ContentType
        {
            get
            {
                string contentTypeHeaderValue = _part.Headers.GetValues("Content-Type").FirstOrDefault();

                if (!String.IsNullOrEmpty(contentTypeHeaderValue) && MediaTypeHeaderValue.TryParse(contentTypeHeaderValue.TrimEnd(';'), out var parsedValue))
                {
                    parsedValue.CharSet= parsedValue.CharSet.Replace("\"", "");
                    parsedValue.MediaType= parsedValue.MediaType.Replace("\"", "");
                    return parsedValue;
                }

                return _part.Headers.ContentType;
            }
        }

Could you release a new nuget package version with this fix?

Any way thanks for the great work with the mtom implementation :D

Regards
Manju

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions