1

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

Community
  • 1
  • 1
Tomasito
  • 1,864
  • 1
  • 20
  • 43
  • What version of ServiceStack are you using? I recreated your service and cannot reproduce the error. The `Initialize` value was set to `true` for me. When you breakpoint on the line `if(request.Initialize)` are the other request parameters set correctly? Do you use a proxy? Try adding the requestlog plugin `Plugins.Add(new RequestLogsFeature());` then check `/requestlogs`. – Scott Dec 17 '13 at 10:37
  • I'm using ServiceStack.3.9.68 without proxy. I'll try requestlog – Tomasito Dec 17 '13 at 10:45
  • 3.9.71 is the latest BSD version. But your problem may become clear once you see the requests. – Scott Dec 17 '13 at 11:04
  • @Scott Updated to latest, `/requestlogs` shows Connection Keep-Alive Content- Length 2 Content- Type application/jsv Accept application/jsv Accept- Encoding gzip Expect 100-continue Host localhost:1337, other columns (except Items and duration) are empty. – Tomasito Dec 17 '13 at 13:22
  • It occurs to me remove `[DataContract]` attribute, as you are not defining `[DataMember]`s so it's not serializing the object properly. – Scott Dec 17 '13 at 13:45

1 Answers1

2

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; }
}
Scott
  • 21,211
  • 8
  • 65
  • 72
  • 2
    This is correct, using DataContract's makes fields opt-in. Here are some other ways to [ignore fields in ServiceStack](http://stackoverflow.com/a/14859968/85785). – mythz Dec 18 '13 at 04:10