Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for array of arrays parameters in methods and a test #965

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.ServiceModel;
using System.Text;

namespace SoapCore.Tests.MessageContract.Models
{
[ServiceContract(Namespace = "http://tempuri.org")]
public interface IArrayOfArrayOfByteService
{
[OperationContract]
string ArrayOfArrayOfByteMethod(byte[][] arrayOfArrayOfByteParam);
}

public class ArrayOfArrayOfByteService : IArrayOfArrayOfByteService
{
public string ArrayOfArrayOfByteMethod(byte[][] arrayOfArrayOfByteParam)
{
var ret = new StringBuilder();
ret.Append("[");
foreach (var array in arrayOfArrayOfByteParam)
{
ret.Append("[");
ret.Append(string.Join(",", array));
ret.Append("]");
}

ret.Append("]");
return ret.ToString();
}
}
}
23 changes: 23 additions & 0 deletions src/SoapCore.Tests/MessageContract/RawRequestSoap11Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ public async Task Soap11MessageContractArrayOfIntParamWrapped()
}
}

[TestMethod]
public async Task SoapArrayOfArrayOfByte()
{
const string body = @"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org"">
<soapenv:Header/>
<soapenv:Body>
<tem:ArrayOfArrayOfByteMethod>
<tem:arrayOfArrayOfByteParam><tem:base64Binary>AQI=</tem:base64Binary><tem:base64Binary>AgM=</tem:base64Binary><tem:base64Binary>BAU=</tem:base64Binary><tem:base64Binary>BgU=</tem:base64Binary></tem:arrayOfArrayOfByteParam>
</tem:ArrayOfArrayOfByteMethod>
</soapenv:Body>
</soapenv:Envelope>";

using (var host = CreateTestHost(typeof(ArrayOfArrayOfByteService)))
using (var client = host.CreateClient())
using (var content = new StringContent(body, Encoding.UTF8, "text/xml"))
using (var res = await host.CreateRequest("/Service.asmx").AddHeader("SOAPAction", @"""ArrayOfArrayOfByteMethod""").And(msg => msg.Content = content).PostAsync())
{
res.EnsureSuccessStatusCode();
var resultMessage = await res.Content.ReadAsStringAsync();
Assert.IsTrue(resultMessage.Contains("<ArrayOfArrayOfByteMethodResult>[[1,2][2,3][4,5][6,5]]</ArrayOfArrayOfByteMethodResult>"));
}
}

[TestMethod]
public async Task Soap11MessageContractComplexNotWrapped()
{
Expand Down
2 changes: 1 addition & 1 deletion src/SoapCore/SerializerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public object DeserializeInputParameter(
switch (_serializer)
{
case SoapSerializer.XmlSerializer:
if (!parameterType.IsArray)
if (!parameterType.IsArray || parameterType.GetElementType()?.IsArray == true)
{
// case [XmlElement("parameter")] int parameter
// case [XmlArray("parameter")] int[] parameter
Expand Down