forked from dotnet/wcf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support MessageHeaderArrayAttribute and MessagePropertyAttribute
Adds these types to public API. Adds implementation code to support them. Adds tests for them. Fixes dotnet#1410
- Loading branch information
Showing
16 changed files
with
925 additions
and
7 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
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
85 changes: 85 additions & 0 deletions
85
...ystem.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageContractTests.4.4.0.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,85 @@ | ||
// 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 Infrastructure.Common; | ||
using WcfService; | ||
using Xunit; | ||
|
||
public static class MessageContractTests_4_4_0 | ||
{ | ||
[WcfFact] | ||
[OuterLoop] | ||
public static void Message_With_MessageHeaders_RoundTrips() | ||
{ | ||
BasicHttpBinding binding = null; | ||
IWcfService_4_4_0 clientProxy = null; | ||
RequestBankingData_4_4_0 requestData = null; | ||
ChannelFactory<IWcfService_4_4_0> factory = null; | ||
|
||
// *** SETUP *** \\ | ||
try | ||
{ | ||
binding = new BasicHttpBinding(); | ||
factory = new ChannelFactory<IWcfService_4_4_0>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_4_4_0_Basic)); | ||
clientProxy = factory.CreateChannel(); | ||
|
||
requestData = new RequestBankingData_4_4_0(); | ||
requestData.accountName = "Michael Jordan"; | ||
requestData.transactionDate = DateTime.Now; | ||
requestData.amount = 100.0M; | ||
|
||
// post-1.1.0 features | ||
requestData.requestSingleValue = "test single value"; | ||
requestData.requestMultipleValues = "test,multiple,value".Split(','); | ||
requestData.requestArrayMultipleValues = "test,array,multiple,value".Split(','); | ||
|
||
// *** EXECUTE *** \\ | ||
ReplyBankingData_4_4_0 replyData = clientProxy.MessageContractRequestReply(requestData); | ||
|
||
// *** VALIDATE *** \\ | ||
Assert.True(String.Equals(requestData.accountName, replyData.accountName), | ||
String.Format("Expected Customer = '{0}', actual = '{1}'", | ||
requestData.accountName, replyData.accountName)); | ||
|
||
Assert.True(requestData.amount == replyData.amount, | ||
String.Format("Expected Amount = '{0}', actual = '{1}'", | ||
requestData.amount, requestData.amount)); | ||
|
||
Assert.True(String.Equals(requestData.requestSingleValue, replyData.replySingleValue), | ||
String.Format("Expected RequestSingleValue = '{0}', actual = '{1}", | ||
requestData.requestSingleValue, replyData.replySingleValue)); | ||
|
||
ValidateArray("MultipleValue", requestData.requestMultipleValues, replyData.replyMultipleValues); | ||
ValidateArray("ArrayMultipleValue", requestData.requestArrayMultipleValues, replyData.replyArrayMultipleValues); | ||
|
||
// *** CLEANUP *** \\ | ||
factory.Close(); | ||
((ICommunicationObject)clientProxy).Close(); | ||
} | ||
finally | ||
{ | ||
// *** ENSURE CLEANUP *** \\ | ||
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)clientProxy, factory); | ||
} | ||
} | ||
|
||
private static void ValidateArray(string elementName, string[] array1, string[] array2) | ||
{ | ||
Assert.True(array2 != null, | ||
String.Format("The {0} element returned a null array", elementName)); | ||
|
||
Assert.True(array1.Length == array2.Length, | ||
String.Format("The {0} element was expected to return {1} items, actual = {2}", | ||
elementName, array1.Length, array2.Length)); | ||
|
||
for (int i = 0; i < array1.Length; ++i) | ||
{ | ||
Assert.True(array1[i] == array2[i], | ||
String.Format("Array item {0} of element {1} was expected to be {2}, actual was {3}", | ||
i, elementName, array1[i], array2[i])); | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/TestTypes.4.4.0.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,86 @@ | ||
// 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.Channels; | ||
using System.ServiceModel.Description; | ||
using System.ServiceModel.Dispatcher; | ||
using System.Xml; | ||
|
||
namespace WcfService | ||
{ | ||
// These classes exist for features added post-1.1.0 | ||
[ServiceContract] | ||
public interface IWcfService_4_4_0 | ||
{ | ||
[OperationContract(Action = "http://tempuri.org/IWcfService_4_4_0/MessageContractRequestReply", | ||
ReplyAction = "http://tempuri.org/IWcfService_4_4_0/MessageContractRequestReplyResponse")] | ||
ReplyBankingData_4_4_0 MessageContractRequestReply(RequestBankingData_4_4_0 bt); | ||
} | ||
|
||
[MessageContract(IsWrapped = true, | ||
WrapperName = "CustomWrapperName", | ||
WrapperNamespace = "http://www.contoso.com")] | ||
public class RequestBankingData_4_4_0 | ||
{ | ||
[MessageBodyMember(Order = 1, | ||
Name = "Date_of_Request")] | ||
public DateTime transactionDate; | ||
|
||
[MessageBodyMember(Name = "Customer_Name", | ||
Namespace = "http://www.contoso.com", | ||
Order = 3)] | ||
public string accountName; | ||
|
||
[MessageBodyMember(Order = 2, | ||
Name = "Transaction_Amount")] | ||
public decimal amount; | ||
|
||
// The following rely on features added post-1.1.0 | ||
[MessageProperty(Name = "TestProperty")] | ||
public string requestProperty; | ||
|
||
[MessageHeader(Name = "SingleElement")] | ||
public string requestSingleValue; | ||
|
||
[MessageHeader(Name = "MultipleElement")] | ||
public string[] requestMultipleValues; | ||
|
||
[MessageHeaderArray(Name = "ArrayMultipleElement")] | ||
public string[] requestArrayMultipleValues; | ||
} | ||
|
||
[MessageContract(IsWrapped = true, | ||
WrapperName = "CustomWrapperName", | ||
WrapperNamespace = "http://www.contoso.com")] | ||
public class ReplyBankingData_4_4_0 | ||
{ | ||
[MessageBodyMember(Order = 1, Name = "Date_of_Request")] | ||
public DateTime transactionDate; | ||
|
||
[MessageBodyMember(Name = "Customer_Name", | ||
Namespace = "http://www.contoso.com", | ||
Order = 3)] | ||
public string accountName; | ||
|
||
[MessageBodyMember(Order = 2, | ||
Name = "Transaction_Amount")] | ||
public decimal amount; | ||
|
||
// The following rely on features added post-1.1.0 | ||
[MessageProperty(Name = "TestProperty")] | ||
public string replyProperty; | ||
|
||
[MessageHeader(Name = "SingleElement")] | ||
public string replySingleValue; | ||
|
||
[MessageHeader(Name = "MultipleElement")] | ||
public string[] replyMultipleValues; | ||
|
||
[MessageHeaderArray(Name = "ArrayMultipleElement")] | ||
public string[] replyArrayMultipleValues; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/IWcfService.4.4.0.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,21 @@ | ||
// 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.ServiceModel; | ||
using System.ServiceModel.Channels; | ||
|
||
namespace WcfService | ||
{ | ||
// This contract relies on features added post-1.1.0 | ||
[ServiceContract] | ||
public interface IWcfService_4_4_0 | ||
{ | ||
[OperationContract(Action = "http://tempuri.org/IWcfService_4_4_0/MessageContractRequestReply")] | ||
ReplyBankingData_4_4_0 MessageContractRequestReply(RequestBankingData_4_4_0 bt); | ||
} | ||
} |
Oops, something went wrong.