문제
이미지 크기를 조정하기 위해 작은 WCF/WPF 앱을 작성하고 있지만 WCF는 클라이언트의 서비스에 크기 28K 이미지를 보내려고 할 때 슬픔을주고 있습니다. 작은 이미지를 보낼 때 서비스가 잘 작동합니다. 나는 이것이 구성 문제라고 가정했으며 바인딩 구성에서 MaxArraylength 속성에 관한 게시물을보고 웹을 트롤했습니다. 클라이언트와 서버의 이러한 설정에 대한 제한을 최대 2147483647로 올렸지 만 여전히 다음 오류가 발생합니다.
Formatter는 메시지를 사로화하려고 시도하면서 예외를 던졌습니다. 매개 변수를 사로화하려는 동안 오류가있었습니다 http://mywebsite.com/services/servicecontracts/2009/01:originalimage. innerexception 메시지는 'system.drawing.image 유형의 대상을 실시하는 오류가있었습니다. XML 데이터를 읽는 동안 최대 배열 길이 할당량 (16384)이 초과되었습니다. 이 할당량은 XML 리더를 생성 할 때 사용되는 xmlDictionaryReaderQuotas 객체에서 MaxArraylength 속성을 변경하여 증가 할 수 있습니다. ' 자세한 내용은 innerexception을 참조하십시오.
클라이언트와 서버 구성을 동일하게 만들었고 다음과 같습니다. 서버 :
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="LogoResizer.WCF.ServiceTypes.ImageResizerService" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:900/mex/"/>
<add baseAddress="net.tcp://localhost:9000/" />
</baseAddresses>
</host>
<endpoint binding="netTcpBinding" contract="LogoResizer.WCF.ServiceContracts.IImageResizerService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
내 클라이언트 구성은 다음과 같습니다.
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:9000/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_ImageResizerServiceContract"
contract="ImageResizerService.ImageResizerServiceContract"
name="NetTcpBinding_ImageResizerServiceContract">
<identity>
<userPrincipalName value="me@domain.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
이 값을 무엇으로 설정하든 여전히 WCF가 16384보다 크기 때문에 WCF가 내 파일을 직렬화 할 수 없다는 오류를 얻는 것 같습니다.
업데이트: userprincipalname 태그의 이메일 주소가 내 개인 정보를 위해 변경되었습니다.
해결책
내 나쁜 - 서버 측 구성에서 바인딩 구성을 엔드 포인트에 적용하는 것을 잊었습니다. 서버 구성을 읽어야합니다.
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="LogoResizer.WCF.ServiceTypes.ImageResizerService" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:900/mex/"/>
<add baseAddress="net.tcp://localhost:9000/" />
</baseAddresses>
</host>
<endpoint bindingConfiguration="NetTcpBinding_ImageResizerServiceContract" binding="netTcpBinding" contract="LogoResizer.WCF.ServiceContracts.IImageResizerService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
참고 BindingConfiguration = "nettcpbinding_imageresizerservicecontract"가 NetTCP 엔드 포인트에 추가되었습니다. 내 앱은 이제 더 큰 이미지로 작동합니다. 달콤한.
다른 팁
추가하십시오 <readerQuotas>
바인딩에서.
이것이 바이트를 업로드하고 다운로드하는 동안 주요 문제이며, 내 문제를 해결했습니다.
<basicHttpBinding>
<binding name="ServicesBinding" transferMode="Streamed" maxBufferSize="200000000"
maxReceivedMessageSize="200000000" messageEncoding="Text"
receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
Microsoft SDK SVCConfigeditor를 사용했습니다. Visual Studio (자체 버전이 있음)를 사용하는 경우에는 이것을 갖습니다. 또한 무료 다운로드입니다.
하드 드라이브에서 (프로그램 파일과 프로그램 파일을 모두 확인) : (x86) :
C : Program Files (x86) Microsoft SDKS Windows V7.0A Bin Netfx 4.0 도구 SVCConfigeditor.exe
C : Program Files Microsoft SDKS Windows V7.1 bin netfx 4.0 도구 svcconfigeditor.exe
Microsoft SDK의 여러 설치가있는 경우 사용하는 버전은 어떤 버전의 개발중인 버전에 따라 다릅니다. 이 도구는 잘못된 버전에서 .dll 파일을 열려고했음을 알리는 오류가 발생합니다.
도구를 사용하려면 서비스의 .dll 파일을 가리키고 도구가 무거운 리프팅을하도록하십시오. 서비스와 대화하는 서비스가있는 경우 특히 유용합니다 (프록시 서비스). 또한 클라이언트 (응용 프로그램) 및 서버 구성 (웹 서비스에서)에 대한 구성 설정이 필요할 수 있습니다.
서버 측 엔드 포인트에 구성이 누락되었습니다. 나는 두 가지 일을해야했다 :
- svcconfigeditor를 사용하여 구성된 서버 측 구성에 엔드 포인트를 넣으십시오.
- svcconfigeditor 도구에서 maxarraylength를 설정해야합니다
또한 ASP.NET 은이 값에 대해 까다 롭기 때문에 구성 바인딩을 단순화하고 끄십시오.
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
WCF 서비스를 탐색 할 때 net.tcp : //myservice.com/ac_service.svc/mex의 참조를 보여 주지만 지금은 작동하지만 이제http://myservice.com/ac_service.svc?wsdl
문제없이 미래에도 효과가있을 것입니다.