Question

Client connects, sends Put:

var client = new JsvServiceClient(ConfigGlobal.Host);
client.Put(new PiecParametrySzczegoloweRequest { Initialize = true, Config = _config });

Server receives call and don't see Initialize variable value is set to true:

internal class PiecParametrySzczegoloweService : Service
{
    public PiecParametrySzczegoloweResponse Put(PiecParametrySzczegoloweRequest request)
    {
        if (request.Initialize)
        {
            ImageFile.Initialize(request.Config);

            request.Initialize = false;

            return new PiecParametrySzczegoloweResponse { Initialized = true };
        }

        return null;
    }
}

Request looks like:

[DataContract]
[Route("/PiecParametrySzczegolowe")]
public class PiecParametrySzczegoloweRequest : IReturn<PiecParametrySzczegoloweResponse>
{
    public bool Initialize { get; set; }

    public PiecParametrySzczegoloweLegend Config { get; set; }

    public int Percent { get; set; }
}

Edit:

It was lack of attribute, thanks! And (problems resolved in meantime)...

If you need /requestlogs and you don't have auth use:

Plugins.Add(new RequestLogsFeature() { RequiredRoles = new string[0] });

If you need serialize binary data (Bitmap) use protobuf-net (var client = new ProtoBufServiceClient(ConfigGlobal.Host);) and do something like this Serialize a Bitmap in C#/.NET to XML

If you don't want (need) to annotate every field member (read warnings) Protobuf-net serialization without annotation

Était-ce utile?

La solution

You need to remove the [DataContract] attribute because this attribute tells the serializer that you will specify the fields to include for serialization using the [DataMember] attribute, but you haven't done so.

Or alternatively mark your properties with [DataMember].

[DataContract]
[Route("/PiecParametrySzczegolowe")]
public class PiecParametrySzczegoloweRequest : IReturn<PiecParametrySzczegoloweResponse>
{
    [DataMember]
    public bool Initialize { get; set; }

    [DataMember]
    public PiecParametrySzczegoloweLegend Config { get; set; }

    [DataMember]
    public int Percent { get; set; }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top