Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions issue1161/MyMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.ServiceModel;
using System.Xml;
using System.Xml.Serialization;

[MessageContract]
public class MyMessage {
private string _body;

[MessageHeader(Name = "MessageHeader", Namespace = "http://www.ebxml.org/namespaces/messageHeader")]
public MyMessageHeader Header { get; set; }

[MessageBodyMember]
public string BodyMessage
{
get => _body;
set => _body = value;
}
}


[XmlType(AnonymousType = true, Namespace = "http://www.ebxml.org/namespaces/messageHeader")]
public class MyMessageHeader
{
private string _from;
private XmlAttribute[] _anyAttr;

[XmlElement(Order = 0)]
public string From
{
get => _from;
set => _from = value;
}

[XmlAnyAttribute]
public XmlAttribute[] SomeOtherAttributes
{
get => _anyAttr;
set => _anyAttr = value;
}
}
17 changes: 17 additions & 0 deletions issue1161/MySoapService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.ServiceModel;

[ServiceContract]
public interface IMySoapService
{
[OperationContract]
MyMessage Process(MyMessage rq);
}

public class MySoapService : IMySoapService
{
public MyMessage Process(MyMessage msg)
{
return msg;
}

}
22 changes: 22 additions & 0 deletions issue1161/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.ServiceModel.Channels;
using SoapCore;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSoapCore();
builder.Services.AddSingleton<IMySoapService, MySoapService>();

var app = builder.Build();


app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.UseSoapEndpoint<IMySoapService>("/myService", new SoapEncoderOptions()
{
MessageVersion = MessageVersion.Soap11
},
SoapSerializer.XmlSerializer);
});

app.Run();
31 changes: 31 additions & 0 deletions issue1161/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:15581",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "myService",
"applicationUrl": "http://localhost:5220",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "myService",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
14 changes: 14 additions & 0 deletions issue1161/SoapCore-Issue-1161.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>SoapCore_Issue_1161</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\src\SoapCore\SoapCore.csproj" />
</ItemGroup>

</Project>
46 changes: 46 additions & 0 deletions issue1161/SoapCore-Issue-1161.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@SoapCore_Issue_1161_HostAddress = http://localhost:5220

### Get WSDL
GET {{SoapCore_Issue_1161_HostAddress}}/myService
Accept: application/json


### Test SOAP ProcessUser (passes)
POST {{SoapCore_Issue_1161_HostAddress}}/myService
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IMySoapService/Process"

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<MessageHeader xmlns="http://www.ebxml.org/namespaces/messageHeader" >
<From>SomeSender</From>
</MessageHeader>
</s:Header>
<s:Body>
<MyMessage xmlns="http://tempuri.org/">
<BodyMessage>someBody</BodyMessage>
</MyMessage>
</s:Body>
</s:Envelope>

### Test SOAP ProcessUser (fails with SoapCore 1.2.1)
POST {{SoapCore_Issue_1161_HostAddress}}/myService
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IMySoapService/Process"

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:MessageHeader xmlns:h="http://www.ebxml.org/namespaces/messageHeader"
xmlns="http://www.ebxml.org/namespaces/messageHeader" >
<From>SomeSender</From>
</h:MessageHeader>
</s:Header>
<s:Body>
<MyMessage xmlns="http://tempuri.org/">
<BodyMessage>someBody</BodyMessage>
</MyMessage>
</s:Body>
</s:Envelope>

8 changes: 8 additions & 0 deletions issue1161/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions issue1161/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
4 changes: 4 additions & 0 deletions src/SoapCore.Tests/ITestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SoapCore.Tests.Model;
using SoapCore.Tests.Serialization.Models.DataContract;

namespace SoapCore.Tests
{
Expand Down Expand Up @@ -106,6 +107,9 @@ public interface ITestService
[OperationContract]
XmlElement XmlElementInput(XmlElement input);

[OperationContract]
MessageHeadersModelWithDuplicateNamespaces GetWithDuplicateNamespaces(MessageHeadersModelWithDuplicateNamespaces input);

/// <summary>
/// Return type is different than the one bellow due to customizations. Use SoapCore.Tests.NativeAuthenticationAndAuthorization.IActionResultContractService to access these endpoints.
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions src/SoapCore.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ public void XmlElemetInput()
Assert.IsTrue(output.OuterXml.Contains("Success"));
}

[TestMethod]
public void MessageWithDuplicateNamespace()
{
var client = CreateClient();
var output = client.GetWithDuplicateNamespaces(new ()
{
BodyMessage = "test",
Header = new () { From = "test" }
});

Assert.AreEqual("test", output.BodyMessage);
Assert.AreEqual("test", output.Header.From);
}

[TestMethod]
public void ThrowsFaultException()
{
Expand Down
32 changes: 32 additions & 0 deletions src/SoapCore.Tests/Serialization/MessageHeadersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,37 @@ public void TestMessageHeadersModelWithNamespace(SoapSerializer serializer)
Assert.Equal(model.Prop3, result.Prop3);
Assert.Equal(model.Prop4, result.Prop4);
}

