客户端连接,发送Put:
var client = new JsvServiceClient(ConfigGlobal.Host);
client.Put(new PiecParametrySzczegoloweRequest { Initialize = true, Config = _config });
服务器接到来电,看不到Initialize
变量值设置为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;
}
}
请求看起来像:
[DataContract]
[Route("/PiecParametrySzczegolowe")]
public class PiecParametrySzczegoloweRequest : IReturn<PiecParametrySzczegoloweResponse>
{
public bool Initialize { get; set; }
public PiecParametrySzczegoloweLegend Config { get; set; }
public int Percent { get; set; }
}
缺乏属性,谢谢!并且(同时解决了问题)......
如果您需要/requestlogs
并且您没有使用身份验证:
Plugins.Add(new RequestLogsFeature() { RequiredRoles = new string[0] });
如果您需要序列化二进制数据(位图),请使用protobuf-net(var client = new ProtoBufServiceClient(ConfigGlobal.Host);
)并执行类似Serialize a Bitmap in C#/.NET to XML
如果您不希望(需要)注释每个字段成员(阅读警告)Protobuf-net serialization without annotation
答案 0 :(得分:2)
您需要删除[DataContract]
属性,因为此属性告诉序列化程序您将使用[DataMember]
属性指定要包含的序列化字段,但您还没有这样做了。
或者使用[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; }
}