2009-12-09 4 views
1

저는 잠시 동안 어려움을 겪어 왔고 실제로 도움이 될 수있었습니다.이중 모드 StreamedRequest가 신뢰할 수있는 세션 바인딩과 작동하지 않습니다.

서버로 이미지 스트리밍을 허용 한 다음 imageURL을 반환하는 WCF 끝점을 디자인하려고합니다 (예 : "http://images.site.com/someimage.jpg").

현재 내 WCF 메서드 호출은 다음과 같습니다

전송 모드 스트리밍이 ReliableSessionBindingElement에서 지원하지 된다

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); 

    } 

} 

내가 고민하고 오류이입니다.

지금까지 메시지 인코딩 요소 앞에 이 추가 된 사용자 지정 netTcp 바인딩을 만들려고했습니다. 또한 transerMode 속성 을 streamedRequest (marc_s의 제안 덕분에)로 변경하여 요청은 스트리밍되지만 응답은 허용하지 않습니다. 이것은 트릭을하는 것처럼 보이지만 여전히 같은 오류가 발생합니다 (이번에는 "전송 모드 StreamedRequest가 아닙니다 ...").

나는 아이디어가 없습니다.

다음은 파일 전송 서비스 계약입니다. SOAP 종점에 JSON과 POX가 있습니다. 또한 mexHttp와 netTcp에 각각 2 개의 MEX 끝 점이 있습니다. 마지막으로, 나는 http (json과 pox의 경우)와 netTcp (비누의 경우)의 기본 주소를 모두 가지고있다.

아무 잘못 보이지 않습니까? 여기

<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> 

모든 제안 사항에 감사드립니다. 당신의 도움을 주셔서 감사합니다.

답변

1

신뢰할 수있는 세션 요소를 삭제하면 StreamedRequest 메서드가 작동합니까? 그걸로 살 수 있니? netTcp를 사용한다면 기업 방화벽 뒤에있을 수 있습니다. 맞습니까? 따라서 신뢰할 수있는 세션 오버 헤드없이 도망 갈 수 있습니다.

또한 WCF에는 다양한 옵션과 가능한 기능 조합이 있습니다. 모든 것이 의미가 없으며 모든 것이 함께 작동하지는 않습니다. 어쩌면 이것은 제한 사항 일 수 있습니다. WCF에서는 사용자 구성 문제가 아닙니다.

설정에 관한 유일한 이상한 점은 netTcp 사용자 정의 바인딩의 mtomMessageEncoding입니다. 왜 훨씬 효율적인 이진 인코딩을 사용하지 않을까요 ??

<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" 

왜 대신

<binaryMessageEncoding /> 

를 사용 ??

+0

Marc - 이미지를 서버로 스트리밍하고 WCF에서 응답으로 문자열 컬렉션을 가져올 수 있는지 알고 계십니까? 내 말은, "할 수있는 것"의 관점에서 - 이것이 가능하다는 것을 알고 있습니까? –

+0

물론 가능합니다. 그러나 : 일단 전화가 서버에 정확하게 하나의 이미지를 전송하고 정확히 하나의 URL을 반환합니다. –

+0

와우 - 이것은 내가 만든 것보다 훨씬 덜 복잡했습니다. 나는 마침내 내가 원하는 것을 할 수있는 방법을 알아 냈고 클라이언트로부터 호출 된 WCF 업로드 메서드에 의해 반환 된 각 URL 문자열을 추가하는 문자열 컬렉션을 작성했습니다. 그러나 transferMode = streamed와 composite duplex 속성이 잘 작동하지 않는다는 것을 알았습니다. 없음 - 덜 - 당신의 도움에 대한 톤 감사드립니다. –

관련 문제