[Theory]
[InlineData(SoapSerializer.XmlSerializer)]
public void TestMessageWithDuplicateNamespace(SoapSerializer serializer)
{
var service = _fixture.GetSampleServiceClient(serializer);
var model = new MessageHeadersModelWithDuplicateNamespaces
{
BodyMessage = "test",
Header = new MessageHeadersModelWithDuplicateNamespacesHeader()
{
From = "test"
}
};

_fixture.ServiceMock.Setup(x => x.GetWithDuplicateNamespaces(It.IsAny<MessageHeadersModelWithDuplicateNamespaces>())).Callback((MessageHeadersModelWithDuplicateNamespaces m) =>
{
m.ShouldDeepEqual(model);
}).Returns(new MessageHeadersModelWithDuplicateNamespaces
{
BodyMessage = "test",
Header = new MessageHeadersModelWithDuplicateNamespacesHeader()
{
From = "test"
}
});

var result = service.GetWithDuplicateNamespaces(model);

Assert.Equal(model.BodyMessage, result.BodyMessage);
Assert.Equal(model.Header.From, result.Header.From);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ public interface ISampleServiceWithMessageHeaders

[OperationContract]
MessageHeadersModelWithNamespace GetWithNamespace(MessageHeadersModelWithNamespace model);

[OperationContract]
MessageHeadersModelWithDuplicateNamespaces GetWithDuplicateNamespaces(MessageHeadersModelWithDuplicateNamespaces input);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Runtime.Serialization;
using System.ServiceModel;

namespace SoapCore.Tests.Serialization.Models.DataContract;

[MessageContract]
public class MessageHeadersModelWithDuplicateNamespaces
{
[MessageHeader(Name = "MessageHeader", Namespace = "MessageWithNamespacesHeaderNamespace")]
public MessageHeadersModelWithDuplicateNamespacesHeader Header { get; set; }

[MessageBodyMember]
public string BodyMessage { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Xml;
using System.Xml.Serialization;

namespace SoapCore.Tests.Serialization.Models.DataContract;

[XmlType(AnonymousType = true, Namespace = "MessageWithNamespacesHeaderNamespace")]
public class MessageHeadersModelWithDuplicateNamespacesHeader
{
[XmlElement(Order = 0)]
public string From { get; set; }

[XmlAnyAttribute]
public XmlAttribute[] SomeOtherAttributes { get; set; }
}
2 changes: 1 addition & 1 deletion src/SoapCore.Tests/SoapCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Formats.Asn1" Version="9.0.2"/>
<PackageReference Include="System.Formats.Asn1" Version="9.0.2" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="9.0.2" />
</ItemGroup>

Expand Down
6 changes: 6 additions & 0 deletions src/SoapCore.Tests/TestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Xml;
using Microsoft.AspNetCore.Mvc;
using SoapCore.Tests.Model;
using SoapCore.Tests.Serialization.Models.DataContract;

namespace SoapCore.Tests
{
Expand Down Expand Up @@ -366,5 +367,10 @@ public ActionResult<ComplexModelInput> JwtAuthenticationAndAuthorizationComplexG
};
}
}

public MessageHeadersModelWithDuplicateNamespaces GetWithDuplicateNamespaces(MessageHeadersModelWithDuplicateNamespaces input)
{
return input;
}
}
}
18 changes: 16 additions & 2 deletions src/SoapCore.sln
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
# Visual Studio Version 17
VisualStudioVersion = 17.14.36705.20 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoapCore", "SoapCore\SoapCore.csproj", "{576F47D4-97EC-4D42-8CD5-89648EEAB688}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoapCore.Tests", "SoapCore.Tests\SoapCore.Tests.csproj", "{2B200D78-B473-4590-9E4C-532AD0219BA9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoapCore.Benchmark", "SoapCore.Benchmark\SoapCore.Benchmark.csproj", "{B54A69DB-ADA2-48E0-A0D7-7649EDA987E1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoapCore-Issue-1161", "..\issue1161\SoapCore-Issue-1161.csproj", "{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -54,6 +56,18 @@ Global
{B54A69DB-ADA2-48E0-A0D7-7649EDA987E1}.Release|x64.Build.0 = Release|Any CPU
{B54A69DB-ADA2-48E0-A0D7-7649EDA987E1}.Release|x86.ActiveCfg = Release|Any CPU
{B54A69DB-ADA2-48E0-A0D7-7649EDA987E1}.Release|x86.Build.0 = Release|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Debug|x64.ActiveCfg = Debug|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Debug|x64.Build.0 = Debug|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Debug|x86.ActiveCfg = Debug|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Debug|x86.Build.0 = Debug|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Release|Any CPU.Build.0 = Release|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Release|x64.ActiveCfg = Release|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Release|x64.Build.0 = Release|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Release|x86.ActiveCfg = Release|Any CPU
{26918EE6-B839-7C0E-D4D1-5C9BAD20B69F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down