Protobuf-net の RPC 機能を使用して WCF Web サービスを使用しようとしています。これが私のサービス契約です:
namespace WcfEchoService
{
// NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
[ServiceContract]
public interface IEchoService
{
[OperationContract, ProtoBehavior]
string Echo(string value);
[OperationContract, ProtoBehavior]
string EchoNull();
[OperationContract, ProtoBehavior]
CompositeType[] EchoData(CompositeType[] value);
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
[ProtoContract]
public class CompositeType
{
[ProtoMember(1)]
public bool BoolValue
{
get;
set;
}
[ProtoMember(2)]
public string StringValue
{
get;
set;
}
}
}
そして、そのすぐ下が私の .NET CF クライアントです。
class EchoServiceClient : ProtoClient, IEchoService {
#region IEchoService Members
public EchoServiceClient() : base(new HttpBasicTransport("my service URI"))
{
}
public string Echo(string value)
{
return (string)this.Invoke("Echo", value);
}
public string EchoNull()
{
return (string)this.Invoke("EchoNull");
}
public CompositeType[] EchoData(CompositeType[] value)
{
return (CompositeType[])this.Invoke("EchoData", value);
}
#endregion
}
そして、これは私がWebサービスを消費しようとする方法です:
class Program
{
static void Main(string[] args)
{
EchoServiceClient client = new EchoServiceClient();
Console.WriteLine(client.EchoNull());
}
}
次のメッセージで例外が発生し続けます。
AllowWriteStreamBuffering が無効な場合に書き込み操作を実行するには、ContentLength を負でない数値に設定するか、SendChunked を true に設定する必要があります。
protobuf-net のソース コードを掘り下げた後にわかる限り、問題は content-length が指定されていないことのようです。.NET CF で protobuf-net シリアル化を使用して WCF Web サービスを使用する方法や、この問題を解決する方法はありますか?
あなたがいるマーク:)