-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To support soap encoded message. (#1885)
* To support soap encoded message. Exposed XmlSerializerOperationBehavior.GetXmlMappings. Fix #1549. Fix #1797. * Fixed Issue with BasicHttpSoapTestServiceHostFactory. * Add one more test for Soap. * Refactor the tests. * Change to use IssueAttribute.
- Loading branch information
Showing
13 changed files
with
524 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
301 changes: 216 additions & 85 deletions
301
...rivate.ServiceModel/src/System/ServiceModel/Description/XmlSerializerOperationBehavior.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...rivate.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatSoapTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.ServiceModel; | ||
using System.ServiceModel.Channels; | ||
using System.Threading.Tasks; | ||
using Infrastructure.Common; | ||
using Xunit; | ||
using System; | ||
|
||
public static partial class XmlSerializerFormatTests | ||
{ | ||
[WcfFact] | ||
[OuterLoop] | ||
public static void CombineString_XmlSerializerFormat_Soap() | ||
{ | ||
RunWcfSoapServiceTest((serviceProxy) => | ||
{ | ||
// *** EXECUTE *** \\ | ||
string message1 = "hello"; | ||
string message2 = "world"; | ||
var response = serviceProxy.CombineStringXmlSerializerFormatSoap(message1, message2); | ||
|
||
// *** VALIDATE *** \\ | ||
Assert.Equal(message1 + message2, response); | ||
}); | ||
} | ||
|
||
[WcfFact] | ||
[OuterLoop] | ||
[Issue(1884)] | ||
public static void EchoComositeType_XmlSerializerFormat_Soap() | ||
{ | ||
RunWcfSoapServiceTest((serviceProxy) => | ||
{ | ||
// *** EXECUTE *** \\ | ||
var value = new SoapComplexType() { BoolValue = true, StringValue = "hello" }; | ||
SoapComplexType response = serviceProxy.EchoComositeTypeXmlSerializerFormatSoap(value); | ||
|
||
// *** VALIDATE *** \\ | ||
Assert.NotNull(response); | ||
Assert.Equal(value.BoolValue, response.BoolValue); | ||
Assert.Equal(value.StringValue, response.StringValue); | ||
}); | ||
} | ||
|
||
[WcfFact] | ||
[OuterLoop] | ||
public static void ProcessCustomerData_XmlSerializerFormat_Soap() | ||
{ | ||
RunWcfSoapServiceTest((serviceProxy) => | ||
{ | ||
// *** EXECUTE *** \\ | ||
CustomerObject value = new CustomerObject() { Name = "MyName", Data = new AdditionalData() { Field = "Foo" } }; | ||
string response = serviceProxy.ProcessCustomerData(value); | ||
|
||
// *** VALIDATE *** \\ | ||
Assert.Equal("MyNameFoo", response); | ||
}); | ||
} | ||
|
||
private static void RunWcfSoapServiceTest(Action<IWcfSoapService> testMethod) | ||
{ | ||
BasicHttpBinding binding; | ||
EndpointAddress endpointAddress; | ||
ChannelFactory<IWcfSoapService> factory; | ||
IWcfSoapService serviceProxy = null; | ||
|
||
try | ||
{ | ||
// *** SETUP *** \\ | ||
binding = new BasicHttpBinding(); | ||
endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Soap); | ||
factory = new ChannelFactory<IWcfSoapService>(binding, endpointAddress); | ||
serviceProxy = factory.CreateChannel(); | ||
testMethod(serviceProxy); | ||
|
||
// *** CLEANUP *** \\ | ||
factory.Close(); | ||
((ICommunicationObject)serviceProxy).Close(); | ||
} | ||
finally | ||
{ | ||
// *** ENSURE CLEANUP *** \\ | ||
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/IWcfSoapService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
|
||
using System; | ||
using System.ServiceModel; | ||
using System.Threading.Tasks; | ||
|
||
namespace WcfService | ||
{ | ||
[ServiceContract] | ||
[XmlSerializerFormat(Use = OperationFormatUse.Encoded)] | ||
public interface IWcfSoapService | ||
{ | ||
[OperationContract(Action = "http://tempuri.org/IWcfService/CombineStringXmlSerializerFormatSoap")] | ||
[XmlSerializerFormat(Use = OperationFormatUse.Encoded)] | ||
string CombineStringXmlSerializerFormatSoap(string message1, string message2); | ||
|
||
[OperationContract(Action = "http://tempuri.org/IWcfService/EchoComositeTypeXmlSerializerFormatSoap")] | ||
[XmlSerializerFormat(Use = OperationFormatUse.Encoded)] | ||
SoapComplexType EchoComositeTypeXmlSerializerFormatSoap(SoapComplexType c); | ||
|
||
[OperationContract(Action = "http://tempuri.org/IWcfService/ProcessCustomerData")] | ||
[XmlSerializerFormat(Style = OperationFormatStyle.Rpc, SupportFaults = true, Use = OperationFormatUse.Encoded)] | ||
[ServiceKnownType(typeof(AdditionalData))] | ||
[return: MessageParameter(Name = "ProcessCustomerDataReturn")] | ||
[return: System.Xml.Serialization.SoapElement(DataType = "string")] | ||
string ProcessCustomerData([MessageParameter(Name = "CustomerData")]CustomerObject customerData); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/WcfSoapService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Channels; | ||
using System.ServiceModel.Web; | ||
using System.Text; | ||
using System.Xml.Serialization; | ||
|
||
namespace WcfService | ||
{ | ||
public class WcfSoapService : IWcfSoapService | ||
{ | ||
public string CombineStringXmlSerializerFormatSoap(string message1, string message2) | ||
{ | ||
return message1 + message2; | ||
} | ||
|
||
public SoapComplexType EchoComositeTypeXmlSerializerFormatSoap(SoapComplexType complexObject) | ||
{ | ||
return complexObject; | ||
} | ||
|
||
[return: MessageParameter(Name = "ProcessCustomerDataReturn"), SoapElement(DataType = "string")] | ||
public string ProcessCustomerData([MessageParameter(Name = "CustomerData")] CustomerObject customerData) | ||
{ | ||
return customerData.Name + ((AdditionalData)customerData.Data).Field; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpSoapTestServiceHost.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.ServiceModel; | ||
using System.ServiceModel.Activation; | ||
using System.ServiceModel.Channels; | ||
|
||
namespace WcfService | ||
{ | ||
public class BasicHttpSoapTestServiceHostFactory : ServiceHostFactory | ||
{ | ||
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) | ||
{ | ||
var serviceHost = new BasicHttpSoapTestServiceHost(serviceType, baseAddresses); | ||
return serviceHost; | ||
} | ||
} | ||
|
||
public class BasicHttpSoapTestServiceHost : TestServiceHostBase<IWcfSoapService> | ||
{ | ||
protected override string Address { get { return "Basic"; } } | ||
|
||
protected override Binding GetBinding() | ||
{ | ||
return new BasicHttpBinding(); | ||
} | ||
|
||
public BasicHttpSoapTestServiceHost(Type serviceType, params Uri[] baseAddresses) | ||
: base(serviceType, baseAddresses) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters