├── .github
└── workflows
│ ├── close_inactive_issues.yml
│ ├── codeql-analysis.yml
│ ├── continuous-integration-workflow.yml
│ └── publish.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── samples
├── Client
│ ├── Client.csproj
│ └── Program.cs
├── Models
│ ├── ComplexModelInput.cs
│ ├── ComplexModelResponse.cs
│ ├── ComplexReturnModel.cs
│ ├── ISampleService.cs
│ └── Models.csproj
├── Sample.sln
├── Server
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── SampleService.cs
│ ├── Server.csproj
│ └── Startup.cs
└── ServiceReferenceClient
│ ├── Connected Services
│ └── ServiceReference
│ │ ├── ConnectedService.json
│ │ └── Reference.cs
│ ├── Program.cs
│ └── ServiceReferenceClient.csproj
└── src
├── .editorconfig
├── Directory.Build.props
├── SoapCore.Benchmark
├── PingService.cs
├── Program.cs
├── SoapCore.Benchmark.csproj
└── Startup.cs
├── SoapCore.Tests
├── ActionFilter
│ ├── ActionFilterTests.cs
│ └── TestActionFilter.cs
├── CustomMessageFault.cs
├── FaultExceptionTransformer
│ ├── FaultExceptionTransformerTests.cs
│ ├── Startup.cs
│ ├── TestFault.cs
│ └── TestFaultExceptionTransformer.cs
├── ITestService.cs
├── IntegrationTests.cs
├── InvalidXMLTests.cs
├── MessageContract
│ ├── Models
│ │ ├── IArrayOfArrayOfByteService.cs
│ │ ├── IArrayOfIntService.cs
│ │ ├── IServiceWithMessageContract.cs
│ │ ├── IServiceWithMessageContractComplexNotWrapped.cs
│ │ ├── IServiceWithMessageContractNotWrapped.cs
│ │ ├── IServiceWithMessageContractWrapped.cs
│ │ └── IStartupConfiguration.cs
│ ├── RawRequestSoap11And12.cs
│ ├── RawRequestSoap11Tests.cs
│ ├── Startup.cs
│ ├── TestService.cs
│ ├── TestServiceComplexNotWrapped.cs
│ ├── TestServiceNotWrapped.cs
│ └── TestServiceWrapped.cs
├── MessageFilter
│ ├── RawMessageFilterTests.cs
│ ├── Startup.cs
│ └── WsMessageFilterTests.cs
├── MessageInspectors
│ ├── InspectorStyle.cs
│ ├── MessageInspector2
│ │ ├── MessageInspector2Mock.cs
│ │ ├── MessageInspector2MockNoException.cs
│ │ ├── MessageInspector2NoExceptionTests.cs
│ │ └── MessageInspector2Tests.cs
│ └── Startup.cs
├── Model
│ ├── ComplexInheritanceModelInputA.cs
│ ├── ComplexInheritanceModelInputB.cs
│ ├── ComplexInheritanceModelInputBase.cs
│ ├── ComplexModelInput.cs
│ ├── ComplexModelInputForModelBindingFilter.cs
│ ├── ComplexTreeModelInput.cs
│ ├── EmptyMembers.cs
│ ├── FaultDetail.cs
│ ├── IComplexTreeModelInput.cs
│ ├── MessageContractRequest.cs
│ ├── MessageContractRequestComplexNotWrapped.cs
│ ├── MessageContractRequestEmpty.cs
│ ├── MessageContractRequestNotWrapped.cs
│ ├── MessageContractResponse.cs
│ └── MessageContractResponseNotWrapped.cs
├── ModelBindingFilter
│ ├── ModelBindingFilterTests.cs
│ └── TestModelBindingFilter.cs
├── NativeAuthenticationAndAuthorization
│ ├── AuthorizationHeaderEndpointBehavior.cs
│ ├── AuthorizationHeaderMessageHandler.cs
│ ├── ITestService.cs
│ ├── NativeAuthenticationAndAuthorizationTests.cs
│ └── TestService.cs
├── OperationDescription
│ ├── IServiceWithMessageContract.cs
│ ├── IServiceWithMessageContractAndEmptyXmlRoot.cs
│ ├── Model
│ │ ├── ClassWithEmptyXmlRoot.cs
│ │ ├── ClassWithXmlRoot.cs
│ │ ├── CoolResponseClass.cs
│ │ └── TypedSoapFault.cs
│ └── OperationDescriptionTests.cs
├── RawRequestSoap11Tests.cs
├── RawRequestSoap12Tests.cs
├── RequestArgumentsOrder
│ ├── IOriginalParametersOrderService.cs
│ ├── IReversedParametersOrderService.cs
│ ├── RequestArgumentsOrderTests.cs
│ ├── ServiceFixture.cs
│ └── ServiceNamespace.cs
├── Serialization
│ ├── DataContractSerializationTests.cs
│ ├── MessageHeadersTests.cs
│ ├── Models.DataContract
│ │ ├── ComplexModel1.cs
│ │ ├── ComplexModel2.cs
│ │ ├── ComplexObject.cs
│ │ ├── ISampleService.cs
│ │ ├── ISampleServiceWithMessageHeaders.cs
│ │ ├── MessageHeadersModelWithBody.cs
│ │ ├── MessageHeadersModelWithBodyAndNamespace.cs
│ │ ├── MessageHeadersModelWithNamespace.cs
│ │ └── SampleEnum.cs
│ ├── Models.Xml
│ │ ├── BasicMessageContractPayload.cs
│ │ ├── ComplexLegacyModel.cs
│ │ ├── ComplexModel1.cs
│ │ ├── ComplexModel2.cs
│ │ ├── ComplexObject.cs
│ │ ├── DataContractWithStream.cs
│ │ ├── DataContractWithoutNamespace.cs
│ │ ├── ISampleService.cs
│ │ ├── MessageContractRequestRpcStyle.cs
│ │ ├── MessageContractRequestWithArrays.cs
│ │ ├── MessageContractResponseRpcStyle.cs
│ │ ├── MessageContractResponseWithArrays.cs
│ │ ├── NotWrappedFieldComplexInput.cs
│ │ ├── NotWrappedFieldComplexInputRequest.cs
│ │ ├── NotWrappedFieldComplexInputResponse.cs
│ │ ├── NotWrappedFieldDoubleComplexInputRequest.cs
│ │ ├── NotWrappedPropertyComplexInput.cs
│ │ ├── NotWrappedPropertyComplexInputRequest.cs
│ │ ├── NotWrappedPropertyComplexInputResponse.cs
│ │ ├── PingComplexMessageHeaderArrayRequest.cs
│ │ ├── PingComplexMessageHeaderArrayResponse.cs
│ │ ├── PingComplexMessageMessageContractAttributeResponse.cs
│ │ ├── PingComplexModelOldStyleRequest.cs
│ │ ├── PingComplexModelOldStyleResponse.cs
│ │ ├── SampleEnum.cs
│ │ ├── ServiceNamespace.cs
│ │ ├── UnwrappedMultipleMessageBodyMemberResponse.cs
│ │ └── UnwrappedStringMessageBodyMemberResponse.cs
│ ├── ServiceFixture.cs
│ ├── XmlSerializationTests.cs
│ └── xunit.runner.json
├── SerializerProviderTests.cs
├── ServiceDescription
│ ├── IServiceWithName.cs
│ ├── IServiceWithoutName.cs
│ └── ServiceContractTests.cs
├── ServiceOperationTuner
│ ├── ClientMessageInspector.cs
│ ├── CustomHeadersEndpointBehavior.cs
│ ├── ServiceOperationTunerTests.cs
│ ├── Startup.cs
│ └── TestServiceOperationTuner.cs
├── SoapCore.Tests.csproj
├── SoapMessageProcessor
│ ├── SoapMessageProcessorTests.cs
│ └── Startup.cs
├── Startup.cs
├── TestService.cs
├── TestServiceKnownTypesProvider.cs
├── TrailingServicePathTuner
│ ├── ISoapService.cs
│ ├── MockModelBounder.cs
│ ├── MockServiceProvider.cs
│ ├── MockSoapService.cs
│ └── TrailingServicePathTunerTests.cs
├── Utilities
│ ├── CustomTextMessageBindingElement.cs
│ ├── CustomTextMessageEncoder.cs
│ ├── CustomTextMessageEncoderFactory.cs
│ └── XElementExtensions.cs
├── Wsdl
│ ├── DefaultWsdlOperationNameGeneratorTests.cs
│ ├── IStartupConfiguration.cs
│ ├── Services
│ │ ├── ArrayOfStringModel.cs
│ │ ├── ArrayService.cs
│ │ ├── AttributeType.cs
│ │ ├── CircularReferenceFirstObject.cs
│ │ ├── CircularReferenceSecondObject.cs
│ │ ├── ComplexComplexType.cs
│ │ ├── ComplexType.cs
│ │ ├── ComplexTypeAnonymous.cs
│ │ ├── CustomDictionary.cs
│ │ ├── Date.cs
│ │ ├── DefaultValuesAttributesService.cs
│ │ ├── EmptyMembers.cs
│ │ ├── EnumWithCustomNames.cs
│ │ ├── ErrorDetail.cs
│ │ ├── FailedOperation.cs
│ │ ├── IActionResultContractService.cs
│ │ ├── IAnonymousServiceKnownTypesService.cs
│ │ ├── IAttributeService.cs
│ │ ├── ICollectionDataContractService.cs
│ │ ├── IComplexAnonymousListService.cs
│ │ ├── IComplexBaseTypeService.cs
│ │ ├── IComplexComplexTypeWithCustomXmlNamesService.cs
│ │ ├── IComplexTypeAndOutParameterService.cs
│ │ ├── IDataContractCircularReferenceService.cs
│ │ ├── IDataContractContainsItselfService.cs
│ │ ├── IDataContractNameService.cs
│ │ ├── IDataContractWithNonDataMembersService.cs
│ │ ├── IDatetimeOffsetService.cs
│ │ ├── IDictionaryTypeListService.cs
│ │ ├── IEmptyNamespaceService.cs
│ │ ├── IEnumListService.cs
│ │ ├── IEnumService.cs
│ │ ├── IEnumWithCustomNamesService.cs
│ │ ├── IGenericDataContractService.cs
│ │ ├── IInheritanceService.cs
│ │ ├── INonNullableEnumService.cs
│ │ ├── INullableEnumService.cs
│ │ ├── IObjectWithArrayService.cs
│ │ ├── IOperationContractEmptyMembersService.cs
│ │ ├── IOperationContractFieldMembersService.cs
│ │ ├── IOperationContractFieldMembersServiceWrapped.cs
│ │ ├── IPortTypeService.cs
│ │ ├── IServiceKnownTypesService.cs
│ │ ├── IServiceWithFaultContracts.cs
│ │ ├── IServiceWithSoapHeaders.cs
│ │ ├── ISpecifiedBoolService.cs
│ │ ├── IStreamService.cs
│ │ ├── IStringListService.cs
│ │ ├── IStructsService.cs
│ │ ├── ISystemImportService.cs
│ │ ├── ISystemTypesService.cs
│ │ ├── ITaskNoReturnService.cs
│ │ ├── ITestMultipleTypesService.cs
│ │ ├── IUnqualifiedMembersService.cs
│ │ ├── IValueTypeService.cs
│ │ ├── IXmlArrayAttributeService.cs
│ │ ├── IXmlIncludeService.cs
│ │ ├── IXmlSchemaProviderTypeService.cs
│ │ ├── MessageAttributesService.cs
│ │ ├── MyClass.cs
│ │ ├── MyClassWithArray.cs
│ │ ├── NulEnum.cs
│ │ ├── OperationFault.cs
│ │ ├── PaymentResponse.cs
│ │ ├── TypeWithFields.cs
│ │ ├── TypeWithNonDataMembers.cs
│ │ ├── TypeWithUnqualifiedMembers.cs
│ │ ├── XmlAnnotatedChoiceReturnService.cs
│ │ └── XmlModelsService.cs
│ ├── Startup.cs
│ └── WsdlTests.cs
├── WsdlFromFile
│ ├── IStartupConfiguration.cs
│ ├── Services
│ │ ├── EchoIncludeService.cs
│ │ ├── EchoIncludeSvc.cs
│ │ ├── MeasurementSiteTablePublicationService.cs
│ │ └── SnapshotPullSvc.cs
│ ├── Startup.cs
│ ├── WSDL
│ │ ├── DATEXII_3_Common.xsd
│ │ ├── DATEXII_3_D2Payload.xsd
│ │ ├── DATEXII_3_ExchangeInformation.xsd
│ │ ├── DATEXII_3_LocationReferencing.xsd
│ │ ├── DATEXII_3_MessageContainer.xsd
│ │ ├── DATEXII_3_RoadTrafficData.xsd
│ │ ├── SnapshotPull.wsdl
│ │ ├── echoInclude.wsdl
│ │ ├── echoInclude.xsd
│ │ └── echoIncluded.xsd
│ ├── WSDLInclude
│ │ ├── ServiceDefinitions.xml
│ │ ├── echoWsdlInclude.wsdl
│ │ ├── xsd00.xml
│ │ └── xsd02.xml
│ ├── WsdlIncludeTests.cs
│ └── WsdlTests.cs
├── XDocumentXmlReaderTests.cs
├── XmlNodeInputOutput
│ ├── IXmlNodeInputOutput.cs
│ ├── Startup.cs
│ ├── XmlNodeInputOutput.cs
│ └── XmlNodeInputOutputTests.cs
└── stylecop.json
├── SoapCore.ruleset
├── SoapCore.sln
├── SoapCore
├── CachedDataContractSerializer.cs
├── CachedXmlSerializer.cs
├── CustomMessage.cs
├── DefaultEncodings.cs
├── DefaultFaultExceptionTransformer.cs
├── DefaultOperationInvoker.cs
├── DocumentationWriter
│ ├── SoapBinding.cs
│ ├── SoapDefinition.cs
│ ├── SoapMessage.cs
│ ├── SoapMethods.cs
│ ├── SoapPortType.cs
│ ├── SoapService.cs
│ ├── SoapShared.cs
│ └── SoapTypes.cs
├── EnvelopeVersionExtentions.cs
├── Extensibility
│ ├── AuthorizeOperationMessageProcessor.cs
│ ├── ExceptionTransformer.cs
│ ├── IAsyncMessageFilter.cs
│ ├── IFaultExceptionTransformer.cs
│ ├── IMessageInspector2.cs
│ ├── IModelBindingFilter.cs
│ ├── IOperationInvoker.cs
│ ├── IServiceOperationTuner.cs
│ ├── ISoapMessageProcessor.cs
│ └── ISoapModelBounder.cs
├── FaultBodyWriter.cs
├── HeadersHelper.cs
├── IActionResultExtensions.cs
├── MemberWithAttribute.cs
├── MembersWithAttributeCache.cs
├── MessageEncoder
│ ├── SoapMessageEncoder.cs
│ └── SoapMessageEncoderDefaults.cs
├── MessageFaultBodyWriter.cs
├── Meta
│ ├── BodyWriterExtensions.cs
│ ├── ClrTypeResolver.cs
│ ├── IWsdlOperationNameGenerator.cs
│ ├── MetaBodyWriter.cs
│ ├── MetaFromFile.cs
│ ├── MetaMessage.cs
│ ├── MetaWCFBodyWriter.cs
│ ├── SoapBindingInfo.cs
│ └── TypeToBuild.cs
├── Namespaces.cs
├── ParsedMessage.cs
├── ParsedMessageBuffer.cs
├── ParsedMessageHeader.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── launchSettings.json
├── ReflectionExtensions.cs
├── Serializer
│ ├── IXmlSerializationHandler.cs
│ └── SerializerHelper.cs
├── ServiceBodyWriter.cs
├── ServiceModel
│ ├── ContractDescription.cs
│ ├── DataMemberDescription.cs
│ ├── OperationDescription.cs
│ ├── ReturnChoice.cs
│ ├── ServiceDescription.cs
│ ├── SoapHeader.cs
│ ├── SoapMethodParameterDirection.cs
│ └── SoapMethodParameterInfo.cs
├── SoapCore.csproj
├── SoapCore.snk
├── SoapCoreBufferManager.cs
├── SoapCoreOptions.cs
├── SoapEncoderOptions.cs
├── SoapEndpointExtensions.cs
├── SoapEndpointMiddleware.cs
├── SoapOptions.cs
├── SoapSerializer.cs
├── TrailingServicePathTuner.cs
├── TypesComparer.cs
├── WSDLFileOptions.cs
├── WebServiceWSDLMapping.cs
├── WsMessageFilter.cs
├── WsUsernameToken.cs
├── XDocumentXmlReader.cs
├── XmlSerializerExtensions.cs
└── stylecop.json
├── global.json
└── logo.png
/.github/workflows/close_inactive_issues.yml:
--------------------------------------------------------------------------------
1 | name: Close inactive issues
2 | on:
3 | schedule:
4 | - cron: '30 1 * * *'
5 | workflow_dispatch:
6 |
7 | jobs:
8 | close-issues:
9 | runs-on: ubuntu-latest
10 | permissions:
11 | issues: write
12 | pull-requests: write
13 | steps:
14 | - uses: actions/stale@v4
15 | with:
16 | days-before-issue-stale: 30
17 | days-before-issue-close: 14
18 | stale-issue-label: 'stale'
19 | exempt-issue-labels: 'bug,enhancement'
20 | stale-issue-message: 'This issue is stale because it has been open for 30 days with no activity.'
21 | close-issue-message: 'This issue was closed because it has been inactive for 14 days since being marked as stale.'
22 | days-before-pr-stale: -1
23 | days-before-pr-close: -1
24 | operations-per-run: 100
25 | ascending: true
26 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | name: "CodeQL"
2 |
3 | on:
4 | push:
5 | branches: [develop]
6 | pull_request:
7 | branches: [develop]
8 | schedule:
9 | - cron: '0 16 * * 0'
10 |
11 | jobs:
12 | analyze:
13 | name: Analyze
14 | runs-on: ubuntu-latest
15 |
16 | steps:
17 | - name: Checkout repository
18 | uses: actions/checkout@v2
19 |
20 | - name: Initialize CodeQL
21 | uses: github/codeql-action/init@v1
22 | with:
23 | languages: csharp
24 |
25 | - name: Setup .NET
26 | uses: actions/setup-dotnet@v1
27 | with:
28 | dotnet-version: '8.0.x'
29 |
30 | - name: Build with .NET
31 | run: dotnet build src/SoapCore.sln --configuration Release
32 |
33 | - name: Perform CodeQL Analysis
34 | uses: github/codeql-action/analyze@v1
35 |
--------------------------------------------------------------------------------
/.github/workflows/continuous-integration-workflow.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push, pull_request, pull_request_review]
4 |
5 | jobs:
6 | test:
7 | runs-on: ubuntu-latest
8 | container:
9 | image: docker://alpine
10 | steps:
11 | - uses: actions/checkout@v1
12 | - name: prepare deps
13 | run: apk add bash icu-libs krb5-libs libgcc libintl libssl3 libstdc++ zlib curl
14 | - name: install sdks
15 | run: cd /tmp && curl -L https://dot.net/v1/dotnet-install.sh --output dotnet-install.sh && chmod +x dotnet-install.sh && ./dotnet-install.sh -c 3.1 && ./dotnet-install.sh -c 8.0 && ln -s /github/home/.dotnet/dotnet /usr/bin/dotnet
16 | - name: build && test
17 | run: dotnet test src/SoapCore.Tests
18 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Nuget publish
2 |
3 | on:
4 | push:
5 | branches: master
6 | tags:
7 | - 'v*'
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 |
12 | container:
13 | image: docker://mcr.microsoft.com/dotnet/sdk:8.0-alpine
14 | steps:
15 |
16 | - uses: actions/checkout@v1
17 | - name: build and publish
18 | run: |
19 | dotnet restore src
20 | dotnet pack --configuration Release --output nupkg src/SoapCore
21 | dotnet nuget push nupkg/*.nupkg --api-key ${{ secrets.NUGET_API }} -s https://api.nuget.org/v3/index.json
22 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 | We are greating for all improvements, bug fixes and new features if it not break exists behaviour.
3 |
4 | ## Code style
5 | Code style described in stylecop ruleset file, checks perform on compile time. All violations of rules breaks project build.
6 | Principal moments:
7 | * use tabs
8 | * private fields named with prefix "_"
9 |
10 | ## PR
11 | For PR need:
12 | * Issue described what problem you solve
13 | * Code passed travis build (starts automatically)
14 | * Code is covered by tests
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/samples/Client/Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 | Exe
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/Client/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.Threading.Tasks;
6 | using Models;
7 |
8 | namespace Client
9 | {
10 | public class Program
11 | {
12 | public static void Main()
13 | {
14 | var binding = new BasicHttpBinding();
15 | var endpoint = new EndpointAddress(new Uri(string.Format("http://{0}:5050/Service.svc", Environment.MachineName)));
16 | var channelFactory = new ChannelFactory(binding, endpoint);
17 | var serviceClient = channelFactory.CreateChannel();
18 | var result = serviceClient.Ping("hey");
19 | Console.WriteLine("Ping method result: {0}", result);
20 |
21 | var complexModel = new ComplexModelInput
22 | {
23 | StringProperty = Guid.NewGuid().ToString(),
24 | IntProperty = int.MaxValue / 2,
25 | ListProperty = new List { "test", "list", "of", "strings" },
26 | DateTimeOffsetProperty = new DateTimeOffset(2018, 12, 31, 13, 59, 59, TimeSpan.FromHours(1))
27 | };
28 |
29 | var complexResult = serviceClient.PingComplexModel(complexModel);
30 | Console.WriteLine("PingComplexModel result. FloatProperty: {0}, StringProperty: {1}, ListProperty: {2}, DateTimeOffsetProperty: {3}, EnumProperty: {4}",
31 | complexResult.FloatProperty, complexResult.StringProperty, string.Join(", ", complexResult.ListProperty), complexResult.DateTimeOffsetProperty, complexResult.TestEnum);
32 |
33 | serviceClient.VoidMethod(out var stringValue);
34 | Console.WriteLine("Void method result: {0}", stringValue);
35 |
36 | var asyncMethodResult = serviceClient.AsyncMethod().Result;
37 | Console.WriteLine("Async method result: {0}", asyncMethodResult);
38 |
39 | var xmlelement = System.Xml.Linq.XElement.Parse("string");
40 | serviceClient.XmlMethod(xmlelement);
41 |
42 | Console.ReadKey();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/samples/Models/ComplexModelInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.ServiceModel;
5 |
6 | namespace Models
7 | {
8 | [DataContract]
9 | public class ComplexModelInput
10 | {
11 | [DataMember]
12 | public string StringProperty { get; set; }
13 |
14 | [DataMember]
15 | public int IntProperty { get; set; }
16 |
17 | [DataMember]
18 | public List ListProperty { get; set; }
19 |
20 | [DataMember]
21 | public DateTimeOffset DateTimeOffsetProperty { get; set; }
22 |
23 | [DataMember]
24 | public List ComplexListProperty { get; set; }
25 |
26 | [DataMember]
27 | public List DerivedObjects { get; set; }
28 |
29 | [DataContract]
30 | [ServiceKnownType(typeof(DerivedObject))]
31 | public class DerivedObject : BaseObject
32 | {
33 | public DerivedObject()
34 | {
35 | Name = nameof(DerivedObject);
36 | }
37 | }
38 | }
39 |
40 | [DataContract]
41 | public class ComplexObject
42 | {
43 | [DataMember]
44 | public string StringProperty { get; set; }
45 |
46 | [DataMember]
47 | public int IntProperty { get; set; }
48 | }
49 |
50 | [DataContract]
51 | public class BaseObject
52 | {
53 | public string Name { get; set; } = nameof(BaseObject);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/samples/Models/ComplexModelResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 |
5 | namespace Models
6 | {
7 | [DataContract]
8 | public class ComplexModelResponse
9 | {
10 | [DataMember]
11 | public float FloatProperty { get; set; }
12 |
13 | [DataMember]
14 | public string StringProperty { get; set; }
15 |
16 | [DataMember]
17 | public List ListProperty { get; set; }
18 |
19 | [DataMember]
20 | public DateTimeOffset DateTimeOffsetProperty { get; set; }
21 |
22 | [DataMember]
23 | public TestEnum TestEnum { get; set; }
24 | }
25 |
26 | public enum TestEnum
27 | {
28 | One,
29 | Two
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/samples/Models/ComplexReturnModel.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace Models
4 | {
5 | [DataContract]
6 | public class ComplexReturnModel
7 | {
8 | [DataMember]
9 | public int Id { get; set; }
10 | [DataMember]
11 | public string Name { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/samples/Models/ISampleService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Threading.Tasks;
3 |
4 | namespace Models
5 | {
6 | [ServiceContract]
7 | public interface ISampleService
8 | {
9 | [OperationContract]
10 | string Ping(string s);
11 |
12 | [OperationContract]
13 | ComplexModelResponse PingComplexModel(ComplexModelInput inputModel);
14 |
15 | [OperationContract]
16 | int[] IntArray();
17 |
18 | [OperationContract]
19 | ComplexReturnModel[] ComplexReturnModel();
20 |
21 | [OperationContract]
22 | void VoidMethod(out string s);
23 |
24 | [OperationContract]
25 | Task AsyncMethod();
26 |
27 | [OperationContract]
28 | int? NullableMethod(bool? arg);
29 |
30 | [OperationContract]
31 | void XmlMethod(System.Xml.Linq.XElement xml);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/samples/Models/Models.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/samples/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.Extensions.Logging;
8 |
9 | namespace Server
10 | {
11 | public class Program
12 | {
13 | public static void Main(string[] args)
14 | {
15 | var host = new WebHostBuilder()
16 | .UseKestrel()
17 | .UseUrls("http://*:5050")
18 | .UseContentRoot(Directory.GetCurrentDirectory())
19 | .UseStartup()
20 | .ConfigureLogging(x =>
21 | {
22 | x.AddDebug();
23 | x.AddConsole();
24 | })
25 | .Build();
26 |
27 | host.Run();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/samples/Server/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:12292/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "Server": {
12 | "commandName": "Project"
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/Server/Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/samples/Server/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Builder;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.DependencyInjection.Extensions;
10 | using Microsoft.Extensions.Logging;
11 | using Models;
12 | using SoapCore;
13 |
14 | namespace Server
15 | {
16 | public class Startup
17 | {
18 | public void ConfigureServices(IServiceCollection services)
19 | {
20 | services.AddSoapCore();
21 | services.TryAddSingleton();
22 | services.AddMvc();
23 | }
24 |
25 | public void Configure(IApplicationBuilder app)
26 | {
27 | app.UseRouting();
28 |
29 | app.UseEndpoints(endpoints => {
30 | endpoints.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
31 | endpoints.UseSoapEndpoint("/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
32 | });
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/samples/ServiceReferenceClient/Program.cs:
--------------------------------------------------------------------------------
1 | // See https://aka.ms/new-console-template for more information
2 | Console.WriteLine("Hello, World!");
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/ServiceReferenceClient/ServiceReferenceClient.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 | [*]
3 | end_of_line = crlf
4 | charset = utf-8
5 | insert_final_newline = true
6 | indent_style = tab
7 | trim_trailing_whitespace = true
8 |
9 | ; 4-column space indentation
10 | [*.{cs,js,ts,html,cshtml,aspx}]
11 | indent_style = tab
12 | indent_size = 4
13 | tab_width = 4
14 |
15 | ; 2-column tab indentation
16 | [*.{xml,props,config,css,less}]
17 | indent_style = tab
18 |
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(DefineConstants);NETCOREAPP2_1_OR_GREATER;
6 | $(DefineConstants);NETCOREAPP2_1_OR_GREATER;NETCOREAPP3_0_OR_GREATER
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Benchmark/PingService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Threading.Tasks;
3 |
4 | namespace SoapCore.Benchmark
5 | {
6 | [ServiceContract(Name="PingService", Namespace="http://example.org/PingService")]
7 | public interface IPingService
8 | {
9 | [OperationContract(Action="http://example.org/PingService/Echo", Name="Echo", ReplyAction="http://example.org/PingService/Echo")]
10 | string Echo(string str);
11 | [OperationContract(Action="http://example.org/PingService/EchoAsync", Name="EchoAsync", ReplyAction="http://example.org/PingService/EchoAsync")]
12 | Task EchoAsync(string str);
13 | }
14 | public class PingService : IPingService
15 | {
16 | public string Echo(string str)
17 | {
18 | return $"{str}";
19 | }
20 |
21 | public Task EchoAsync(string str)
22 | {
23 | return Task.FromResult($"{str}");
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/SoapCore.Benchmark/SoapCore.Benchmark.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1;net8.0
6 | ..\SoapCore.ruleset
7 | true
8 | 8
9 | false
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Benchmark/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Http;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using System;
5 | using System.Threading.Tasks;
6 |
7 | namespace SoapCore.Benchmark
8 | {
9 | public class Startup
10 | {
11 | public void ConfigureServices(IServiceCollection services)
12 | {
13 | services.AddSingleton();
14 | }
15 |
16 | public void Configure(IApplicationBuilder app)
17 | {
18 | app.UseSoapEndpoint("/TestService.asmx", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
19 | app.Use(async (HttpContext ctx, Func next) =>
20 | {
21 | await ctx.Response.WriteAsync("").ConfigureAwait(false);
22 | });
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ActionFilter/ActionFilterTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 | using SoapCore.Tests.Model;
8 |
9 | namespace SoapCore.Tests.ActionFilter
10 | {
11 | [TestClass]
12 | public class ActionFilterTests
13 | {
14 | [ClassInitialize]
15 | #pragma warning disable IDE0060 // Remove unused parameter
16 | public static void StartServer(TestContext context)
17 | #pragma warning restore IDE0060 // Remove unused parameter
18 | {
19 | Task.Run(() =>
20 | {
21 | var host = new WebHostBuilder()
22 | .UseKestrel()
23 | .UseUrls("http://localhost:5052")
24 | .UseStartup()
25 | .Build();
26 | host.Run();
27 | }).Wait(1000);
28 | }
29 |
30 | public ITestService CreateClient()
31 | {
32 | var binding = new BasicHttpBinding();
33 | var endpoint = new EndpointAddress(new Uri(string.Format("http://{0}:5052/Service.svc", "localhost")));
34 | var channelFactory = new ChannelFactory(binding, endpoint);
35 | var serviceClient = channelFactory.CreateChannel();
36 | return serviceClient;
37 | }
38 |
39 | [TestMethod]
40 | public void ModelWasAlteredInActionFilter()
41 | {
42 | var inputModel = new ComplexModelInput
43 | {
44 | StringProperty = "string property test value",
45 | IntProperty = 123,
46 | ListProperty = new List { "test", "list", "of", "strings" },
47 | DateTimeOffsetProperty = new DateTimeOffset(2018, 12, 31, 13, 59, 59, TimeSpan.FromHours(1))
48 | };
49 |
50 | var client = CreateClient();
51 | var result = client.ComplexParamWithActionFilter(inputModel);
52 | Assert.AreNotEqual(inputModel.StringProperty, result.StringProperty);
53 | Assert.AreNotEqual(inputModel.IntProperty, result.IntProperty);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ActionFilter/TestActionFilter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Mvc.Filters;
3 | using SoapCore.Tests.Model;
4 |
5 | namespace SoapCore.Tests.ActionFilter
6 | {
7 | internal class TestActionFilter : ActionFilterAttribute
8 | {
9 | public void OnSoapActionExecuting(string operationName, object[] allArgs, HttpContext httpContext, object result)
10 | {
11 | var complexModel = (ComplexModelInput)allArgs[0];
12 | complexModel.StringProperty += "MODIFIED BY TestActionFilter";
13 | complexModel.IntProperty = complexModel.IntProperty * 2;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/CustomMessageFault.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.ServiceModel.Channels;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Xml;
9 |
10 | namespace SoapCore.Tests
11 | {
12 | internal class CustomMessageFault : MessageFault
13 | {
14 | private readonly string _reason;
15 | private readonly string _actor;
16 |
17 | public CustomMessageFault(string reason, string actor)
18 | {
19 | _reason = reason;
20 | _actor = actor;
21 | }
22 |
23 | public override FaultCode Code => new FaultCode("Client");
24 |
25 | public override bool HasDetail => false;
26 |
27 | public override FaultReason Reason => new FaultReason(_reason);
28 |
29 | public override string Actor => _actor;
30 |
31 | protected override void OnWriteDetailContents(XmlDictionaryWriter writer)
32 | {
33 | throw new NotSupportedException();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/FaultExceptionTransformer/Startup.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using Microsoft.AspNetCore.Builder;
3 | using Microsoft.AspNetCore.Hosting;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.Extensions.DependencyInjection.Extensions;
6 | using Microsoft.Extensions.Logging;
7 | using SoapCore.Extensibility;
8 |
9 | namespace SoapCore.Tests.FaultExceptionTransformer
10 | {
11 | public class Startup
12 | {
13 | public void ConfigureServices(IServiceCollection services)
14 | {
15 | services.AddSoapCore();
16 | services.TryAddSingleton();
17 | services.AddSingleton();
18 | services.AddMvc();
19 | }
20 |
21 | #if !NETCOREAPP3_0_OR_GREATER
22 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
23 | {
24 | app.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
25 | app.UseMvc();
26 | }
27 | #else
28 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
29 | {
30 | app.UseRouting();
31 |
32 | app.UseEndpoints(x =>
33 | {
34 | x.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
35 | });
36 | }
37 | #endif
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/FaultExceptionTransformer/TestFault.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.Text;
5 |
6 | namespace SoapCore.Tests.FaultExceptionTransformer
7 | {
8 | [DataContract]
9 | public class TestFault
10 | {
11 | public TestFault()
12 | {
13 | }
14 |
15 | [DataMember]
16 | public string Message { get; set; }
17 |
18 | [DataMember]
19 | public string AdditionalProperty { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/FaultExceptionTransformer/TestFaultExceptionTransformer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.ServiceModel;
4 | using System.ServiceModel.Channels;
5 | using System.Xml;
6 | using SoapCore.Extensibility;
7 |
8 | namespace SoapCore.Tests.FaultExceptionTransformer
9 | {
10 | public class TestFaultExceptionTransformer : IFaultExceptionTransformer
11 | {
12 | public Message ProvideFault(Exception exception, MessageVersion messageVersion, Message requestMessage, XmlNamespaceManager xmlNamespaceManager)
13 | {
14 | var fault = new TestFault
15 | {
16 | Message = exception.Message,
17 | AdditionalProperty = "foo:bar"
18 | };
19 |
20 | var faultException = new FaultException(fault, new FaultReason(exception.Message), new FaultCode(nameof(TestFault)), nameof(TestFault));
21 |
22 | var messageFault = faultException.CreateMessageFault();
23 | var bodyWriter = new MessageFaultBodyWriter(messageFault, messageVersion);
24 | var faultMessage = Message.CreateMessage(messageVersion, null, bodyWriter);
25 |
26 | faultMessage.Properties.Add(HttpResponseMessageProperty.Name, new HttpResponseMessageProperty { StatusCode = HttpStatusCode.OK, StatusDescription = "test description" });
27 |
28 | return faultMessage;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/Models/IArrayOfArrayOfByteService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Text;
3 |
4 | namespace SoapCore.Tests.MessageContract.Models
5 | {
6 | [ServiceContract(Namespace = "http://tempuri.org")]
7 | public interface IArrayOfArrayOfByteService
8 | {
9 | [OperationContract]
10 | string ArrayOfArrayOfByteMethod(byte[][] arrayOfArrayOfByteParam);
11 | }
12 |
13 | public class ArrayOfArrayOfByteService : IArrayOfArrayOfByteService
14 | {
15 | public string ArrayOfArrayOfByteMethod(byte[][] arrayOfArrayOfByteParam)
16 | {
17 | var ret = new StringBuilder();
18 | ret.Append("[");
19 | foreach (var array in arrayOfArrayOfByteParam)
20 | {
21 | ret.Append("[");
22 | ret.Append(string.Join(",", array));
23 | ret.Append("]");
24 | }
25 |
26 | ret.Append("]");
27 | return ret.ToString();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/Models/IArrayOfIntService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Text;
5 |
6 | namespace SoapCore.Tests.MessageContract.Models
7 | {
8 | [ServiceContract(Namespace = "http://tempuri.org")]
9 | public interface IArrayOfIntService
10 | {
11 | [OperationContract]
12 | int[] ArrayOfIntMethod(int[] arrayOfIntParam);
13 |
14 | [OperationContract]
15 | int IntMethod(int intParam);
16 | }
17 |
18 | public class ArrayOfIntService : IArrayOfIntService
19 | {
20 | public int[] ArrayOfIntMethod(int[] arrayOfIntParam)
21 | {
22 | return arrayOfIntParam;
23 | }
24 |
25 | public int IntMethod(int intParam)
26 | {
27 | return intParam;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/Models/IServiceWithMessageContract.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Threading.Tasks;
3 | using SoapCore.Tests.OperationDescription.Model;
4 |
5 | namespace SoapCore.Tests.MessageContract.Models
6 | {
7 | [ServiceContract(Namespace = "http://tempuri.org")]
8 | public interface IServiceWithMessageContract
9 | {
10 | [OperationContract]
11 | [XmlSerializerFormat(SupportFaults = true)]
12 | string EmptyRequest(Model.MessageContractRequestEmpty req);
13 |
14 | [OperationContract]
15 | [XmlSerializerFormat(SupportFaults = true)]
16 | Model.MessageContractResponse DoRequest(Model.MessageContractRequest req);
17 |
18 | [OperationContract]
19 | [XmlSerializerFormat(SupportFaults = true)]
20 | Model.MessageContractResponseNotWrapped DoRequest2(Model.MessageContractRequestNotWrapped req);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/Models/IServiceWithMessageContractComplexNotWrapped.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.MessageContract.Models
5 | {
6 | [ServiceContract(Namespace = "http://tempuri.org")]
7 | public interface IServiceWithMessageContractComplexNotWrapped
8 | {
9 | [OperationContract]
10 | [XmlSerializerFormat(SupportFaults = true)]
11 | Model.MessageContractResponseNotWrapped PostData(Model.MessageContractRequestComplexNotWrapped req);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/Models/IServiceWithMessageContractNotWrapped.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Threading.Tasks;
3 | using SoapCore.Tests.OperationDescription.Model;
4 |
5 | namespace SoapCore.Tests.MessageContract.Models
6 | {
7 | [ServiceContract(Namespace = "http://tempuri.org")]
8 | public interface IServiceWithMessageContractNotWrapped
9 | {
10 | [OperationContract]
11 | [XmlSerializerFormat(SupportFaults = true)]
12 | Model.MessageContractResponseNotWrapped PullData(Model.MessageContractRequestNotWrapped req);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/Models/IServiceWithMessageContractWrapped.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Threading.Tasks;
3 | using SoapCore.Tests.OperationDescription.Model;
4 |
5 | namespace SoapCore.Tests.MessageContract.Models
6 | {
7 | [ServiceContract(Namespace = "http://tempuri.org")]
8 | public interface IServiceWithMessageContractWrapped
9 | {
10 | [OperationContract]
11 | [XmlSerializerFormat(SupportFaults = true)]
12 | Model.MessageContractResponse PullData(Model.MessageContractRequest req);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/Models/IStartupConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace SoapCore.Tests.MessageContract.Models
6 | {
7 | public interface IStartupConfiguration
8 | {
9 | Type ServiceType { get; }
10 | }
11 |
12 | public class StartupConfiguration : IStartupConfiguration
13 | {
14 | public StartupConfiguration(Type serviceType)
15 | {
16 | ServiceType = serviceType;
17 | }
18 |
19 | public Type ServiceType { get; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/RawRequestSoap11And12.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading.Tasks;
4 | using System.Xml;
5 | using System.Xml.Linq;
6 | using System.Xml.XPath;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.AspNetCore.TestHost;
9 | using Microsoft.Extensions.DependencyInjection;
10 | using Microsoft.VisualStudio.TestTools.UnitTesting;
11 | using SoapCore.Tests.MessageContract.Models;
12 |
13 | namespace SoapCore.Tests.MessageContract
14 | {
15 | [TestClass]
16 | public class RawRequestSoap11And12
17 | {
18 | [TestMethod]
19 | public async Task Soap11And12MessageContractGetWSDL_ShouldContainSoap11AndSoap12Namespaces()
20 | {
21 | using var host = CreateTestHost(typeof(TestService));
22 | using var client = host.CreateClient();
23 | using var res = host.CreateRequest("/Service11And12.asmx?wsdl").GetAsync().Result;
24 |
25 | res.EnsureSuccessStatusCode();
26 |
27 | var response = await res.Content.ReadAsStringAsync();
28 | var root = XDocument.Parse(response);
29 | Assert.AreEqual("http://schemas.xmlsoap.org/wsdl/soap/", root.Root.Attributes().FirstOrDefault(t => t.Name.LocalName == "soap").Value);
30 | Assert.AreEqual("http://schemas.xmlsoap.org/wsdl/soap12/", root.Root.Attributes().FirstOrDefault(t => t.Name.LocalName == "soap12").Value);
31 | }
32 |
33 | private TestServer CreateTestHost(Type serviceType)
34 | {
35 | var webHostBuilder = new WebHostBuilder()
36 | .UseStartup()
37 | .ConfigureServices(services => services.AddSingleton(new StartupConfiguration(serviceType)));
38 | return new TestServer(webHostBuilder);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/TestService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using SoapCore.Tests.MessageContract.Models;
8 | using SoapCore.Tests.Model;
9 |
10 | namespace SoapCore.Tests.MessageContract
11 | {
12 | public class TestService : IServiceWithMessageContract
13 | {
14 | public MessageContractResponse DoRequest(MessageContractRequest req)
15 | {
16 | Model.MessageContractResponse response = new MessageContractResponse();
17 | response.ReferenceNumber = req.ReferenceNumber;
18 | return response;
19 | }
20 |
21 | public MessageContractResponseNotWrapped DoRequest2(MessageContractRequestNotWrapped req)
22 | {
23 | Model.MessageContractResponseNotWrapped response = new MessageContractResponseNotWrapped();
24 | response.ReferenceNumber = req.ReferenceNumber;
25 | return response;
26 | }
27 |
28 | public string EmptyRequest(MessageContractRequestEmpty req)
29 | {
30 | return "OK";
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/TestServiceComplexNotWrapped.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using SoapCore.Tests.MessageContract.Models;
3 | using SoapCore.Tests.Model;
4 |
5 | namespace SoapCore.Tests.MessageContract
6 | {
7 | public class TestServiceComplexNotWrapped : IServiceWithMessageContractComplexNotWrapped
8 | {
9 | public MessageContractResponseNotWrapped PostData(MessageContractRequestComplexNotWrapped req)
10 | {
11 | MessageContractResponseNotWrapped ret = new MessageContractResponseNotWrapped();
12 | ret.ReferenceNumber = req.PostDataBodyMember.IntProperty;
13 | return ret;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/TestServiceNotWrapped.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using SoapCore.Tests.MessageContract.Models;
8 | using SoapCore.Tests.Model;
9 |
10 | namespace SoapCore.Tests.MessageContract
11 | {
12 | public class TestServiceNotWrapped : IServiceWithMessageContractNotWrapped
13 | {
14 | public MessageContractResponseNotWrapped PullData(MessageContractRequestNotWrapped req)
15 | {
16 | MessageContractResponseNotWrapped ret = new MessageContractResponseNotWrapped();
17 | ret.ReferenceNumber = req.ReferenceNumber;
18 | return ret;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageContract/TestServiceWrapped.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using SoapCore.Tests.MessageContract.Models;
8 | using SoapCore.Tests.Model;
9 |
10 | namespace SoapCore.Tests.MessageContract
11 | {
12 | public class TestServiceWrapped : IServiceWithMessageContractWrapped
13 | {
14 | public MessageContractResponse PullData(MessageContractRequest req)
15 | {
16 | MessageContractResponse ret = new MessageContractResponse();
17 | ret.ReferenceNumber = req.ReferenceNumber;
18 | return ret;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageFilter/Startup.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using Microsoft.AspNetCore.Builder;
3 | using Microsoft.AspNetCore.Hosting;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.Extensions.DependencyInjection.Extensions;
6 | using Microsoft.Extensions.Logging;
7 |
8 | namespace SoapCore.Tests.MessageFilter
9 | {
10 | public class Startup
11 | {
12 | public void ConfigureServices(IServiceCollection services)
13 | {
14 | services.AddSoapCore();
15 | services.TryAddSingleton();
16 | services.AddSoapWsSecurityFilter("yourusername", "yourpassword");
17 | services.AddMvc();
18 | }
19 |
20 | #if !NETCOREAPP3_0_OR_GREATER
21 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
22 | {
23 | app.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
24 | app.UseMvc();
25 | }
26 | #else
27 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
28 | {
29 | app.UseRouting();
30 |
31 | app.UseEndpoints(x =>
32 | {
33 | x.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
34 | });
35 | }
36 | #endif
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageInspectors/InspectorStyle.cs:
--------------------------------------------------------------------------------
1 | namespace SoapCore.Tests.MessageInspectors
2 | {
3 | public enum InspectorStyle
4 | {
5 | MessageInspector2,
6 | MessageInspector2NoException,
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageInspectors/MessageInspector2/MessageInspector2Mock.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.ServiceModel.Channels;
3 | using SoapCore.Extensibility;
4 | using SoapCore.ServiceModel;
5 |
6 | namespace SoapCore.Tests.MessageInspectors.MessageInspector2
7 | {
8 | public class MessageInspector2Mock : IMessageInspector2
9 | {
10 | public static bool AfterReceivedRequestCalled { get; private set; }
11 | public static bool BeforeSendReplyCalled { get; private set; }
12 | public static Message LastReceivedMessage { get; private set; }
13 |
14 | public static void Reset()
15 | {
16 | LastReceivedMessage = null;
17 | AfterReceivedRequestCalled = false;
18 | BeforeSendReplyCalled = false;
19 | }
20 |
21 | public object AfterReceiveRequest(ref Message message, ServiceDescription serviceDescription)
22 | {
23 | LastReceivedMessage = message;
24 | AfterReceivedRequestCalled = true;
25 |
26 | // validate message
27 | ValidateMessage(ref message);
28 |
29 | return null;
30 | }
31 |
32 | public void BeforeSendReply(ref Message reply, ServiceDescription serviceDescription, object correlationState)
33 | {
34 | BeforeSendReplyCalled = true;
35 | }
36 |
37 | protected virtual void ValidateMessage(ref Message message)
38 | {
39 | throw new FaultException(new FaultReason("Message is invalid."), new FaultCode("Sender"), null);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageInspectors/MessageInspector2/MessageInspector2MockNoException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel.Channels;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SoapCore.Tests.MessageInspectors.MessageInspector2
9 | {
10 | public class MessageInspector2MockNoException : MessageInspector2Mock
11 | {
12 | protected override void ValidateMessage(ref Message message)
13 | {
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/MessageInspectors/Startup.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using Microsoft.AspNetCore.Builder;
3 | using Microsoft.AspNetCore.Hosting;
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.DependencyInjection.Extensions;
7 | using Microsoft.Extensions.Logging;
8 | using SoapCore.Tests.MessageInspectors.MessageInspector2;
9 |
10 | namespace SoapCore.Tests.MessageInspectors
11 | {
12 | public class Startup
13 | {
14 | public Startup(IConfiguration configuration)
15 | {
16 | Configuration = configuration;
17 | InspectorStyle = configuration.GetValue("InspectorStyle");
18 | }
19 |
20 | public IConfiguration Configuration { get; }
21 | public InspectorStyle InspectorStyle { get; }
22 |
23 | public void ConfigureServices(IServiceCollection services)
24 | {
25 | services.AddSoapCore();
26 | services.TryAddSingleton();
27 |
28 | switch (InspectorStyle)
29 | {
30 | case InspectorStyle.MessageInspector2:
31 | services.AddSoapMessageInspector(new MessageInspector2Mock());
32 | break;
33 | case InspectorStyle.MessageInspector2NoException:
34 | services.AddSoapMessageInspector(new MessageInspector2MockNoException());
35 | break;
36 | }
37 |
38 | services.AddMvc();
39 | }
40 |
41 | #if !NETCOREAPP3_0_OR_GREATER
42 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
43 | {
44 | app.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
45 | app.UseMvc();
46 | }
47 | #else
48 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
49 | {
50 | app.UseRouting();
51 |
52 | app.UseEndpoints(x =>
53 | {
54 | x.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
55 | });
56 | }
57 | #endif
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/ComplexInheritanceModelInputA.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Model
4 | {
5 | [KnownType(typeof(ComplexInheritanceModelInputB))]
6 | [DataContract(Name = "ComplexInheritanceModelInputA")]
7 | public class ComplexInheritanceModelInputA : ComplexInheritanceModelInputBase
8 | {
9 | [DataMember]
10 | public override string Example { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/ComplexInheritanceModelInputB.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Model
4 | {
5 | [DataContract(Name = "ComplexInheritanceModelInputB")]
6 | public class ComplexInheritanceModelInputB : ComplexInheritanceModelInputA
7 | {
8 | [DataMember]
9 | public int Example2 { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/ComplexInheritanceModelInputBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 |
5 | namespace SoapCore.Tests.Model
6 | {
7 | [KnownType(nameof(GetKnownTypes))]
8 | [DataContract(Name = "ComplexInheritanceModelInputBase")]
9 | public abstract class ComplexInheritanceModelInputBase
10 | {
11 | [DataMember]
12 | public string StringProperty { get; set; }
13 |
14 | [DataMember]
15 | public abstract string Example { get; set; }
16 |
17 | private static IEnumerable GetKnownTypes()
18 | {
19 | yield return typeof(ComplexInheritanceModelInputA);
20 | yield return typeof(ComplexInheritanceModelInputB);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/ComplexModelInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 |
5 | namespace SoapCore.Tests.Model
6 | {
7 | [DataContract]
8 | public class ComplexModelInput
9 | {
10 | [DataMember]
11 | public string StringProperty { get; set; }
12 |
13 | [DataMember]
14 | public int IntProperty { get; set; }
15 |
16 | [DataMember]
17 | public List ListProperty { get; set; }
18 |
19 | [DataMember]
20 | public DateTimeOffset DateTimeOffsetProperty { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/ComplexModelInputForModelBindingFilter.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Model
4 | {
5 | [DataContract]
6 | public class ComplexModelInputForModelBindingFilter : ComplexModelInput
7 | {
8 | //empty
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/ComplexTreeModelInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.Text;
5 |
6 | namespace SoapCore.Tests.Model
7 | {
8 | [DataContract]
9 | public class ComplexTreeModelInput : IComplexTreeModelInput
10 | {
11 | [DataMember]
12 | public ComplexModelInput Item { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/EmptyMembers.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Model
5 | {
6 | public class EmptyMembers
7 | {
8 | public EmptyMembers()
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/FaultDetail.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Model
4 | {
5 | [DataContract]
6 | public class FaultDetail
7 | {
8 | [DataMember]
9 | public string ExceptionProperty { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/IComplexTreeModelInput.cs:
--------------------------------------------------------------------------------
1 | namespace SoapCore.Tests.Model
2 | {
3 | public interface IComplexTreeModelInput
4 | {
5 | ComplexModelInput Item { get; set; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/MessageContractRequest.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Model
5 | {
6 | [MessageContract(IsWrapped = true)]
7 | public class MessageContractRequest
8 | {
9 | private int _referenceNumber;
10 | public MessageContractRequest()
11 | {
12 | }
13 |
14 | [MessageBodyMember]
15 | public int ReferenceNumber
16 | {
17 | get
18 | {
19 | return _referenceNumber;
20 | }
21 | set
22 | {
23 | _referenceNumber = value;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/MessageContractRequestComplexNotWrapped.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Model
5 | {
6 | [MessageContract(IsWrapped = false)]
7 | public class MessageContractRequestComplexNotWrapped
8 | {
9 | [MessageBodyMember]
10 | public ComplexModelInput PostDataBodyMember { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/MessageContractRequestEmpty.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Model
5 | {
6 | [MessageContract(IsWrapped = false)]
7 | public class MessageContractRequestEmpty
8 | {
9 | public MessageContractRequestEmpty()
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/MessageContractRequestNotWrapped.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Model
5 | {
6 | [MessageContract(IsWrapped=false)]
7 | public class MessageContractRequestNotWrapped
8 | {
9 | private int _referenceNumber;
10 | public MessageContractRequestNotWrapped()
11 | {
12 | }
13 |
14 | [MessageBodyMember]
15 | public int ReferenceNumber
16 | {
17 | get
18 | {
19 | return _referenceNumber;
20 | }
21 | set
22 | {
23 | _referenceNumber = value;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/MessageContractResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Model
5 | {
6 | [MessageContract(IsWrapped = true)]
7 | public class MessageContractResponse
8 | {
9 | private int _referenceNumber;
10 | public MessageContractResponse()
11 | {
12 | }
13 |
14 | [MessageBodyMember]
15 | public int ReferenceNumber
16 | {
17 | get
18 | {
19 | return _referenceNumber;
20 | }
21 | set
22 | {
23 | _referenceNumber = value;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Model/MessageContractResponseNotWrapped.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Model
5 | {
6 | [MessageContract(IsWrapped = false)]
7 | public class MessageContractResponseNotWrapped
8 | {
9 | private int _referenceNumber;
10 | public MessageContractResponseNotWrapped()
11 | {
12 | }
13 |
14 | [MessageBodyMember]
15 | public int ReferenceNumber
16 | {
17 | get
18 | {
19 | return _referenceNumber;
20 | }
21 | set
22 | {
23 | _referenceNumber = value;
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ModelBindingFilter/TestModelBindingFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using SoapCore.Extensibility;
4 | using SoapCore.Tests.Model;
5 |
6 | namespace SoapCore.Tests.ModelBindingFilter
7 | {
8 | public class TestModelBindingFilter : IModelBindingFilter
9 | {
10 | public TestModelBindingFilter(List modelTypes)
11 | {
12 | ModelTypes = modelTypes;
13 | }
14 |
15 | public List ModelTypes { get; set; }
16 |
17 | public void OnModelBound(object model, IServiceProvider serviceProvider, out object result)
18 | {
19 | var complexModel = (ComplexModelInputForModelBindingFilter)model;
20 | complexModel.StringProperty += "MODIFIED BY TestModelBindingFilter";
21 | complexModel.IntProperty = complexModel.IntProperty * 2;
22 | result = true;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/NativeAuthenticationAndAuthorization/AuthorizationHeaderEndpointBehavior.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http;
3 | using System.ServiceModel.Channels;
4 | using System.ServiceModel.Description;
5 | using System.ServiceModel.Dispatcher;
6 |
7 | namespace SoapCore.Tests.NativeAuthenticationAndAuthorization
8 | {
9 | internal class AuthorizationHeaderEndpointBehavior : IEndpointBehavior
10 | {
11 | private readonly string _authorizationHeader;
12 | public AuthorizationHeaderEndpointBehavior(string authorizationHeader)
13 | {
14 | _authorizationHeader = authorizationHeader;
15 | }
16 |
17 | public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
18 | {
19 | bindingParameters.Add(new Func(x =>
20 | {
21 | return new AuthorizationHeaderMessageHandler(x, _authorizationHeader);
22 | }));
23 | }
24 |
25 | public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
26 | {
27 | }
28 |
29 | public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
30 | {
31 | }
32 |
33 | public void Validate(ServiceEndpoint endpoint)
34 | {
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/NativeAuthenticationAndAuthorization/AuthorizationHeaderMessageHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Net.Http;
2 | using System.ServiceModel.Channels;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 |
6 | namespace SoapCore.Tests.NativeAuthenticationAndAuthorization
7 | {
8 | internal class AuthorizationHeaderMessageHandler : DelegatingHandler
9 | {
10 | private readonly string _authorizationHeader;
11 | public AuthorizationHeaderMessageHandler(HttpClientHandler httpClientHandler, string authorizationHeader)
12 | {
13 | InnerHandler = httpClientHandler;
14 | _authorizationHeader = authorizationHeader;
15 | }
16 |
17 | protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
18 | {
19 | request.Headers.Add("Authorization", _authorizationHeader);
20 |
21 | return await base.SendAsync(request, cancellationToken);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/NativeAuthenticationAndAuthorization/ITestService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using SoapCore.Tests.Model;
3 |
4 | namespace SoapCore.Tests.NativeAuthenticationAndAuthorization
5 | {
6 | [ServiceContract]
7 | public interface ITestService
8 | {
9 | [OperationContract]
10 | string JwtAuthenticationAndAuthorizationIActionResultUnprotected(ComplexModelInput payload);
11 |
12 | [OperationContract]
13 | string JwtAuthenticationAndAuthorizationIActionResultJustAuthenticated(ComplexModelInput payload);
14 |
15 | [OperationContract]
16 | string JwtAuthenticationAndAuthorizationIActionResultUsingPolicy(ComplexModelInput payload);
17 |
18 | [OperationContract]
19 | string JwtAuthenticationAndAuthorizationIActionResult(ComplexModelInput payload);
20 |
21 | [OperationContract]
22 | string JwtAuthenticationAndAuthorizationActionResult(ComplexModelInput payload);
23 |
24 | [OperationContract]
25 | string JwtAuthenticationAndAuthorizationGenericActionResult(ComplexModelInput payload);
26 |
27 | [OperationContract]
28 | ComplexModelInput JwtAuthenticationAndAuthorizationComplexGenericActionResult(ComplexModelInput payload);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/NativeAuthenticationAndAuthorization/TestService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using SoapCore.Tests.Model;
3 |
4 | namespace SoapCore.Tests.NativeAuthenticationAndAuthorization
5 | {
6 | [ServiceContract]
7 | public abstract class TestService : ITestService
8 | {
9 | [OperationContract]
10 | public abstract string JwtAuthenticationAndAuthorizationIActionResultUnprotected(ComplexModelInput payload);
11 |
12 | [OperationContract]
13 | public abstract string JwtAuthenticationAndAuthorizationIActionResultJustAuthenticated(ComplexModelInput payload);
14 |
15 | [OperationContract]
16 | public abstract string JwtAuthenticationAndAuthorizationIActionResultUsingPolicy(ComplexModelInput payload);
17 |
18 | [OperationContract]
19 | public abstract string JwtAuthenticationAndAuthorizationIActionResult(ComplexModelInput payload);
20 |
21 | [OperationContract]
22 | public abstract string JwtAuthenticationAndAuthorizationActionResult(ComplexModelInput payload);
23 |
24 | [OperationContract]
25 | public abstract string JwtAuthenticationAndAuthorizationGenericActionResult(ComplexModelInput payload);
26 |
27 | [OperationContract]
28 | public abstract ComplexModelInput JwtAuthenticationAndAuthorizationComplexGenericActionResult(ComplexModelInput payload);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/OperationDescription/IServiceWithMessageContract.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Threading.Tasks;
3 | using SoapCore.Tests.OperationDescription.Model;
4 |
5 | namespace SoapCore.Tests.OperationDescription
6 | {
7 | public interface IServiceWithMessageContract
8 | {
9 | Task GetMyClass();
10 |
11 | Task GetMyAsyncClassAsync();
12 |
13 | CoolResponseClass GetMyOtherClass();
14 |
15 | ClassWithXmlRoot GetClassWithXmlRoot(ClassWithXmlRoot classWithXmlRoot);
16 |
17 | string GetMyStringClass();
18 |
19 | [FaultContract(typeof(TypedSoapFault))]
20 | void ThrowTypedFault();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/OperationDescription/IServiceWithMessageContractAndEmptyXmlRoot.cs:
--------------------------------------------------------------------------------
1 | using SoapCore.Tests.OperationDescription.Model;
2 |
3 | namespace SoapCore.Tests.OperationDescription
4 | {
5 | ///
6 | /// Interface to test OperationDescription.cs functionality.
7 | ///
8 | public interface IServiceWithMessageContractAndEmptyXmlRoot : IServiceWithMessageContract
9 | {
10 | ///
11 | /// Returns a class with an empty string as XMLRoot element.
12 | ///
13 | /// Class with empty string as XMLRoot element.
14 | /// instance used in a test.
15 | ClassWithEmptyXmlRoot GetClassWithEmptyXmlRoot(ClassWithEmptyXmlRoot classWithXmlRoot);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/OperationDescription/Model/ClassWithEmptyXmlRoot.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace SoapCore.Tests.OperationDescription.Model
4 | {
5 | ///
6 | /// Test stub to test the operation description parameter extraction with emtpy XmlRootElementName.
7 | ///
8 | [XmlRoot(ElementName = "")]
9 | public class ClassWithEmptyXmlRoot
10 | {
11 | ///
12 | /// Gets or sets SomeString.
13 | ///
14 | public string SomeString { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/OperationDescription/Model/ClassWithXmlRoot.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace SoapCore.Tests.OperationDescription.Model
4 | {
5 | [XmlRoot(ElementName = "test")]
6 | public class ClassWithXmlRoot
7 | {
8 | public string SomeString { get; set; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/OperationDescription/Model/CoolResponseClass.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.OperationDescription.Model
4 | {
5 | [MessageContract]
6 | public class CoolResponseClass
7 | {
8 | public string SomeString { get; set; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/OperationDescription/Model/TypedSoapFault.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.OperationDescription.Model
4 | {
5 | //TODO: Fix the meta generation of fault namespaces, to remove this limitation
6 | [DataContract(Namespace = "Currently, this MUST be set to the same as your ServiceContract namespace for catching to work on the client.")]
7 | public class TypedSoapFault
8 | {
9 | [DataMember(Name = "This name is currently ignored")]
10 | public string MyIncludedProperty { get; set; }
11 |
12 | [IgnoreDataMember]
13 | [DataMember]
14 | public string MyExcludedProperty { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/RequestArgumentsOrder/IOriginalParametersOrderService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.RequestArgumentsOrder
4 | {
5 | [ServiceContract(Namespace = ServiceNamespace.Value)]
6 | public interface IOriginalParametersOrderService
7 | {
8 | [OperationContract]
9 | string TwoStringParameters(string first, string second);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/RequestArgumentsOrder/IReversedParametersOrderService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.RequestArgumentsOrder
4 | {
5 | [ServiceContract(Namespace = ServiceNamespace.Value)]
6 | public interface IReversedParametersOrderService
7 | {
8 | [OperationContract]
9 | string TwoStringParameters(string second, string first);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/RequestArgumentsOrder/ServiceNamespace.cs:
--------------------------------------------------------------------------------
1 | namespace SoapCore.Tests.RequestArgumentsOrder
2 | {
3 | public static class ServiceNamespace
4 | {
5 | public const string Value = "http://service.net/webservices/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.DataContract/ComplexObject.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.DataContract
4 | {
5 | [DataContract]
6 | public class ComplexObject
7 | {
8 | [DataMember]
9 | public string StringProperty { get; set; }
10 |
11 | [DataMember]
12 | public int IntProperty { get; set; }
13 |
14 | public static ComplexObject CreateSample1()
15 | => new ComplexObject
16 | {
17 | IntProperty = 1,
18 | StringProperty = $"{nameof(ComplexObject)} sample one"
19 | };
20 |
21 | public static ComplexObject CreateSample2()
22 | => new ComplexObject
23 | {
24 | IntProperty = 2,
25 | StringProperty = $"{nameof(ComplexObject)} sample two"
26 | };
27 |
28 | public static ComplexObject CreateSample3()
29 | => new ComplexObject
30 | {
31 | IntProperty = 3,
32 | StringProperty = $"{nameof(ComplexObject)} sample three"
33 | };
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.DataContract/ISampleServiceWithMessageHeaders.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.DataContract
4 | {
5 | [ServiceContract]
6 | public interface ISampleServiceWithMessageHeaders
7 | {
8 | [OperationContract]
9 | MessageHeadersModelWithBody GetWithBody(MessageHeadersModelWithBody model);
10 |
11 | [OperationContract]
12 | MessageHeadersModelWithBodyAndNamespace GetWithBodyAndNamespace(MessageHeadersModelWithBodyAndNamespace model);
13 |
14 | [OperationContract]
15 | MessageHeadersModelWithNamespace GetWithNamespace(MessageHeadersModelWithNamespace model);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.DataContract/MessageHeadersModelWithBody.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.DataContract
4 | {
5 | [MessageContract]
6 | public class MessageHeadersModelWithBody
7 | {
8 | [MessageHeader]
9 | public string Prop1 { get; set; }
10 |
11 | [MessageHeader]
12 | public string Prop2 { get; set; }
13 |
14 | [MessageHeader(Namespace = "TestHeaderNamespace")]
15 | public string Prop3 { get; set; }
16 |
17 | [MessageHeader(Namespace = "TestHeaderNamespace")]
18 | public string Prop4 { get; set; }
19 |
20 | [MessageHeader(MustUnderstand = true)]
21 | public string Prop5 { get; set; }
22 |
23 | [MessageHeader(MustUnderstand = true)]
24 | public string Prop6 { get; set; }
25 |
26 | [MessageHeader(MustUnderstand = true, Namespace = "TestHeaderNamespace")]
27 | public string Prop7 { get; set; }
28 |
29 | [MessageHeader(MustUnderstand = true, Namespace = "TestHeaderNamespace")]
30 | public string Prop8 { get; set; }
31 |
32 | [MessageBodyMember]
33 | public string Body1 { get; set; }
34 |
35 | [MessageBodyMember]
36 | public string Body2 { get; set; }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.DataContract/MessageHeadersModelWithBodyAndNamespace.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.DataContract
4 | {
5 | [MessageContract(WrapperNamespace = "TestNamespace")]
6 | public class MessageHeadersModelWithBodyAndNamespace
7 | {
8 | [MessageHeader]
9 | public string Prop1 { get; set; }
10 |
11 | [MessageHeader]
12 | public string Prop2 { get; set; }
13 |
14 | [MessageHeader(Namespace = "TestHeaderNamespace")]
15 | public string Prop3 { get; set; }
16 |
17 | [MessageHeader(Namespace = "TestHeaderNamespace")]
18 | public string Prop4 { get; set; }
19 |
20 | [MessageHeader(MustUnderstand = true)]
21 | public string Prop5 { get; set; }
22 |
23 | [MessageHeader(MustUnderstand = true)]
24 | public string Prop6 { get; set; }
25 |
26 | [MessageHeader(MustUnderstand = true, Namespace = "TestHeaderNamespace")]
27 | public string Prop7 { get; set; }
28 |
29 | [MessageHeader(MustUnderstand = true, Namespace = "TestHeaderNamespace")]
30 | public string Prop8 { get; set; }
31 |
32 | [MessageBodyMember]
33 | public string Body1 { get; set; }
34 |
35 | [MessageBodyMember]
36 | public string Body2 { get; set; }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.DataContract/MessageHeadersModelWithNamespace.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.DataContract
4 | {
5 | [MessageContract(WrapperNamespace = "TestNamespace")]
6 | public class MessageHeadersModelWithNamespace
7 | {
8 | [MessageHeader]
9 | public string Prop1 { get; set; }
10 |
11 | [MessageHeader(Namespace = "TestHeaderNamespace")]
12 | public string Prop2 { get; set; }
13 |
14 | [MessageHeader(MustUnderstand = true)]
15 | public string Prop3 { get; set; }
16 |
17 | [MessageHeader(MustUnderstand = true, Namespace = "TestHeaderNamespace")]
18 | public string Prop4 { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.DataContract/SampleEnum.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.DataContract
4 | {
5 | [DataContract]
6 | public enum SampleEnum
7 | {
8 | [EnumMember]
9 | A,
10 |
11 | [EnumMember]
12 | B,
13 |
14 | [EnumMember]
15 | C,
16 |
17 | [EnumMember]
18 | D
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/BasicMessageContractPayload.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Text;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [MessageContract]
9 | public class BasicMessageContractPayload
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/ComplexLegacyModel.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Xml.Schema;
3 | using System.Xml.Serialization;
4 |
5 | namespace SoapCore.Tests.Serialization.Models.Xml
6 | {
7 | [MessageContract(WrapperName = "getLinks", WrapperNamespace = "http://xmlelement-namespace/", IsWrapped = true)]
8 | public class ComplexLegacyModel
9 | {
10 | [MessageBodyMember(Namespace = "http://xmlelement-namespace/", Order = 0)]
11 | [XmlElement("unqualified", Form = XmlSchemaForm.Unqualified)]
12 | public string[] UnqualifiedItems { get; set; }
13 |
14 | [MessageBodyMember(Namespace = "http://xmlelement-namespace/", Order = 1)]
15 | [XmlElement("qualified")]
16 | public string[] QualifiedItems { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/ComplexObject.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.Xml.Serialization;
3 |
4 | namespace SoapCore.Tests.Serialization.Models.Xml
5 | {
6 | [DataContract(Namespace = ServiceNamespace.Value)]
7 | [XmlType(Namespace = ServiceNamespace.Value)]
8 | public class ComplexObject
9 | {
10 | [DataMember(Order = 0)]
11 | [XmlAttribute]
12 | public string StringProperty { get; set; }
13 |
14 | [DataMember(Order = 1)]
15 | [XmlAttribute]
16 | public int IntProperty { get; set; }
17 |
18 | public static ComplexObject CreateSample1()
19 | => new ComplexObject
20 | {
21 | IntProperty = 1,
22 | StringProperty = $"{nameof(ComplexObject)} sample one"
23 | };
24 |
25 | public static ComplexObject CreateSample2()
26 | => new ComplexObject
27 | {
28 | IntProperty = 2,
29 | StringProperty = $"{nameof(ComplexObject)} sample two"
30 | };
31 |
32 | public static ComplexObject CreateSample3()
33 | => new ComplexObject
34 | {
35 | IntProperty = 3,
36 | StringProperty = $"{nameof(ComplexObject)} sample three"
37 | };
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/DataContractWithStream.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Serialization.Models.Xml
5 | {
6 | [MessageContract(WrapperNamespace = "TestNamespace")]
7 | public class DataContractWithStream
8 | {
9 | [MessageHeader]
10 | public string Header1 { get; set; }
11 |
12 | [MessageHeader(Namespace = "TestHeaderNamespace")]
13 | public string Header2 { get; set; }
14 |
15 | [MessageHeader(MustUnderstand = true)]
16 | public string Header3 { get; set; }
17 |
18 | [MessageHeader(MustUnderstand = true, Namespace = "TestHeaderNamespace")]
19 | public string Header4 { get; set; }
20 |
21 | [MessageBodyMember]
22 | public Stream Data { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/DataContractWithoutNamespace.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.Text;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [DataContract]
9 | public class DataContractWithoutNamespace
10 | {
11 | [DataMember]
12 | public int IntProperty { get; set; }
13 |
14 | [DataMember]
15 | public string StringProperty { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/MessageContractRequestRpcStyle.cs:
--------------------------------------------------------------------------------
1 | namespace SoapCore.Tests.Serialization.Models.Xml
2 | {
3 | [System.ServiceModel.MessageContract(WrapperName = "TestMessageContractWithWithRpcStyle", WrapperNamespace = "http://xmlelement-namespace/", IsWrapped = true)]
4 | public class MessageContractRequestRpcStyle
5 | {
6 | [System.ServiceModel.MessageBodyMember(Namespace = "", Order = 0)]
7 | public string StringParameter { get; set; }
8 |
9 | [System.ServiceModel.MessageBodyMember(Namespace = "", Order = 1)]
10 | public int IntParameter { get; set; }
11 |
12 | [System.ServiceModel.MessageBodyMember(Namespace = "", Order = 2)]
13 | public SampleEnum EnumParameter { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/MessageContractResponseRpcStyle.cs:
--------------------------------------------------------------------------------
1 | namespace SoapCore.Tests.Serialization.Models.Xml
2 | {
3 | [System.ServiceModel.MessageContract(WrapperName = "TestMessageContractWithWithRpcStyleResponse", WrapperNamespace = "http://xmlelement-namespace/", IsWrapped = true)]
4 | public class MessageContractResponseRpcStyle
5 | {
6 | [System.ServiceModel.MessageBodyMember(Namespace = "", Order = 0)]
7 | public int Result { get; set; }
8 |
9 | [System.ServiceModel.MessageBodyMember(Namespace = "", Order = 1)]
10 | public string Message { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/NotWrappedFieldComplexInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 | using System.Xml.Serialization;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [Serializable]
9 | [XmlType(AnonymousType = true, Namespace = "http://tempuri.org/NotWrappedFieldComplexInput")]
10 | public class NotWrappedFieldComplexInput
11 | {
12 | [XmlElement(Order = 0)]
13 | public string StringProperty { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/NotWrappedFieldComplexInputRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 | using System.Xml.Serialization;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [MessageContract(IsWrapped = false)]
9 | public class NotWrappedFieldComplexInputRequest
10 | {
11 | [MessageBodyMember(Namespace = "http://tempuri.org/NotWrappedFieldComplexInput", Order = 0)]
12 | #pragma warning disable SA1401 // Fields must be private
13 | public NotWrappedFieldComplexInput NotWrappedComplexInput;
14 | #pragma warning restore SA1401 // Fields must be private
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/NotWrappedFieldComplexInputResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 | using System.Xml.Serialization;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [MessageContract(IsWrapped = false)]
9 | public class NotWrappedFieldComplexInputResponse
10 | {
11 | [MessageBodyMember(Namespace = "http://tempuri.org/NotWrappedFieldComplexInput", Order = 0)]
12 | #pragma warning disable SA1401 // Fields must be private
13 | public NotWrappedFieldComplexInput NotWrappedComplexInput;
14 | #pragma warning restore SA1401 // Fields must be private
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/NotWrappedFieldDoubleComplexInputRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 | using System.Xml.Serialization;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [MessageContract(IsWrapped = false)]
9 | public class NotWrappedFieldDoubleComplexInputRequest
10 | {
11 | #pragma warning disable SA1401 // Fields must be private
12 | [MessageBodyMember(Namespace = "http://tempuri.org/NotWrappedFieldDoubleComplexInput", Order = 0)]
13 | public NotWrappedFieldComplexInput NotWrappedComplexInput1;
14 |
15 | [MessageBodyMember(Namespace = "http://tempuri.org/NotWrappedFieldDoubleComplexInput", Order = 1)]
16 | public NotWrappedFieldComplexInput NotWrappedComplexInput2;
17 | #pragma warning restore SA1401 // Fields must be private
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/NotWrappedPropertyComplexInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 | using System.Xml.Serialization;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [Serializable]
9 | [XmlType(AnonymousType = true, Namespace = "http://tempuri.org/NotWrappedPropertyComplexInput")]
10 | public class NotWrappedPropertyComplexInput
11 | {
12 | [XmlElement(Order = 0)]
13 | public string StringProperty { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/NotWrappedPropertyComplexInputRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 | using System.Xml.Serialization;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [MessageContract(IsWrapped = false)]
9 | public class NotWrappedPropertyComplexInputRequest
10 | {
11 | [MessageBodyMember(Namespace = "http://tempuri.org/NotWrappedPropertyComplexInput", Order = 0)]
12 | public NotWrappedPropertyComplexInput NotWrappedComplexInput { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/NotWrappedPropertyComplexInputResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 | using System.Xml.Serialization;
5 |
6 | namespace SoapCore.Tests.Serialization.Models.Xml
7 | {
8 | [MessageContract(IsWrapped = false)]
9 | public class NotWrappedPropertyComplexInputResponse
10 | {
11 | [MessageBodyMember(Namespace = "http://tempuri.org/NotWrappedPropertyComplexInput", Order = 0)]
12 | public NotWrappedPropertyComplexInput NotWrappedComplexInput { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/PingComplexMessageHeaderArrayRequest.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.Xml
4 | {
5 | [MessageContract(WrapperName = nameof(ISampleService.PingComplexMessageHeaderArray), WrapperNamespace = ServiceNamespace.Value, IsWrapped = true)]
6 | public class PingComplexMessageHeaderArrayRequest
7 | {
8 | [MessageHeader(Namespace = ServiceNamespace.Value)]
9 | [System.Xml.Serialization.XmlArrayItemAttribute("ComplexModel1", Namespace = ServiceNamespace.Value + "SomethingDifferent", IsNullable = false)]
10 | public ComplexModel1[] MyHeaderValue { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/PingComplexMessageHeaderArrayResponse.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.Xml
4 | {
5 | [MessageContract(WrapperName = nameof(PingComplexMessageHeaderArrayResponse), WrapperNamespace = ServiceNamespace.Value, IsWrapped = true)]
6 | public class PingComplexMessageHeaderArrayResponse
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/PingComplexMessageMessageContractAttributeResponse.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.Xml
4 | {
5 | [MessageContract(WrapperName = "MyWrapperNameIsDifferentFromTheClass", WrapperNamespace = ServiceNamespace.Value, IsWrapped = true)]
6 | public class PingComplexMessageMessageContractAttributeResponse
7 | {
8 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 0)]
9 | public ComplexModel1 ComplexProperty { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/PingComplexModelOldStyleRequest.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.Xml
4 | {
5 | [MessageContract(WrapperName = nameof(ISampleService.PingComplexModelOldStyle), WrapperNamespace = ServiceNamespace.Value, IsWrapped = true)]
6 | public class PingComplexModelOldStyleRequest
7 | {
8 | // pure input value, similar to non-ref param in new style
9 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 0)]
10 | public ComplexModel1 InputModel { get; set; }
11 |
12 | // ref (in and out) param, present both in request and response
13 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 1)]
14 | public ComplexModel2 ResponseModelRef1 { get; set; }
15 |
16 | // pure input value
17 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 2)]
18 | public ComplexObject Data1 { get; set; }
19 |
20 | // ref (in and out) param, present both in request and response
21 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 3)]
22 | public ComplexModel1 ResponseModelRef2 { get; set; }
23 |
24 | // pure input value
25 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 4)]
26 | public ComplexObject Data2 { get; set; }
27 |
28 | // pure output param, not present in request
29 | // out ComplexModel2 responseModelOut1
30 | // out ComplexModel1 responseModelOut2
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/PingComplexModelOldStyleResponse.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.Xml
4 | {
5 | [MessageContract(WrapperName = nameof(PingComplexModelOldStyleResponse), WrapperNamespace = ServiceNamespace.Value, IsWrapped = true)]
6 | public class PingComplexModelOldStyleResponse
7 | {
8 | // similar to return result in new style
9 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 0)]
10 | public bool PingComplexModelOldStyleResult { get; set; }
11 |
12 | // pure input value, similar to non-ref param in new style
13 | // not present in response
14 | // ComplexModel1 inputModel;
15 |
16 | // ref (in and out) param, present both in request and response
17 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 1)]
18 | public ComplexModel2 ResponseModelRef1 { get; set; }
19 |
20 | // pure input value, not present in response
21 | // ComplexObject data1
22 |
23 | // ref (in and out) param, present both in request and response
24 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 2)]
25 | public ComplexModel1 ResponseModelRef2 { get; set; }
26 |
27 | // pure input value, not present in response
28 | // ComplexObject data2
29 |
30 | // pure output param, present only in response
31 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 3)]
32 | public ComplexModel2 ResponseModelOut1 { get; set; }
33 |
34 | // pure output param, present only in response
35 | [MessageBodyMember(Namespace = ServiceNamespace.Value, Order = 4)]
36 | public ComplexModel1 ResponseModelOut2 { get; set; }
37 |
38 | // pure input value
39 | // not present in response
40 | // ComplexObject data2
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/SampleEnum.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.Xml.Serialization;
3 |
4 | namespace SoapCore.Tests.Serialization.Models.Xml
5 | {
6 | [DataContract(Namespace = ServiceNamespace.Value)]
7 | [XmlType(Namespace = ServiceNamespace.Value)]
8 | public enum SampleEnum
9 | {
10 | [EnumMember]
11 | A,
12 |
13 | [EnumMember]
14 | B,
15 |
16 | [EnumMember]
17 | C,
18 |
19 | [EnumMember]
20 | D
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/ServiceNamespace.cs:
--------------------------------------------------------------------------------
1 | namespace SoapCore.Tests.Serialization.Models.Xml
2 | {
3 | public static class ServiceNamespace
4 | {
5 | public const string Value = "http://sampleservice.net/webservices/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/UnwrappedMultipleMessageBodyMemberResponse.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.Xml
4 | {
5 | [MessageContract(IsWrapped = false)]
6 | public class UnwrappedMultipleMessageBodyMemberResponse
7 | {
8 | [MessageBodyMember(Name = "foo1", Namespace = "http://tempuri.org/NotWrappedPropertyComplexInput")]
9 | public NotWrappedPropertyComplexInput NotWrappedComplexInput1 { get; set; }
10 |
11 | [MessageBodyMember(Name = "foo2", Namespace = "http://tempuri.org/NotWrappedPropertyComplexInput")]
12 | public NotWrappedPropertyComplexInput NotWrappedComplexInput2 { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/Models.Xml/UnwrappedStringMessageBodyMemberResponse.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Serialization.Models.Xml
4 | {
5 | [MessageContract(IsWrapped = false)]
6 | public class UnwrappedStringMessageBodyMemberResponse
7 | {
8 | [MessageBodyMember]
9 | public string StringProperty { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Serialization/xunit.runner.json:
--------------------------------------------------------------------------------
1 | {
2 | "parallelizeTestCollections": false
3 | }
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ServiceDescription/IServiceWithName.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Text;
5 |
6 | namespace SoapCore.Tests
7 | {
8 | [ServiceContract(Name="MyServiceWithName")]
9 | internal interface IServiceWithName
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ServiceDescription/IServiceWithoutName.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace SoapCore.Tests
6 | {
7 | internal interface IServiceWithoutName
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ServiceDescription/ServiceContractTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using SoapCore.ServiceModel;
5 | using Xunit;
6 |
7 | namespace SoapCore.Tests
8 | {
9 | public class ServiceContractTests
10 | {
11 | [Fact]
12 | public void TestFallbackOfServiceNameToTypeName()
13 | {
14 | ServiceDescription serviceDescription = new ServiceDescription(typeof(IServiceWithoutName), false);
15 |
16 | Assert.Equal("IServiceWithoutName", serviceDescription.ServiceName);
17 | }
18 |
19 | [Fact]
20 | public void TestExplicitlySetServiceName()
21 | {
22 | ServiceDescription serviceDescription = new ServiceDescription(typeof(IServiceWithName), false);
23 |
24 | Assert.Equal("MyServiceWithName", serviceDescription.ServiceName);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ServiceOperationTuner/ClientMessageInspector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.ServiceModel.Channels;
4 | using System.ServiceModel.Dispatcher;
5 |
6 | namespace SoapCore.Tests.ServiceOperationTuner
7 | {
8 | public class ClientMessageInspector : IClientMessageInspector
9 | {
10 | private readonly string _customPingValue;
11 |
12 | public ClientMessageInspector(string customPingValue)
13 | {
14 | _customPingValue = customPingValue;
15 | }
16 |
17 | public void AfterReceiveReply(ref Message reply, object correlationState)
18 | {
19 | }
20 |
21 | public object BeforeSendRequest(ref Message request, IClientChannel channel)
22 | {
23 | HttpRequestMessageProperty httpRequestMessage;
24 | object httpRequestMessageObject;
25 |
26 | if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out httpRequestMessageObject))
27 | {
28 | httpRequestMessage = httpRequestMessageObject as HttpRequestMessageProperty;
29 | }
30 | else
31 | {
32 | httpRequestMessage = new HttpRequestMessageProperty();
33 | request.Properties.Add(HttpRequestMessageProperty.Name, httpRequestMessage);
34 | }
35 |
36 | httpRequestMessage.Headers["ping_value"] = _customPingValue;
37 |
38 | return Guid.NewGuid();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ServiceOperationTuner/CustomHeadersEndpointBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 | using System.ServiceModel.Description;
3 | using System.ServiceModel.Dispatcher;
4 |
5 | namespace SoapCore.Tests.ServiceOperationTuner
6 | {
7 | public class CustomHeadersEndpointBehavior : IEndpointBehavior
8 | {
9 | private string _customPingValue;
10 |
11 | public CustomHeadersEndpointBehavior(string customPingValue)
12 | {
13 | _customPingValue = customPingValue;
14 | }
15 |
16 | public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
17 | {
18 | clientRuntime.ClientMessageInspectors.Add(new ClientMessageInspector(_customPingValue));
19 | }
20 |
21 | public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
22 | {
23 | }
24 |
25 | public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
26 | {
27 | }
28 |
29 | public void Validate(ServiceEndpoint endpoint)
30 | {
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ServiceOperationTuner/Startup.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using Microsoft.AspNetCore.Builder;
3 | using Microsoft.AspNetCore.Hosting;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.Extensions.DependencyInjection.Extensions;
6 | using Microsoft.Extensions.Logging;
7 |
8 | namespace SoapCore.Tests.ServiceOperationTuner
9 | {
10 | public class Startup
11 | {
12 | public void ConfigureServices(IServiceCollection services)
13 | {
14 | services.AddSoapCore();
15 | services.TryAddSingleton();
16 | services.AddSoapServiceOperationTuner(new TestServiceOperationTuner());
17 | services.AddMvc();
18 | }
19 |
20 | #if !NETCOREAPP3_0_OR_GREATER
21 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
22 | {
23 | app.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
24 | app.UseMvc();
25 | }
26 | #else
27 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
28 | {
29 | app.UseRouting();
30 |
31 | app.UseEndpoints(x =>
32 | {
33 | x.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
34 | });
35 | }
36 | #endif
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/ServiceOperationTuner/TestServiceOperationTuner.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.Extensions.Primitives;
3 | using SoapCore;
4 | using SoapCore.Extensibility;
5 |
6 | namespace SoapCore.Tests.ServiceOperationTuner
7 | {
8 | public class TestServiceOperationTuner : IServiceOperationTuner
9 | {
10 | public static bool IsCalled { get; private set; }
11 | public static bool IsSetPingValue { get; private set; }
12 | public static bool IsBodyAvailable { get; private set; }
13 |
14 | public static void Reset()
15 | {
16 | IsCalled = false;
17 | IsSetPingValue = false;
18 | IsBodyAvailable = false;
19 | }
20 |
21 | public void Tune(HttpContext httpContext, object serviceInstance, ServiceModel.OperationDescription operation)
22 | {
23 | IsCalled = true;
24 | if ((serviceInstance != null) && (serviceInstance is TestService)
25 | && operation.Name.Equals("PingWithServiceOperationTuning"))
26 | {
27 | TestService service = serviceInstance as TestService;
28 | string result = string.Empty;
29 |
30 | StringValues pingValue;
31 | if (httpContext.Request.Headers.TryGetValue("ping_value", out pingValue))
32 | {
33 | result = pingValue[0];
34 | }
35 |
36 | if (httpContext.Request.Body.CanRead)
37 | {
38 | IsBodyAvailable = true;
39 | }
40 |
41 | service.SetPingResult(result);
42 | IsSetPingValue = true;
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/TestServiceKnownTypesProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Text;
5 | using SoapCore.Tests.Model;
6 |
7 | namespace SoapCore.Tests
8 | {
9 | public static class TestServiceKnownTypesProvider
10 | {
11 | public static Type[] GetKnownTypes(ICustomAttributeProvider provider)
12 | {
13 | return new Type[] { typeof(ComplexModelInput), typeof(ComplexTreeModelInput) };
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/TrailingServicePathTuner/ISoapService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests
4 | {
5 | [ServiceContract(Namespace = "http://localhost/MockSoapService")]
6 | public interface ISoapService
7 | {
8 | [OperationContract(Action = "http://localhost/MockSoapService/GetMock")]
9 | string Get();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/TrailingServicePathTuner/MockModelBounder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Text;
5 | using SoapCore.Extensibility;
6 |
7 | namespace SoapCore.Tests
8 | {
9 | internal class MockModelBounder : ISoapModelBounder
10 | {
11 | public void OnModelBound(MethodInfo methodInfo, object[] prms)
12 | {
13 | return;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/TrailingServicePathTuner/MockServiceProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SoapCore.Tests
4 | {
5 | internal class MockServiceProvider : IServiceProvider
6 | {
7 | private readonly bool _isTrailingService;
8 |
9 | public MockServiceProvider(bool isTrailingService)
10 | {
11 | _isTrailingService = isTrailingService;
12 | }
13 |
14 | public object GetService(Type serviceType)
15 | {
16 | return (serviceType == typeof(TrailingServicePathTuner) && _isTrailingService) ? new TrailingServicePathTuner() : null;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/TrailingServicePathTuner/MockSoapService.cs:
--------------------------------------------------------------------------------
1 | namespace SoapCore.Tests
2 | {
3 | public class MockSoapService : ISoapService
4 | {
5 | public string Get() => "Hello Test";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Utilities/CustomTextMessageEncoderFactory.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 |
3 | namespace SoapCore.Tests.Utilities
4 | {
5 | public class CustomTextMessageEncoderFactory : MessageEncoderFactory
6 | {
7 | private readonly System.ServiceModel.Channels.MessageEncoder _encoder;
8 | private readonly MessageVersion _version;
9 | private readonly string _mediaType;
10 | private readonly string _charSet;
11 |
12 | internal CustomTextMessageEncoderFactory(string mediaType, string charSet, MessageVersion version)
13 | {
14 | _version = version;
15 | _mediaType = mediaType;
16 | _charSet = charSet;
17 | _encoder = new CustomTextMessageEncoder(this);
18 | }
19 |
20 | public override System.ServiceModel.Channels.MessageEncoder Encoder
21 | {
22 | get
23 | {
24 | return _encoder;
25 | }
26 | }
27 |
28 | public override MessageVersion MessageVersion
29 | {
30 | get
31 | {
32 | return _version;
33 | }
34 | }
35 |
36 | internal string MediaType
37 | {
38 | get
39 | {
40 | return _mediaType;
41 | }
42 | }
43 |
44 | internal string CharSet
45 | {
46 | get
47 | {
48 | return _charSet;
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Utilities/XElementExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Runtime.Serialization;
3 | using System.Xml.Linq;
4 | using SoapCore.Tests.Model;
5 |
6 | namespace SoapCore.Tests.Utilities
7 | {
8 | public static class XElementExtensions
9 | {
10 | public static T DeserializeInnerElementAs(this XElement element)
11 | {
12 | var serializer = new DataContractSerializer(typeof(FaultDetail));
13 | var innerElement = element.Elements().SingleOrDefault();
14 |
15 | using (var reader = innerElement.CreateReader())
16 | {
17 | return (T)serializer.ReadObject(reader);
18 | }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/DefaultWsdlOperationNameGeneratorTests.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using SoapCore.Meta;
3 | using SoapCore.ServiceModel;
4 | using SoapCore.Tests.Wsdl.Services;
5 | using Xunit;
6 |
7 | namespace SoapCore.Tests.Wsdl
8 | {
9 | public class DefaultWsdlOperationNameGeneratorTests
10 | {
11 | private readonly ServiceDescription _serviceDescription;
12 | private readonly ServiceModel.OperationDescription _operation;
13 | private readonly DefaultWsdlOperationNameGenerator _generator;
14 |
15 | public DefaultWsdlOperationNameGeneratorTests()
16 | {
17 | _serviceDescription = new ServiceDescription(typeof(IEnumService), false);
18 | var contractDescription = new ContractDescription(_serviceDescription, typeof(IEnumService), new ServiceContractAttribute(), false);
19 | var method = typeof(IEnumService).GetMethod(nameof(IEnumService.Method));
20 | var contractAttribute = new OperationContractAttribute();
21 | _operation = new ServiceModel.OperationDescription(contractDescription, method, contractAttribute, false);
22 |
23 | _generator = new DefaultWsdlOperationNameGenerator();
24 | }
25 |
26 | [Fact]
27 | public void TestGenerateWsdlInputMessageName()
28 | {
29 | var result = _generator.GenerateWsdlInputMessageName(_operation, _serviceDescription);
30 | Assert.Equal("IEnumService_Method_InputMessage", result);
31 | }
32 |
33 | [Fact]
34 | public void TestGenerateWsdlOutputMessageName()
35 | {
36 | var result = _generator.GenerateWsdlOutputMessageName(_operation, _serviceDescription);
37 | Assert.Equal("IEnumService_Method_OutputMessage", result);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/IStartupConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace SoapCore.Tests.Wsdl
6 | {
7 | public interface IStartupConfiguration
8 | {
9 | Type ServiceType { get; }
10 |
11 | string SchemeOverride { get; }
12 | }
13 |
14 | public class StartupConfiguration : IStartupConfiguration
15 | {
16 | public StartupConfiguration(Type serviceType, string schemeOverride)
17 | {
18 | ServiceType = serviceType;
19 | SchemeOverride = schemeOverride;
20 | }
21 |
22 | public Type ServiceType { get; }
23 |
24 | public string SchemeOverride { get; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ArrayOfStringModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml.Serialization;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [Serializable]
7 | public class ArrayOfStringModel
8 | {
9 | [XmlElement("file")]
10 | public string[] File
11 | {
12 | get;
13 | set;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ArrayService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | #pragma warning disable SA1649 // File name should match first type name
7 | #pragma warning disable SA1402 // File may only contain a single type
8 | [ServiceContract(Namespace = "http://bagov.net/")]
9 | public interface IArrayService
10 | {
11 | [OperationContract]
12 | [XmlSerializerFormat]
13 | EnumerableResponse GetResponse(ArrayRequest request);
14 | }
15 |
16 | public class ArrayService : IArrayService
17 | {
18 | public EnumerableResponse GetResponse(ArrayRequest request)
19 | {
20 | return new EnumerableResponse();
21 | }
22 | }
23 |
24 | [MessageContract]
25 | public class EnumerableResponse
26 | {
27 | public IEnumerable LongNullableEnumerable { get; set; }
28 | public IEnumerable LongEnumerable { get; set; }
29 | public IEnumerable> LongEnumerableEnumerable { get; set; }
30 | public IEnumerable> StringEnumerableEnumerable { get; set; }
31 | }
32 |
33 | [MessageContract]
34 | public class ArrayRequest
35 | {
36 | public long?[] LongNullableArray { get; set; }
37 | public long[] LongArray { get; set; }
38 | public long[][] LongArrayArray { get; set; }
39 | public List> StringListList { get; set; }
40 | public List InnerClassList { get; set; }
41 | }
42 |
43 | // Class starts with lower-case letter on purpose for a test
44 | #pragma warning disable SA1300 // Element should begin with upper-case letter
45 | public class innerClass
46 | #pragma warning restore SA1300 // Element should begin with upper-case letter
47 | {
48 | public string Name { get; set; }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/AttributeType.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | public class AttributeType
6 | {
7 | [XmlAttribute]
8 | public string StringProperty { get; set; }
9 |
10 | [XmlAttribute]
11 | public int IntProperty { get; set; }
12 |
13 | [XmlAttribute]
14 | public int OptionalIntProperty { get; set; }
15 |
16 | public bool ShouldSerializeOptionalIntProperty()
17 | {
18 | return OptionalIntProperty != 0;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/CircularReferenceFirstObject.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [DataContract]
6 | public class CircularReferenceFirstObject
7 | {
8 | [DataMember]
9 | public CircularReferenceSecondObject SecondObject { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/CircularReferenceSecondObject.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [DataContract]
6 | public class CircularReferenceSecondObject
7 | {
8 | [DataMember]
9 | public CircularReferenceFirstObject FirstObject { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ComplexComplexType.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | public class ComplexComplexType
6 | {
7 | [XmlElement(ElementName = "complex")]
8 | public ComplexType ComplexType { get; set; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ComplexType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Xml.Serialization;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | public class ComplexType
8 | {
9 | public int IntProperty { get; set; }
10 | [XmlElement(ElementName = "stringprop")]
11 | public string StringProperty { get; set; }
12 | [XmlElement(ElementName = "mybytes")]
13 | public byte[] ByteArrayProperty { get; set; }
14 |
15 | public Guid MyGuid { get; set; }
16 |
17 | public List StringList { get; set; }
18 |
19 | public List IntList { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ComplexTypeAnonymous.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Xml.Serialization;
7 |
8 | namespace SoapCore.Tests.Wsdl.Services
9 | {
10 | [XmlType(AnonymousType = true)]
11 | public class ComplexTypeAnonymous
12 | {
13 | public int IntProperty { get; set; }
14 | [XmlElement(ElementName = "stringprop")]
15 | public string StringProperty { get; set; }
16 | [XmlElement(ElementName = "mybytes")]
17 | public byte[] ByteArrayProperty { get; set; }
18 |
19 | public Guid MyGuid { get; set; }
20 |
21 | public List StringList { get; set; }
22 |
23 | public List IntList { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/CustomDictionary.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | public class CustomDictionary : Dictionary
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/Date.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 | using System.Xml.Schema;
4 | using System.Xml.Serialization;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | [XmlSchemaProvider("MyCustomSchemaProvider")]
9 | public class Date : IXmlSerializable
10 | {
11 | private DateTime _date;
12 |
13 | public Date() : this(DateTime.MinValue)
14 | {
15 | }
16 |
17 | public Date(DateTime date) => _date = date;
18 |
19 | public static XmlQualifiedName MyCustomSchemaProvider(XmlSchemaSet xs)
20 | => new XmlQualifiedName("date", "http://www.w3.org/2001/XMLSchema");
21 | public XmlSchema GetSchema() => null;
22 |
23 | public void ReadXml(XmlReader reader) => _date = reader.ReadElementContentAsDateTime();
24 | public void WriteXml(XmlWriter writer) => writer.WriteValue(_date.ToString("yyyy-MM-dd"));
25 |
26 | public DateTime GetDate() => DateTime.SpecifyKind(_date, DateTimeKind.Utc);
27 | public new string ToString() => _date.ToString("yyyy-MM-dd");
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/DefaultValuesAttributesService.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | #pragma warning disable SA1649 // File name should match first type name
7 | #pragma warning disable SA1402 // File may only contain a single type
8 | [ServiceContract(Namespace = "http://bagov.net")]
9 | public interface IDefaultValueAttributesService
10 | {
11 | [OperationContract]
12 | DefaultValueAttributesResponseType GetResponse();
13 | }
14 |
15 | public class DefaultValueAttributesService : IDefaultValueAttributesService
16 | {
17 | public DefaultValueAttributesResponseType GetResponse()
18 | {
19 | return new DefaultValueAttributesResponseType();
20 | }
21 | }
22 |
23 | public class DefaultValueAttributesResponseType
24 | {
25 | public bool BooleanWithNoDefaultProperty { get; set; }
26 |
27 | [DefaultValue(null)]
28 | public bool BooleanWithDefaultNullProperty { get; set; }
29 |
30 | [DefaultValue(false)]
31 | public bool BooleanWithDefaultFalseProperty { get; set; }
32 |
33 | [DefaultValue(true)]
34 | public string BooleanWithDefaultTrueProperty { get; set; }
35 |
36 | public int IntWithNoDefaultProperty { get; set; }
37 |
38 | [DefaultValue(42)]
39 | public int IntWithDefaultProperty { get; set; }
40 |
41 | public string StringWithNoDefaultProperty { get; set; }
42 |
43 | [DefaultValue(null)]
44 | public string StringWithDefaultNullProperty { get; set; }
45 |
46 | [DefaultValue("default")]
47 | public string StringWithDefaultProperty { get; set; }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/EmptyMembers.cs:
--------------------------------------------------------------------------------
1 | namespace SoapCore.Tests.Wsdl.Services
2 | {
3 | //[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
4 | public class EmptyMembers
5 | {
6 | public EmptyMembers()
7 | {
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/EnumWithCustomNames.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | public enum EnumWithCustomNames
6 | {
7 | [XmlEnum("F")]
8 | FirstEnumMember = -2,
9 |
10 | [XmlEnum("S")]
11 | SecondEnumMember = 1,
12 |
13 | ThirdEnumMember = 0
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ErrorDetail.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.Serialization;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [DataContract]
7 | public class ErrorDetail
8 | {
9 | [DataMember]
10 | public string Error { get; set; }
11 |
12 | [DataMember]
13 | public List SubErrors { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/FailedOperation.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [DataContract]
6 | public class FailedOperation
7 | {
8 | [DataMember]
9 | public string Message { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IActionResultContractService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using Microsoft.AspNetCore.Mvc;
3 | using SoapCore.Tests.Model;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | [ServiceContract]
8 | public interface IActionResultContractService
9 | {
10 | [OperationContract]
11 | IActionResult IActionResultTest();
12 |
13 | [OperationContract]
14 | ActionResult ActionResultTest();
15 |
16 | [OperationContract]
17 | ActionResult GenericActionResultTest();
18 |
19 | [OperationContract]
20 | ActionResult ComplexGenericActionResultTest();
21 | }
22 |
23 | public class ActionResultContractService : IActionResultContractService
24 | {
25 | public ActionResult ActionResultTest()
26 | {
27 | throw new System.NotImplementedException();
28 | }
29 |
30 | public ActionResult ComplexGenericActionResultTest()
31 | {
32 | throw new System.NotImplementedException();
33 | }
34 |
35 | public ActionResult GenericActionResultTest()
36 | {
37 | throw new System.NotImplementedException();
38 | }
39 |
40 | public IActionResult IActionResultTest()
41 | {
42 | throw new System.NotImplementedException();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IAnonymousServiceKnownTypesService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | [ServiceKnownType(typeof(AnonymousServiceKnownTypesService.Dog))]
8 | [ServiceContract]
9 | public interface IAnonymousServiceKnownTypesService
10 | {
11 | [ServiceKnownType(typeof(AnonymousServiceKnownTypesService.Cat))]
12 | [OperationContract]
13 | object TestFromTypedToAny(AnonymousServiceKnownTypesService.Animal value);
14 |
15 | [ServiceKnownType(typeof(AnonymousServiceKnownTypesService.Squirrel))]
16 | [OperationContract]
17 | AnonymousServiceKnownTypesService.Animal TestFromAnyToTyped(object value);
18 | }
19 |
20 | public class AnonymousServiceKnownTypesService : IAnonymousServiceKnownTypesService
21 | {
22 | public object TestFromTypedToAny(Animal value)
23 | {
24 | return value;
25 | }
26 |
27 | public Animal TestFromAnyToTyped(object value)
28 | {
29 | if (value is null)
30 | {
31 | throw new ArgumentNullException(nameof(value));
32 | }
33 |
34 | if (value is Animal result)
35 | {
36 | return result;
37 | }
38 |
39 | throw new Exception($"Object of type `{value.GetType()}` is not supported in this context.");
40 | }
41 |
42 | [DataContract(Name = "Animal")]
43 | public class Animal
44 | {
45 | }
46 |
47 | [DataContract(Name = "Dog")]
48 | public class Dog : Animal
49 | {
50 | }
51 |
52 | [DataContract(Name = "Cat")]
53 | public class Cat : Animal
54 | {
55 | }
56 |
57 | [DataContract(Name = "Squirrel")]
58 | public class Squirrel : Animal
59 | {
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IAttributeService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SoapCore.Tests.Wsdl.Services
9 | {
10 | [ServiceContract]
11 | public interface IAttributeService
12 | {
13 | [OperationContract]
14 | AttributeType Method();
15 | }
16 |
17 | public class AttributeService : IAttributeService
18 | {
19 | public AttributeType Method()
20 | {
21 | throw new NotImplementedException();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ICollectionDataContractService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.ServiceModel;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | [ServiceContract]
9 | public interface ICollectionDataContractService
10 | {
11 | [OperationContract]
12 | CollectionDataContractService.MyList ListStrings();
13 |
14 | [OperationContract]
15 | CollectionDataContractService.MyList ListMyTypes();
16 | }
17 |
18 | public class CollectionDataContractService : ICollectionDataContractService
19 | {
20 | public MyList ListStrings() => throw new NotImplementedException();
21 | public MyList ListMyTypes() => throw new NotImplementedException();
22 |
23 | [CollectionDataContract(Namespace = "http://testnamespace.org", Name = "My{0}List", ItemName = "MyItem")]
24 | public class MyList : List
25 | {
26 | }
27 |
28 | public class MyType
29 | {
30 | public string MyProperty { get; set; }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IComplexAnonymousListService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SoapCore.Tests.Wsdl.Services
9 | {
10 | [ServiceContract]
11 | public interface IComplexAnonymousListService
12 | {
13 | [OperationContract]
14 | List Test();
15 | }
16 |
17 | public class ComplexAnonymousListService : IComplexAnonymousListService
18 | {
19 | public List Test() => throw new NotImplementedException();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IComplexBaseTypeService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services;
5 |
6 | [ServiceContract]
7 | public interface IComplexBaseTypeService
8 | {
9 | [OperationContract]
10 | DerivedTypeList Method(DerivedTypeList argument);
11 | }
12 |
13 | public class ComplexBaseTypeService : IComplexBaseTypeService
14 | {
15 | public DerivedTypeList Method(DerivedTypeList argument)
16 | {
17 | return new DerivedTypeList();
18 | }
19 | }
20 |
21 | public class BaseType
22 | {
23 | public string BaseName { get; set; }
24 | }
25 |
26 | public class DerivedType : BaseType
27 | {
28 | public string DerivedName { get; set; }
29 | }
30 |
31 | public class DerivedTypeList : List
32 | {
33 | }
34 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IComplexComplexTypeWithCustomXmlNamesService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IComplexComplexTypeWithCustomXmlNamesService
8 | {
9 | [OperationContract]
10 | ComplexComplexType Method(out string message);
11 | }
12 |
13 | public class ComplexComplexTypeWithCustomXmlNamesService : IComplexComplexTypeWithCustomXmlNamesService
14 | {
15 | public ComplexComplexType Method(out string message)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IComplexTypeAndOutParameterService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IComplexTypeAndOutParameterService
8 | {
9 | [OperationContract]
10 | ComplexType Method(out string message);
11 | }
12 |
13 | public class ComplexTypeAndOutParameterService : IComplexTypeAndOutParameterService
14 | {
15 | public ComplexType Method(out string message)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IDataContractCircularReferenceService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IDataContractCircularReferenceService
8 | {
9 | [OperationContract]
10 | CircularReferenceFirstObject GetFirstObject();
11 | }
12 |
13 | public class DataContractCircularReferenceService : IDataContractCircularReferenceService
14 | {
15 | public CircularReferenceFirstObject GetFirstObject()
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IDataContractContainsItselfService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.Text;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | [ServiceContract]
8 | public interface IDataContractContainsItselfService
9 | {
10 | [OperationContract]
11 | PaymentResponse GetErrorDetail();
12 | }
13 |
14 | public class DataContractContainsItselfService : IDataContractContainsItselfService
15 | {
16 | public PaymentResponse GetErrorDetail()
17 | {
18 | throw new NotImplementedException();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IDataContractNameService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | [ServiceContract]
8 | public interface IDataContractNameService
9 | {
10 | [OperationContract]
11 | DataContractNameService.ChildClass Test();
12 | }
13 |
14 | public class DataContractNameService : IDataContractNameService
15 | {
16 | public ChildClass Test() => throw new NotImplementedException();
17 |
18 | [DataContract(Name = "BaseRenamed")]
19 | public class BaseClass
20 | {
21 | [DataMember]
22 | public string BaseProp { get; set; }
23 | }
24 |
25 | [DataContract(Name = "ChildRenamed")]
26 | public class ChildClass : BaseClass
27 | {
28 | [DataMember]
29 | public string ChildProp { get; set; }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IDataContractWithNonDataMembersService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [ServiceContract]
6 | public interface IDataContractWithNonDataMembersService
7 | {
8 | [OperationContract]
9 | TypeWithNonDataMembers Method(TypeWithNonDataMembers argument);
10 | }
11 |
12 | public class DataContractWithNonDataMembersService : IDataContractWithNonDataMembersService
13 | {
14 | public TypeWithNonDataMembers Method(TypeWithNonDataMembers argument)
15 | {
16 | return new TypeWithNonDataMembers();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IDatetimeOffsetService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IDatetimeOffsetService
8 | {
9 | [OperationContract]
10 | DateTimeOffset Method(DateTimeOffset model);
11 | }
12 |
13 | public class DateTimeOffsetService : IDatetimeOffsetService
14 | {
15 | public DateTimeOffset Method(DateTimeOffset model)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IDictionaryTypeListService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using SoapCore.Tests.Model;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | [ServiceContract]
9 | public interface IDictionaryTypeListService
10 | {
11 | [OperationContract]
12 | List Test();
13 |
14 | [OperationContract]
15 | Dictionary DictionaryTest(Dictionary thing);
16 | }
17 |
18 | public class DictionaryTypeListService : IDictionaryTypeListService
19 | {
20 | public Dictionary DictionaryTest(Dictionary thing)
21 | {
22 | throw new NotImplementedException();
23 | }
24 |
25 | public List Test() => throw new NotImplementedException();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IEmptyNamespaceService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [ServiceContract(Namespace = "")]
6 | public interface IEmptyNamespaceService
7 | {
8 | [OperationContract]
9 | void TestMethod();
10 | }
11 |
12 | public class EmptyNamespaceService : IEmptyNamespaceService
13 | {
14 | public void TestMethod()
15 | {
16 | // Do nothing
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IEnumListService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.ServiceModel;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | [ServiceContract]
9 | public interface IEnumListService
10 | {
11 | [OperationContract]
12 | List List();
13 | }
14 |
15 | public class EnumListService : IEnumListService
16 | {
17 | [DataContract]
18 | public enum TestEnum
19 | {
20 | [EnumMember]
21 | A,
22 |
23 | [EnumMember]
24 | B
25 | }
26 |
27 | public List List() => throw new NotImplementedException();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IEnumService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services;
4 |
5 | [ServiceContract]
6 | public interface IEnumService
7 | {
8 | [OperationContract]
9 | TypeWithEnums Method(TypeWithEnums argument);
10 | }
11 |
12 | public class EnumService : IEnumService
13 | {
14 | public TypeWithEnums Method(TypeWithEnums argument)
15 | {
16 | return new TypeWithEnums();
17 | }
18 | }
19 |
20 | public class TypeWithEnums
21 | {
22 | public NulEnum Enum { get; set; }
23 | public NulEnum? NullEnum { get; set; }
24 | }
25 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IEnumWithCustomNamesService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IEnumWithCustomNamesService
8 | {
9 | [OperationContract]
10 | EnumWithCustomNames? GetEnum(string text);
11 | }
12 |
13 | public class EnumWithCustomNamesService : IEnumWithCustomNamesService
14 | {
15 | public EnumWithCustomNames? GetEnum(string text)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IGenericDataContractService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | [ServiceContract]
8 | public interface IGenericDataContractService
9 | {
10 | [OperationContract]
11 | GenericDataContractService.MyType TestString();
12 |
13 | [OperationContract]
14 | GenericDataContractService.MyType TestMyArg();
15 | }
16 |
17 | public class GenericDataContractService : IGenericDataContractService
18 | {
19 | public MyType TestString() => throw new NotImplementedException();
20 |
21 | public MyType TestMyArg() => throw new NotImplementedException();
22 |
23 | [DataContract(Name = "My{0}Type", Namespace = "http://testnamespace.org")]
24 | public class MyType
25 | {
26 | [DataMember]
27 | public T Value { get; set; }
28 | }
29 |
30 | public class MyArg
31 | {
32 | public string Value { get; set; }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IInheritanceService.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IInheritanceService
8 | {
9 | [OperationContract]
10 | InheritanceService.Animal Test();
11 | }
12 |
13 | public class InheritanceService : IInheritanceService
14 | {
15 | public Animal Test()
16 | {
17 | return new Dog
18 | {
19 | Name = "Test",
20 | };
21 | }
22 |
23 | [KnownType(typeof(Dog))]
24 | [DataContract(Name = "Animal")]
25 | public abstract class Animal
26 | {
27 | [DataMember]
28 | public string Name { get; set; }
29 | }
30 |
31 | [DataContract(Name = "Dog")]
32 | public class Dog : Animal
33 | {
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/INonNullableEnumService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface INonNullableEnumService
8 | {
9 | [OperationContract]
10 | NulEnum GetEnum(string text);
11 | }
12 |
13 | public class NonNullableEnumService : INonNullableEnumService
14 | {
15 | public NulEnum GetEnum(string text)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/INullableEnumService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface INullableEnumService
8 | {
9 | [OperationContract]
10 | NulEnum? GetEnum(string text);
11 | }
12 |
13 | public class NullableEnumService : INullableEnumService
14 | {
15 | public NulEnum? GetEnum(string text)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IObjectWithArrayService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Text;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | [ServiceContract]
9 | public interface IObjectWithArrayService
10 | {
11 | [OperationContract]
12 | void Method(MyClassWithArray model);
13 | }
14 |
15 | public class ObjectWithArrayService : IObjectWithArrayService
16 | {
17 | public void Method(MyClassWithArray model)
18 | {
19 | throw new NotImplementedException();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IOperationContractEmptyMembersService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IOperationContractEmptyMembersService
8 | {
9 | [OperationContract]
10 | string Method(EmptyMembers members);
11 | }
12 |
13 | public class OperationContractEmptyMembersService : IOperationContractEmptyMembersService
14 | {
15 | public string Method(EmptyMembers members)
16 | {
17 | return "OK";
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IOperationContractFieldMembersService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [ServiceContract]
6 | public interface IOperationContractFieldMembersService
7 | {
8 | [OperationContract]
9 | TypeWithFields Method(TypeWithFields argument);
10 | }
11 |
12 | public class OperationContractFieldMembersService : IOperationContractFieldMembersService
13 | {
14 | public TypeWithFields Method(TypeWithFields argument)
15 | {
16 | return new TypeWithFields();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IOperationContractFieldMembersServiceWrapped.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [ServiceContract]
6 | public interface IOperationContractFieldMembersServiceWrapped
7 | {
8 | [OperationContract]
9 | TypeWithFields Method(TypeWithFieldsWrapped argument);
10 | }
11 |
12 | public class OperationContractFieldMembersServiceWrapped : IOperationContractFieldMembersServiceWrapped
13 | {
14 | public TypeWithFields Method(TypeWithFieldsWrapped argument)
15 | {
16 | return new TypeWithFields();
17 | }
18 | }
19 |
20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Required for test")]
21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Tightly coupled")]
22 | [MessageContract(IsWrapped = true)]
23 | public class TypeWithFieldsWrapped
24 | {
25 | [MessageBodyMember]
26 | public TypeWithFields TypeWithFields;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IPortTypeService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [ServiceContract(Namespace = "http://tempuri.org/IPortTypeService")]
6 | public interface IPortTypeService : IPortTypeServiceBase
7 | {
8 | [OperationContract]
9 | void Test();
10 | }
11 |
12 | [ServiceContract(Namespace = "http://tempuri.org/IPortTypeServiceBase")]
13 | public interface IPortTypeServiceBase
14 | {
15 | [OperationContract]
16 | void TestBase();
17 | }
18 |
19 | public abstract class PortTypeServiceBase : IPortTypeServiceBase
20 | {
21 | public void TestBase()
22 | {
23 | throw new System.NotImplementedException();
24 | }
25 |
26 | public class PortTypeService : PortTypeServiceBase, IPortTypeService
27 | {
28 | public void Test()
29 | {
30 | // TODO:
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IServiceKnownTypesService.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceKnownType(typeof(ServiceKnownTypesService.Dog))]
7 | [ServiceContract]
8 | public interface IServiceKnownTypesService
9 | {
10 | [ServiceKnownType(typeof(ServiceKnownTypesService.Cat))]
11 | [OperationContract]
12 | ServiceKnownTypesService.Animal Test(ServiceKnownTypesService.Animal value);
13 | }
14 |
15 | public class ServiceKnownTypesService : IServiceKnownTypesService
16 | {
17 | public Animal Test(Animal value)
18 | {
19 | return value;
20 | }
21 |
22 | [DataContract(Name = "Animal")]
23 | public class Animal
24 | {
25 | }
26 |
27 | [DataContract(Name = "Dog")]
28 | public class Dog : Animal
29 | {
30 | }
31 |
32 | [DataContract(Name = "Cat")]
33 | public class Cat : Animal
34 | {
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IServiceWithFaultContracts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IServiceWithFaultContracts
8 | {
9 | [OperationContract]
10 | [FaultContract(typeof(OperationFault))]
11 | EnumWithCustomNames? GetEnum(string text);
12 |
13 | [OperationContract]
14 | [FaultContract(typeof(FailedOperation))]
15 | ComplexType LoadComplexType(out string message);
16 | }
17 |
18 | public class ServiceWithFaultContracts : IServiceWithFaultContracts
19 | {
20 | public EnumWithCustomNames? GetEnum(string text)
21 | {
22 | throw new NotImplementedException();
23 | }
24 |
25 | public ComplexType LoadComplexType(out string message)
26 | {
27 | throw new NotImplementedException();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IServiceWithSoapHeaders.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Xml;
8 | using System.Xml.Serialization;
9 | using SoapCore.ServiceModel;
10 | #pragma warning disable SA1401 // Fields should be private
11 |
12 | namespace SoapCore.Tests.Wsdl.Services;
13 | [ServiceContract]
14 | public interface IServiceWithSoapHeaders
15 | {
16 | [OperationContract]
17 | [AuthenticationContextSoapHeader]
18 | public void Method();
19 | }
20 |
21 | public class ServiceWithSoapHeaders : IServiceWithSoapHeaders
22 | {
23 | public void Method()
24 | {
25 | }
26 | }
27 |
28 | public sealed class AuthenticationContextSoapHeader : SoapHeaderAttribute
29 | {
30 | [XmlAnyAttribute]
31 | public XmlAttribute[] XAttributes;
32 |
33 | public string OperatorCode { get; set; }
34 | public string Password { get; set; }
35 | }
36 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ISpecifiedBoolService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Xml.Serialization;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services;
5 |
6 | [ServiceContract]
7 | public interface ISpecifiedBoolService
8 | {
9 | [OperationContract]
10 | TypeWithSpecifiedEnum Method(TypeWithSpecifiedEnum argument);
11 | }
12 |
13 | public class SpecifiedBoolService : ISpecifiedBoolService
14 | {
15 | public TypeWithSpecifiedEnum Method(TypeWithSpecifiedEnum argument)
16 | {
17 | return new TypeWithSpecifiedEnum();
18 | }
19 | }
20 |
21 | public class TypeWithSpecifiedEnum
22 | {
23 | [XmlIgnore]
24 | public bool EnumSpecified { get; set; }
25 | public NulEnum Enum { get; set; }
26 | public NulEnum NormalEnum { get; set; }
27 | }
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IStreamService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.ServiceModel;
5 | using System.Text;
6 |
7 | namespace SoapCore.Tests.Wsdl.Services
8 | {
9 | [ServiceContract]
10 | public interface IStreamService
11 | {
12 | [OperationContract]
13 | Stream GetStream();
14 | }
15 |
16 | public class StreamService : IStreamService
17 | {
18 | public Stream GetStream()
19 | {
20 | throw new NotImplementedException();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IStringListService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Text;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | [ServiceContract]
9 | public interface IStringListService
10 | {
11 | [OperationContract]
12 | List Test();
13 |
14 | [OperationContract]
15 | ArrayOfStringModel TestWithModel();
16 | }
17 |
18 | public class StringListService : IStringListService
19 | {
20 | public List Test() => throw new NotImplementedException();
21 | public ArrayOfStringModel TestWithModel() => throw new NotImplementedException();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IStructsService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.ServiceModel;
5 | using System.Text;
6 |
7 | namespace SoapCore.Tests.Wsdl.Services
8 | {
9 | [ServiceContract]
10 | public interface IStructsService
11 | {
12 | [OperationContract]
13 | void Method(StructService.StructModel model);
14 | }
15 |
16 | public class StructService : IStructsService
17 | {
18 | public void Method(StructModel model)
19 | {
20 | throw new NotImplementedException();
21 | }
22 |
23 | [DataContract]
24 | public struct AnyStruct
25 | {
26 | public int Prop { get; set; }
27 | }
28 |
29 | [DataContract]
30 | public class StructModel
31 | {
32 | [DataMember]
33 | public IList MyStructs { get; set; }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ISystemImportService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface ISystemImportService
8 | {
9 | [OperationContract]
10 | ComplexType GetValue();
11 | }
12 |
13 | public class SystemImportService : ISystemImportService
14 | {
15 | public ComplexType GetValue()
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ISystemTypesService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface ISystemTypesService
8 | {
9 | [OperationContract]
10 | void Method(Uri value);
11 | }
12 |
13 | public class SystemTypesService : ISystemTypesService
14 | {
15 | public void Method(Uri value)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ITaskNoReturnService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SoapCore.Tests.Wsdl.Services
8 | {
9 | [ServiceContract]
10 | public interface ITaskNoReturnService
11 | {
12 | [OperationContract]
13 | Task TaskNoResultMethod();
14 | }
15 |
16 | public class TaskNoReturnService : ITaskNoReturnService
17 | {
18 | public Task TaskNoResultMethod()
19 | {
20 | throw new NotImplementedException();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/ITestMultipleTypesService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using System.ServiceModel;
4 | using System.Xml.Linq;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | [ServiceContract]
9 | public interface ITestMultipleTypesService
10 | {
11 | [OperationContract]
12 | DataTable GetDataTable(DataTable input);
13 |
14 | [OperationContract]
15 | System.Xml.Linq.XElement GetXElement(System.Xml.Linq.XElement input);
16 |
17 | [OperationContract]
18 | DateTimeOffset GetDateTimeOffset(DateTimeOffset input);
19 |
20 | [OperationContract]
21 | int GetInt(int input);
22 |
23 | [OperationContract]
24 | byte[] GetBytes(byte[] input);
25 |
26 | [OperationContract]
27 | string GetString(string input);
28 |
29 | [OperationContract]
30 | MyClass GetMyClass(MyClass input);
31 | }
32 |
33 | public class TestMultipleTypesService : ITestMultipleTypesService
34 | {
35 | public DataTable GetDataTable(DataTable input)
36 | {
37 | throw new NotImplementedException();
38 | }
39 |
40 | public DateTimeOffset GetDateTimeOffset(DateTimeOffset input)
41 | {
42 | throw new NotImplementedException();
43 | }
44 |
45 | public int GetInt(int input)
46 | {
47 | throw new NotImplementedException();
48 | }
49 |
50 | public string GetString(string input)
51 | {
52 | throw new NotImplementedException();
53 | }
54 |
55 | public XElement GetXElement(XElement input)
56 | {
57 | throw new NotImplementedException();
58 | }
59 |
60 | public MyClass GetMyClass(MyClass input)
61 | {
62 | return input;
63 | }
64 |
65 | public byte[] GetBytes(byte[] input)
66 | {
67 | throw new NotImplementedException();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IUnqualifiedMembersService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [ServiceContract]
7 | public interface IUnqualifiedMembersService
8 | {
9 | [OperationContract(Action = "http://sampleservice.net/webservices/Method", ReplyAction = "*")]
10 | [XmlSerializerFormat(SupportFaults = true)]
11 | TypeWithUnqualifiedMembers Method(TypeWithUnqualifiedMembers request);
12 | }
13 |
14 | public class UnqualifiedMembersService : IUnqualifiedMembersService
15 | {
16 | public TypeWithUnqualifiedMembers Method(TypeWithUnqualifiedMembers request)
17 | {
18 | throw new NotImplementedException();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IValueTypeService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | [ServiceContract]
8 | public interface IValueTypeService
9 | {
10 | [OperationContract]
11 | void MethodInput(ValueTypeService.AnyStructInput model);
12 |
13 | [OperationContract]
14 | ValueTypeService.AnyStructOutput MethodOutput();
15 | }
16 |
17 | public class ValueTypeService : IValueTypeService
18 | {
19 | public void MethodInput(AnyStructInput model)
20 | {
21 | // TODO:
22 | }
23 |
24 | public AnyStructOutput MethodOutput()
25 | {
26 | return default;
27 | }
28 |
29 | [DataContract]
30 | public struct AnyStructInput
31 | {
32 | [DataMember]
33 | public int Value { get; set; }
34 |
35 | [DataMember]
36 | public OtherStructInput? NullableOther { get; set; }
37 | }
38 |
39 | [DataContract]
40 | public struct OtherStructInput
41 | {
42 | [DataMember]
43 | public DateTime? Test { get; set; }
44 | }
45 |
46 | [DataContract]
47 | public struct AnyStructOutput
48 | {
49 | [DataMember]
50 | public double Value { get; set; }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IXmlArrayAttributeService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Xml.Serialization;
8 |
9 | namespace SoapCore.Tests.Wsdl.Services;
10 |
11 | [ServiceContract]
12 | public interface IXmlArrayAttributeService
13 | {
14 | [OperationContract]
15 | TypeWithXmlArrayAttribute Method(TypeWithXmlArrayAttribute argument);
16 | }
17 |
18 | public class XmlArrayAttributeService : IXmlArrayAttributeService
19 | {
20 | public TypeWithXmlArrayAttribute Method(TypeWithXmlArrayAttribute argument)
21 | {
22 | return new TypeWithXmlArrayAttribute();
23 | }
24 | }
25 |
26 | public class TypeWithXmlArrayAttribute
27 | {
28 | [XmlArray("AvlRoomTypeItems")]
29 | public List AvlRoomTypeList { get; set; }
30 | }
31 |
32 | public class AvlRoomTypeItem
33 | {
34 | public string RoomTypeCode { get; set; }
35 | }
36 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IXmlIncludeService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.Xml.Serialization;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | [ServiceContract]
8 | internal interface IXmlIncludeService
9 | {
10 | [XmlInclude(typeof(XmlIncludeService.Dog))]
11 | [XmlInclude(typeof(XmlIncludeService.Cat))]
12 | [OperationContract]
13 | XmlIncludeService.Animal Test(XmlIncludeService.Animal value);
14 | }
15 |
16 | public class XmlIncludeService : IXmlIncludeService
17 | {
18 | public Animal Test(Animal value)
19 | {
20 | return value;
21 | }
22 |
23 | [Serializable]
24 | [XmlInclude(typeof(Dog))]
25 | [XmlInclude(typeof(Cat))]
26 | public class Animal
27 | {
28 | }
29 |
30 | [Serializable]
31 | public class Dog : Animal
32 | {
33 | }
34 |
35 | [Serializable]
36 | public class Cat : Animal
37 | {
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/IXmlSchemaProviderTypeService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using System.ServiceModel;
4 | using System.Xml.Linq;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | [ServiceContract]
9 | public interface IXmlSchemaProviderTypeService
10 | {
11 | [OperationContract]
12 | DataTable GetDataTable(DataTable input);
13 |
14 | [OperationContract]
15 | XElement GetXElement(XElement input);
16 |
17 | [OperationContract]
18 | Date GetDate(Date input);
19 | }
20 |
21 | public class XmlSchemaProviderTypeService : IXmlSchemaProviderTypeService
22 | {
23 | public DataTable GetDataTable(DataTable input)
24 | {
25 | throw new NotImplementedException();
26 | }
27 |
28 | public XElement GetXElement(XElement input)
29 | {
30 | throw new NotImplementedException();
31 | }
32 |
33 | public Date GetDate(Date input)
34 | {
35 | throw new NotImplementedException();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/MessageAttributesService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | #pragma warning disable SA1649 // File name should match first type name
6 | #pragma warning disable SA1402 // File may only contain a single type
7 | [ServiceContract(Namespace = "http://bagov.net")]
8 | public interface IMessageHeadersService
9 | {
10 | [OperationContract]
11 | MessageHeadersResponseType GetResponse();
12 | }
13 |
14 | public class MessageHeadersService : IMessageHeadersService
15 | {
16 | public MessageHeadersResponseType GetResponse()
17 | {
18 | return new MessageHeadersResponseType();
19 | }
20 | }
21 |
22 | [MessageContract]
23 | public class MessageHeadersResponseType
24 | {
25 | [MessageBodyMember(Name = "ModifiedStringProperty")]
26 | public string StringProperty { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/MyClass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using System.ServiceModel;
4 | using System.Xml.Linq;
5 |
6 | namespace SoapCore.Tests.Wsdl.Services
7 | {
8 | public class MyClass
9 | {
10 | public string StringProperty { get; set; }
11 | public int IntProperty { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/MyClassWithArray.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace SoapCore.Tests.Wsdl.Services
6 | {
7 | public class MyClassWithArray
8 | {
9 | public MyClass[] TestArrayModel { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/NulEnum.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [DataContract]
6 | public enum NulEnum
7 | {
8 | [EnumMember]
9 | A,
10 |
11 | [EnumMember]
12 | B
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/OperationFault.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace SoapCore.Tests.Wsdl.Services
4 | {
5 | [DataContract]
6 | public class OperationFault
7 | {
8 | [DataMember]
9 | public string Code { get; set; }
10 |
11 | [DataMember]
12 | public string Message { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/PaymentResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.Serialization;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [DataContract]
7 | public class PaymentResponse
8 | {
9 | [DataMember]
10 | public string ErrorCode { get; set; }
11 |
12 | [DataMember]
13 | public List ErrorDetailList { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/TypeWithFields.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.Serialization;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "Required for test")]
7 | [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Required for test")]
8 | [DataContract]
9 | public class TypeWithFields
10 | {
11 | [DataMember]
12 | public string StringPropMember { get; set; }
13 |
14 | [DataMember]
15 | public string StringFieldMember;
16 |
17 | [DataMember]
18 | public List StringListFieldMember;
19 |
20 | [DataMember]
21 | public List StringListPropMember { get; set; }
22 |
23 | [DataMember]
24 | public List TypeWithFieldsInnerListFieldMember;
25 |
26 | [DataMember]
27 | public List TypeWithFieldsInnerListPropMember { get; set; }
28 | }
29 |
30 | [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "Required for test")]
31 | [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Required for test")]
32 | [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Tightly coupled")]
33 | [DataContract]
34 | public class TypeWithFieldsInner
35 | {
36 | [DataMember]
37 | public List StringListFieldMember;
38 |
39 | [DataMember]
40 | public List StringListPropMember { get; set; }
41 |
42 | [DataMember]
43 | public string StringPropMember { get; set; }
44 |
45 | [DataMember]
46 | public string StringFieldMember;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/TypeWithNonDataMembers.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.Serialization;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | [DataContract]
7 | public class TypeWithNonDataMembers
8 | {
9 | [DataMember]
10 | public string StringMember { get; set; }
11 |
12 | public string StringNonMemberNonSerializable { get; set; }
13 |
14 | [DataMember]
15 | public List StringListMember { get; set; }
16 |
17 | public List StringListNonMemberNonSerializable { get; set; }
18 |
19 | [DataMember]
20 | public List TypeWithNonDataMembersInnerListMember { get; set; }
21 |
22 | public List TypeWithNonDataMembersInnerListNonMemberNonSerializable { get; set; }
23 | }
24 |
25 | [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Tightly coupled")]
26 | [DataContract]
27 | public class TypeWithNonDataMembersInner
28 | {
29 | [DataMember]
30 | public int IntMemberInner { get; set; }
31 |
32 | public int IntNonMemberInnerNonSerializable { get; set; }
33 |
34 | [DataMember]
35 | public List IntListMemberInner { get; set; }
36 |
37 | public List IntListNonMemberInnerNonSerializable { get; set; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Services/XmlAnnotatedChoiceReturnService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Xml.Serialization;
3 |
4 | namespace SoapCore.Tests.Wsdl.Services
5 | {
6 | #pragma warning disable SA1649 // File name should match first type name
7 | #pragma warning disable SA1402 // File may only contain a single type
8 | [ServiceContract(Namespace = "http://bagov.net/")]
9 | public interface IXmlAnnotatedChoiceReturnService
10 | {
11 | [OperationContract]
12 | [return: XmlElement("resultResp", typeof(ResultResponse))]
13 | [return: XmlElement("integerNumber", typeof(int))]
14 | object GetResponse(bool boolean);
15 | }
16 |
17 | public class ResultResponse
18 | {
19 | public bool Result { get; set; }
20 | public string StringResult { get; set; }
21 |
22 | [XmlElement("first", typeof(int))]
23 | [XmlElement("second", typeof(string))]
24 | public object[] MultipleResponse { get; set; }
25 | }
26 |
27 | public class XmlAnnotatedChoiceReturnService : IXmlAnnotatedChoiceReturnService
28 | {
29 | public object GetResponse(bool boolean)
30 | {
31 | if (boolean)
32 | {
33 | return 5;
34 | }
35 |
36 | return new ResultResponse() { Result = true, StringResult = "test1" };
37 | }
38 | }
39 | }
40 |
41 | #pragma warning restore SA1649 // File name should match first type name
42 | #pragma warning restore SA1402 // File may only contain a single type
43 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/Wsdl/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.ServiceModel.Channels;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.Extensions.DependencyInjection;
8 | using Microsoft.Extensions.DependencyInjection.Extensions;
9 | using Microsoft.Extensions.Logging;
10 | using SoapCore.Tests.Model;
11 |
12 | namespace SoapCore.Tests.Wsdl
13 | {
14 | public class Startup
15 | {
16 | private readonly Type _serviceType;
17 |
18 | private readonly string _schemeOverride;
19 |
20 | public Startup(IStartupConfiguration configuration)
21 | {
22 | _serviceType = configuration.ServiceType;
23 | _schemeOverride = configuration.SchemeOverride;
24 | }
25 |
26 | public void ConfigureServices(IServiceCollection services)
27 | {
28 | services.AddSoapCore();
29 | services.TryAddSingleton(_serviceType);
30 | services.AddMvc();
31 | }
32 |
33 | #if !NETCOREAPP3_0_OR_GREATER
34 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
35 | {
36 | app.UseSoapEndpoint(_serviceType, "/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer, schemeOverride: _schemeOverride);
37 | app.UseSoapEndpoint(_serviceType, "/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer, schemeOverride: _schemeOverride);
38 |
39 | app.UseMvc();
40 | }
41 | #else
42 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
43 | {
44 | app.UseRouting();
45 |
46 | app.UseEndpoints(x =>
47 | {
48 | x.UseSoapEndpoint(_serviceType, "/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer, schemeOverride: _schemeOverride);
49 | x.UseSoapEndpoint(_serviceType, "/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer, schemeOverride: _schemeOverride);
50 | });
51 | }
52 | #endif
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/IStartupConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace SoapCore.Tests.WsdlFromFile
6 | {
7 | public interface IStartupConfiguration
8 | {
9 | string ServiceName { get; }
10 |
11 | Type ServiceType { get; }
12 |
13 | string TestFileFolder { get; }
14 |
15 | string WsdlFile { get; }
16 | }
17 |
18 | public class StartupConfiguration : IStartupConfiguration
19 | {
20 | public StartupConfiguration(string serviceName, Type serviceType, string testFileFolder, string wsdlFile)
21 | {
22 | ServiceName = serviceName;
23 | ServiceType = serviceType;
24 | TestFileFolder = testFileFolder;
25 | WsdlFile = wsdlFile;
26 | }
27 |
28 | public string ServiceName { get; }
29 |
30 | public Type ServiceType { get; }
31 |
32 | public string TestFileFolder { get; }
33 |
34 | public string WsdlFile { get; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/Services/EchoIncludeService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 |
4 | namespace SoapCore.Tests.WsdlFromFile.Services
5 | {
6 | public class EchoIncludeService : IncludePortType
7 | {
8 | public EchoIncludeService()
9 | {
10 | }
11 |
12 | public echoIncludeResponse echoInclude(echoIncludeRequest request)
13 | {
14 | var response = new echoIncludeResponse();
15 |
16 | try
17 | {
18 | //todo
19 | }
20 | catch (System.Exception)
21 | {
22 | throw;
23 | }
24 |
25 | return response;
26 | }
27 |
28 | public Task echoIncludeAsync(echoIncludeRequest request)
29 | {
30 | throw new NotImplementedException();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/Services/MeasurementSiteTablePublicationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 |
4 | namespace SoapCore.Tests.WsdlFromFile.Services
5 | {
6 | ///
7 | /// Pull service for snapshopPull interface(MeasurementSiteTablePublicationService)
8 | ///
9 | public class MeasurementSiteTablePublicationService : snapshotPullInterface
10 | {
11 | public MeasurementSiteTablePublicationService()
12 | {
13 | }
14 |
15 | public pullSnapshotDataResponse pullSnapshotData(pullSnapshotDataRequest request)
16 | {
17 | var response = new pullSnapshotDataResponse();
18 | try
19 | {
20 | //todo
21 | }
22 | catch (System.Exception)
23 | {
24 | throw;
25 | }
26 |
27 | return response;
28 | }
29 |
30 | public Task pullSnapshotDataAsync(pullSnapshotDataRequest request)
31 | {
32 | throw new NotImplementedException();
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/WSDL/DATEXII_3_D2Payload.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/WSDL/DATEXII_3_MessageContainer.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | a Container class to manage further information classes as Payload, Information Management, CIS Information and Exchange Information
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/WSDL/DATEXII_3_RoadTrafficData.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | A measured or calculated value of an instant in time.
8 |
9 |
10 |
11 |
12 |
13 |
14 | A time stamp defining an instant in time.
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/WSDL/echoInclude.xsd:
--------------------------------------------------------------------------------
1 |
2 |
12 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/WSDL/echoIncluded.xsd:
--------------------------------------------------------------------------------
1 |
12 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/WSDLInclude/echoWsdlInclude.wsdl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/WSDLInclude/xsd00.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/WsdlFromFile/WSDLInclude/xsd02.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/XmlNodeInputOutput/IXmlNodeInputOutput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceModel;
4 | using System.Text;
5 | using System.Xml;
6 |
7 | namespace SoapCore.Tests.XmlNodeInputOutput
8 | {
9 | [ServiceContract]
10 | public interface IXmlNodeInputOutput
11 | {
12 | [OperationContract]
13 | XmlElement ProcessRequest(string login, string password, XmlElement requestXml);
14 |
15 | [OperationContract]
16 | XmlElement GetRequest();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/XmlNodeInputOutput/Startup.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.ServiceModel.Channels;
3 | using System.Text;
4 | using System.Threading.Tasks;
5 | using System.Xml;
6 | using Microsoft.AspNetCore.Builder;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.DependencyInjection.Extensions;
10 | using Microsoft.Extensions.Logging;
11 |
12 | namespace SoapCore.Tests.XmlNodeInputOutput
13 | {
14 | public class Startup
15 | {
16 | public void ConfigureServices(IServiceCollection services)
17 | {
18 | services.AddSoapCore();
19 | services.TryAddSingleton();
20 | services.AddMvc();
21 | }
22 |
23 | public void Configure(IApplicationBuilder app)
24 | {
25 | app.UseRouting();
26 |
27 | app.UseEndpoints(x =>
28 | {
29 | x.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
30 | x.UseSoapEndpoint("/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
31 | });
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/XmlNodeInputOutput/XmlNodeInputOutput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Xml;
5 |
6 | namespace SoapCore.Tests.XmlNodeInputOutput
7 | {
8 | public class XmlNodeInputOutput : IXmlNodeInputOutput
9 | {
10 | public XmlNodeInputOutput()
11 | {
12 | }
13 |
14 | public XmlElement ProcessRequest(string login, string password, XmlElement requestXml)
15 | {
16 | if (password == "Password")
17 | {
18 | return requestXml;
19 | }
20 | else
21 | {
22 | XmlDocument xdError = new XmlDocument();
23 | xdError.LoadXml("Incorrect Password");
24 | return xdError.DocumentElement;
25 | }
26 | }
27 |
28 | public XmlElement GetRequest()
29 | {
30 | XmlDocument xdResponse = new XmlDocument();
31 | xdResponse.LoadXml("A response");
32 | return xdResponse.DocumentElement;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/SoapCore.Tests/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "indentation": {
5 | "useTabs": true
6 | },
7 | "spacingRules": {
8 | },
9 | "orderingRules": { "usingDirectivesPlacement": "outsideNamespace" }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/SoapCore/CachedDataContractSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Collections.Generic;
4 | using System.Runtime.Serialization;
5 | using System.Xml.Serialization;
6 |
7 | namespace SoapCore
8 | {
9 |
10 | public static class CachedDataContractSerializer
11 | {
12 | private static readonly ConcurrentDictionary CachedSerializers = new ConcurrentDictionary();
13 |
14 | public static DataContractSerializer GetDataContractSerializer(Type elementType, string parameterName, string parameterNs, IEnumerable knownTypes = null)
15 | {
16 | var key = $"{elementType}|{parameterName}|{parameterNs}";
17 |
18 | if (knownTypes != null)
19 | {
20 | return CachedSerializers.GetOrAdd(key, _ => new DataContractSerializer(elementType, parameterName, parameterNs, knownTypes));
21 | }
22 | else
23 | {
24 | return CachedSerializers.GetOrAdd(key, _ => new DataContractSerializer(elementType, parameterName, parameterNs));
25 | }
26 | }
27 |
28 | public static DataContractSerializer GetDataContractSerializer(Type elementType, IEnumerable knownTypes = null)
29 | {
30 | var key = $"{elementType}|_|_";
31 |
32 | if (knownTypes != null)
33 | {
34 | return CachedSerializers.GetOrAdd(key, _ => new DataContractSerializer(elementType, knownTypes));
35 | }
36 | else
37 | {
38 | return CachedSerializers.GetOrAdd(key, _ => new DataContractSerializer(elementType));
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/SoapCore/CachedXmlSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Collections.Generic;
4 | using System.Runtime.Serialization;
5 | using System.Xml.Serialization;
6 |
7 | namespace SoapCore
8 | {
9 | public static class CachedXmlSerializer
10 | {
11 | private static readonly ConcurrentDictionary CachedSerializers = new ConcurrentDictionary();
12 |
13 | public static XmlSerializer GetXmlSerializer(Type elementType, string parameterName, string parameterNs)
14 | {
15 | var key = $"{elementType}|{parameterName}|{parameterNs}";
16 | return CachedSerializers.GetOrAdd(key, _ => new XmlSerializer(elementType, null, Array.Empty(), new XmlRootAttribute(parameterName), parameterNs));
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/SoapCore/DefaultEncodings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace SoapCore
6 | {
7 | internal class DefaultEncodings
8 | {
9 | public static Encoding UTF8 => new UTF8Encoding(false);
10 | public static Encoding Unicode => new UnicodeEncoding(false, false);
11 | public static Encoding BigEndianUnicode => new UnicodeEncoding(true, false);
12 | public static Encoding Iso88591 => Encoding.GetEncoding("ISO8859-1");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/SoapCore/DefaultFaultExceptionTransformer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel.Channels;
3 | using System.Xml;
4 | using SoapCore.Extensibility;
5 |
6 | namespace SoapCore
7 | {
8 | ///
9 | /// The default implementation of the fault provider when an unexpected exception occurs. This can be replaced or
10 | /// extended by registering your own IFaultExceptionTransformer in the service collection on startup.
11 | ///
12 | /// The message type.
13 | public class DefaultFaultExceptionTransformer : IFaultExceptionTransformer
14 | where T_MESSAGE : CustomMessage, new()
15 | {
16 | private readonly ExceptionTransformer _exceptionTransformer;
17 |
18 | public DefaultFaultExceptionTransformer()
19 | {
20 | _exceptionTransformer = null;
21 | }
22 |
23 | public DefaultFaultExceptionTransformer(ExceptionTransformer exceptionTransformer)
24 | {
25 | _exceptionTransformer = exceptionTransformer;
26 | }
27 |
28 | public Message ProvideFault(Exception exception, MessageVersion messageVersion, Message requestMessage, XmlNamespaceManager xmlNamespaceManager)
29 | {
30 | var bodyWriter = _exceptionTransformer == null ?
31 | new FaultBodyWriter(exception, messageVersion) :
32 | new FaultBodyWriter(exception, messageVersion, faultStringOverride: _exceptionTransformer.Transform(exception));
33 |
34 | var soapCoreFaultMessage = Message.CreateMessage(messageVersion, null, bodyWriter);
35 |
36 | T_MESSAGE customMessage = new T_MESSAGE
37 | {
38 | Message = soapCoreFaultMessage,
39 | NamespaceManager = xmlNamespaceManager
40 | };
41 |
42 | return customMessage;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/SoapCore/DefaultOperationInvoker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using SoapCore.Extensibility;
8 |
9 | namespace SoapCore
10 | {
11 | public class DefaultOperationInvoker : IOperationInvoker
12 | {
13 | public async Task