RESTサービスとSOAPサービスを消費するクライアントを比較すると、説明できないパフォーマンス結果が得られました。私がやったことは、次のようにサービスプロキシを作成することです:RESTサービスプロキシとWCF SOAPプロキシのパフォーマンス
REST:
WebHttpBinding webBinding = new WebHttpBinding();
webBinding.AllowCookies = true;
webBinding.MaxReceivedMessageSize = int.MaxValue;
CustomBinding custom = new CustomBinding(webBinding);
WebMessageEncodingBindingElement webMEBE = custom.Elements.Find<WebMessageEncodingBindingElement>();
webMEBE.ContentTypeMapper = new MyMapper();
webMEBE.ReaderQuotas.MaxArrayLength = int.MaxValue;
var factory = new WebChannelFactory<ITest>(custom, new Uri("http://localhost/Test"));
var proxy = factory.CreateChannel();
SOAP:
endPointAddr = "net.tcp://" + textBox2.Text +
":8909/MyService";
tcpBinding = new NetTcpBinding();
tcpBinding.MaxReceivedMessageSize = int.MaxValue;
tcpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Transport.ProtectionLevel =
System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType =
TcpClientCredentialType.Windows;
tcpBinding.Security.Mode = SecurityMode.None;
endpointAddress =
new EndpointAddress(endPointAddr);
IService1 proxy =
ChannelFactory<IService1>.CreateChannel(tcpBinding, endpointAddress);
両方IService1
とITest
返し、私が使用して1つのメソッドGetRequest()
を、持っている〜 300Kbオブジェクト。 IService1.GetRequest()はOperationContract、ITest.GetRequest()はWebGetです。
どちらの場合でもチャネルを開くと、proxy.GetRequest()というタイトなループを実行して、処理できるリクエストの数を把握しました。結果は、テストがローカルマシン上で行われた場合、SOAPが5:1でRESTを上回り、ネットワーク上でSOAPは依然としてRESTを約50%上回っていたことです。
なぜ大きな違いがあるのかわかりません。
あなたのSOAPはSOAPではありません。 –
Embarassing:S。金曜日に、どちらかの技術を初めて使用したのですが、私はWCF SOAPを検索したときのチュートリアルから始めました。 – user472875