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

Complex Object [Array] With Virtual Stream Propery Return Empty Array in Soap Method #968

Closed
ankitkmrpatel opened this issue Oct 8, 2023 · 7 comments
Labels

Comments

@ankitkmrpatel
Copy link
Contributor

ankitkmrpatel commented Oct 8, 2023

Hi, I am migrating Soap Endpoint into Core Project from our OLD .Net Framework. We a trying to create the following service which expects to receive an envelope body as an argument. The envelope body has Array of Complex Object with property implemented using Virtual Stream.

The problem that Message Property always comes Empty Array in the service method.

Image: Send Method Argument Using Envelope Body - Messages Has Empty Array
image

Service Contract:

[ServiceContract(Name = "complexObjWithStreamService", Namespace = "http://myurl.com/myProd/2010/06")]
[MaxFaultSize(5242880)]
public interface IComplexObjWithStreamService
{
    [OperationContract]
    [SendStreamOperationFormat]
    [FaultContract(typeof(ApplicationFault), Action = "http://myurl.com/myProd/2010/06/FaultAction")]
    void SendStream(StreamRequest request);
}


[MessageContract]
public class StreamRequest 
{
    [MessageHeader]
    public Guid SendStreamRequestTrackingID { get; set; }

    [MessageBodyMember]
    public Message[] Messages { get; set; }

    public StreamRequest ()
    {
    }
}

[KnownType(typeof(VirtualStream))]
[KnownType(typeof(FileStream))]
[KnownType(typeof(UnmanagedMemoryStream))]
[DataContract]
public class Message: IDisposable
{
    [DataMember]
    public Guid MessageID { get; set; }

    [DataMember]
    public Stream MessageStream { get; set; }

    public void Dispose()
    {
        MessageStream.Dispose();
        MessageStream = null;
    }
}

Service Implementation

builder.Services.TryAddSingleton<IComplexObjWithStreamService, ComplexObjWithStreamService>();

---
app.UseEndpoints(endpoints => {
    endpoints.UseSoapEndpoint<IComplexObjWithStreamService>(soapCoreOptions =>
    {
        var soapEncoderOptions = new SoapEncoderOptions
        {
            BindingName = "basicHttpBinding",
            WriteEncoding = System.Text.Encoding.UTF8,
            ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max,
            MessageVersion = MessageVersion.Soap11WSAddressingAugust2004,
        };

        soapCoreOptions.Path = "/StreamService";
        soapCoreOptions.EncoderOptions = new[] { soapEncoderOptions };
        soapCoreOptions.SoapSerializer = SoapSerializer.XmlSerializer;
        soapCoreOptions.AdditionalEnvelopeXmlnsAttributes = new Dictionary<string, string>()
        {
            { "h", "http://myurl.com/myProd/2010/06" },
        };
    });

});
ankitkmrpatel added a commit to ankitkmrpatel/SoapCore that referenced this issue Oct 19, 2023
@andersjonsson
Copy link
Collaborator

That's odd. As far as I can tell everything you're trying to do should work.
I'd recommend setting up a small test case where you can debug through the deserialization code and see where it goes wrong.

I assume that your PR is intended to fix this issue? If there's no reason for this to be a custom serializer I'd rather see that the issue was fixed in the default serializer. Adding support for custom serializers is cool though, and could be useful in other cases

@ankitkmrpatel
Copy link
Contributor Author

Hi @andersjonsson,

All commits have been added to the repository, and the documentation has been updated accordingly. Please feel free to check it out at your convenience.

@ankitkmrpatel
Copy link
Contributor Author

Hi @andersjonsson Any News for New Release for PR? The PR is still pending.

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Dec 28, 2023
@ankitkmrpatel
Copy link
Contributor Author

Fixed the Conflicts after the update.

@github-actions github-actions bot removed the stale label Jan 6, 2024
Copy link

github-actions bot commented Feb 5, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Feb 5, 2024
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants