私はしばらくこれに苦労していて、本当にいくつかの助けを使うことができました。
サーバーへの画像のストリーミングを可能にし、imageURL(つまり、「http://images.site.com/someimage.jpg」)を返すWCFエンドポイントを設計しようとしています。
現在、私のWCFメソッドの呼び出しは次のようになっています。
for (var i = 0; i <= (Request.Files.Count - 1); i++)
{
client = new SOAPFileTransferServiceClient();
fileinfo = new FileTransferInfo();
m_objFile = Request.Files[i];
if (!(m_objFile == null | string.IsNullOrEmpty(m_objFile.FileName) | _objFile.ContentLength < 1))
{
fileinfo.FileSize = m_objFile.ContentLength;
fileinfo.FileName = Path.GetFileName(m_objFile.FileName);
fileinfo.UserID = Context.Request["sid"].ToString();
client.UploadFile(fileinfo, m_objFile.InputStream);
if (retParam.param2 == 0)
imgurl.Add(retParam.param1);
}
}
私が苦労しているエラーはこれです:
転送モードStreamedは、ReliableSessionBindingElementではサポートされていません。
これまで、メッセージエンコーディング要素の前に追加されたカスタムnetTcpバインディングを作成してみました。また、transerMode属性をstreamedRequestに変更し(marc_sによる提案のおかげで)、要求はストリーミングされますが、応答は許可されません。これでうまくいくようですが、それでも同じエラーが発生します(今回は「転送モードStreamedRequestは...ではありません...」)。
私は考えが足りません。
以下はファイル転送サービス契約です。SOAPエンドポイントに加えてJSONとPOXがあります。また、2つのMEXエンドポイントがあります(1つはmexHttp用、もう1つはnetTcp用)。最後に、http(jsonとpoxの場合)とnetTcp(soapの場合)の両方のベースアドレスがあります。
何か問題がありますか?
<service behaviorConfiguration="transferServiceBehavior" name="MyProject.API.FileTransfer.FileTransferService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="jsonWeb" name="MyJSONFileTransferEP"
contract="MyProject.API.FileTransfer.IJSONFileTransferService" />
<endpoint address="pox" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="poxWeb" name="MyPOXFileTransferEP"
contract="MyProject.API.FileTransfer.IPOXFileTransferService" />
<endpoint address="httpMex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<endpoint address="soap" behaviorConfiguration="NetTcpEPBehavior"
binding="customBinding" bindingConfiguration="netTcpCustom"
name="MySOAPFileTransferEP" contract="MyProject.API.FileTransfer.ISOAPFileTransferService" />
<endpoint address="nettcpMex" binding="netTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:2544/filetransfer/" />
<add baseAddress="net.tcp://localhost:2544/filetransfer/" />
</baseAddresses>
</host>
</service>
そして、これがサービス契約で使用される私のカスタムバインディングです:
<customBinding>
<binding name="netTcpCustom"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00">
<reliableSession />
<compositeDuplex />
<oneWay />
<windowsStreamSecurity protectionLevel="None" />
<mtomMessageEncoding />
<tcpTransport maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647"
connectionBufferSize="8192"
hostNameComparisonMode="StrongWildcard"
channelInitializationTimeout="00:01:00"
maxBufferSize="2147483647"
maxPendingConnections="20"
maxOutputDelay="00:00:00.2000000"
maxPendingAccepts="5"
transferMode="StreamedRequest"
listenBacklog="20"
portSharingEnabled="false"
teredoEnabled="false">
<connectionPoolSettings groupName="default" leaseTimeout="00:05:00"
idleTimeout="00:02:00" maxOutboundConnectionsPerEndpoint="20" />
</tcpTransport>
</binding>
</customBinding>
最後に、その価値について、App.configのsystem.serviceModel定義全体を以下に示します。
<system.serviceModel>
<client>
<endpoint address="http://localhost:2542/auth/json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="jsonWeb" contract="Trezoro.WebAPI.Authentication.IJSONAuthService"
name="MyJSONAuthEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2542/auth/pox" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="poxWeb" contract="Trezoro.WebAPI.Authentication.IPOXAuthService"
name="MyPOXAuthEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2542/auth/soap" behaviorConfiguration="BasicHttpEPBehavior"
binding="basicHttpBinding" bindingConfiguration="soapWeb" contract="Trezoro.WebAPI.Authentication.ISOAPAuthService"
name="MySOAPAuthEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2542/auth/mex" binding="mexHttpBinding"
bindingConfiguration="" contract="IMetadataExchange" name="authmex">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2543/trade/json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="jsonWeb" contract="Trezoro.WebAPI.Trade.IJSONTradeService"
name="MyJSONTradeEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2543/trade/pox" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="poxWeb" contract="Trezoro.WebAPI.Trade.IPOXTradeService"
name="MyPOXTradeEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2543/trade/soap" behaviorConfiguration="BasicHttpEPBehavior"
binding="basicHttpBinding" bindingConfiguration="soapWeb" contract="Trezoro.WebAPI.Trade.ISOAPTradeService"
name="MySOAPTradeEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2543/trade/mex" binding="mexHttpBinding"
bindingConfiguration="" contract="IMetadataExchange" name="trademex">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2544/filetransfer/json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="jsonWeb" contract="Trezoro.WebAPI.FileTransfer.IJSONFileTransferService"
name="MyJSONFileTransferEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2544/filetransfer/pox" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="poxWeb" contract="Trezoro.WebAPI.FileTransfer.IPOXFileTransferService"
name="MyPOXFileTransferEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="http://localhost:2545/filetransfer/soap" behaviorConfiguration="NetTcpEPBehavior"
binding="customBinding" bindingConfiguration="netTcpCustom"
contract="Trezoro.WebAPI.FileTransfer.ISOAPFileTransferService"
name="MySOAPFileTransferEP">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:2545/filetransfer/nettcpMex"
binding="netTcpBinding" bindingConfiguration="" contract="IMetadataExchange"
name="filetransfermex">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
</client>
<bindings>
<basicHttpBinding>
<binding name="soapWeb" />
<binding name="httpLargeMessageStream"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="StreamedRequest"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="netTcpCustom"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00">
<reliableSession />
<compositeDuplex />
<oneWay />
<windowsStreamSecurity protectionLevel="None" />
<mtomMessageEncoding />
<tcpTransport maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647"
connectionBufferSize="8192"
hostNameComparisonMode="StrongWildcard"
channelInitializationTimeout="00:01:00"
maxBufferSize="2147483647"
maxPendingConnections="20"
maxOutputDelay="00:00:00.2000000"
maxPendingAccepts="5"
transferMode="StreamedRequest"
listenBacklog="20"
portSharingEnabled="false"
teredoEnabled="false">
<connectionPoolSettings groupName="default" leaseTimeout="00:05:00"
idleTimeout="00:02:00" maxOutboundConnectionsPerEndpoint="20" />
</tcpTransport>
</binding>
</customBinding>
<netTcpBinding>
<binding name="netTcpWeb"
hostNameComparisonMode="StrongWildcard"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
maxReceivedMessageSize="2147483647"
transferMode="StreamedRequest"
portSharingEnabled="false">
<security mode="None" />
</binding>
</netTcpBinding>
<webHttpBinding>
<binding name="poxWeb"
maxBufferSize="1500000"
maxBufferPoolSize="1500000"
maxReceivedMessageSize="1500000">
<readerQuotas maxDepth="32"
maxStringContentLength="656000"
maxArrayLength="656000"
maxBytesPerRead="656000"
maxNameTableCharCount="656000" />
</binding>
<binding name="jsonWeb"
maxBufferSize="1500000"
maxBufferPoolSize="1500000"
maxReceivedMessageSize="1500000">
<readerQuotas maxDepth="32"
maxStringContentLength="656000"
maxArrayLength="656000"
maxBytesPerRead="656000"
maxNameTableCharCount="656000" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Default" name="Trezoro.WebAPI.Authentication.AuthService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="jsonWeb" name="MyJSONAuthEP"
contract="Trezoro.WebAPI.Authentication.IJSONAuthService" />
<endpoint address="pox" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="poxWeb" name="MyPOXAuthEP"
contract="Trezoro.WebAPI.Authentication.IPOXAuthService" />
<endpoint address="soap" behaviorConfiguration="BasicHttpEPBehavior"
binding="basicHttpBinding" bindingConfiguration="soapWeb" name="MySOAPAuthEP"
contract="Trezoro.WebAPI.Authentication.ISOAPAuthService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:2542/auth/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="Default" name="Trezoro.WebAPI.Trade.TradeService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="jsonWeb" name="MyJSONTradeEP"
contract="Trezoro.WebAPI.Trade.IJSONTradeService" />
<endpoint address="pox" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="poxWeb" name="MyPOXTradeEP"
contract="Trezoro.WebAPI.Trade.IPOXTradeService" />
<endpoint address="soap" behaviorConfiguration="BasicHttpEPBehavior"
binding="basicHttpBinding" bindingConfiguration="soapWeb" name="MySOAPTradeEP"
contract="Trezoro.WebAPI.Trade.ISOAPTradeService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:2543/trade/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="transferServiceBehavior" name="Trezoro.WebAPI.FileTransfer.FileTransferService">
<endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="jsonWeb" name="MyJSONFileTransferEP"
contract="Trezoro.WebAPI.FileTransfer.IJSONFileTransferService" />
<endpoint address="pox" behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding" bindingConfiguration="poxWeb" name="MyPOXFileTransferEP"
contract="Trezoro.WebAPI.FileTransfer.IPOXFileTransferService" />
<endpoint address="httpMex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<endpoint address="soap" behaviorConfiguration="NetTcpEPBehavior"
binding="customBinding" bindingConfiguration="netTcpCustom"
name="MySOAPFileTransferEP" contract="Trezoro.WebAPI.FileTransfer.ISOAPFileTransferService" />
<endpoint address="nettcpMex" binding="netTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:2544/filetransfer/" />
<add baseAddress="net.tcp://localhost:2544/filetransfer/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebHttpEPBehavior">
<webHttp />
</behavior>
<behavior name="BasicHttpEPBehavior" />
<behavior name="NetTcpEPBehavior" />
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
<behavior name="transferServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
ありとあらゆる提案に感謝します。ご協力いただきありがとうございます。