메시지 계약과 함께 WCF 스트리밍을 사용하려고합니다. 스트림 자체 옆에 추가 매개 변수가 필요하기 때문입니다.WCF : 메시지 계약을 사용하여 스트리밍 사용
기본적으로 파일 업로드 및 다운로드 서비스를 만들고 추가 로직을 맨 위에 표시합니다.
서버 오류 '/'응용 프로그램에 : 나는 모든 것이 잘 있는지 확인하기 위해 브라우저에서 서비스를 공격 할 때
불행하게도, 나는 다음과 같은 오류가 발생합니다. 작업 'UploadFile'계약에서 'IFileTransferService'는 SOAP 헤더가있는 MessageContract를 사용합니다. SOAP 헤더는 None MessageVersion에서 지원하지 않습니다.
불행히도 내게 도움이되는 중요한 결과를 얻지 못했습니다. 너희들이 나를 도울 수 있니? 여기 서비스의 세부 사항 (나는 공간 때문에 다운로드 부분을 제거했다).
<customBinding>
<binding name="customHttpBindingStream">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport transferMode="Streamed" maxReceivedMessageSize="2147483647"/>
</binding>
</customBinding>
UPDATE :
[ServiceContract(Namespace = "http://www.acme.org/2009/04")]
public interface IFileTransferService
{
[OperationContract(Action = "UploadFile")]
void UploadFile(FileUploadMessage request);
}
[MessageContract]
public class FileUploadMessage
{
[MessageHeader(MustUnderstand = true)]
public FileMetaData Metadata { get; set; }
[MessageBodyMember(Order = 1)]
public Stream FileByteStream { get; set; }
}
[DataContract(Namespace = "http://schemas.acme.org/2009/04")]
public class FileMetaData
{
[DataMember(Name="FileType", Order=0, IsRequired=true)]
public FileTypeEnum fileType;
[DataMember(Name="localFilename", Order=1, IsRequired=false)]
public string localFileName;
[DataMember(Name = "remoteFilename", Order = 2, IsRequired = false)]
public string remoteFileName;
}
난은 BasicHttpBinding이 아닌 긍정적 인 효과와 바인딩 customhttp를 모두 사용하는 것을 시도했다 온라인 설명서를 읽기가 MessageContracts와 함께 스트리밍 참으로 할 수 있어야 것으로 보인다. MSDN (Large Data and Streaming)에 예를 들어, 참조 : 나는 또한 파일 업로드의 서비스를 달성하는 사람들의 블로그 게시물을 본 내가 (예를 here을 위해) 함께 넣어하려고 것과 매우 유사 다운로드 한
Programming Model for Streamed Transfers
The programming model for streaming is straightforward. For receiving streamed data, specify an operation contract that has a single Stream typed input parameter. For returning streamed data, return a Stream reference. [...] This rule similarly applies to message contracts. As shown in the following message contract, you can have only a single body member in your message contract that is a stream. If you want to communicate additional information with the stream, this information must be a carried in message headers. The message body is exclusively reserved for the stream content.
[MessageContract]
public class UploadStreamMessage
{
[MessageHeader]
public string appRef;
[MessageBodyMember]
public Stream data;
}
.
UPDATE 2 난은 BasicHttpBinding과 서비스를 호스팅하는 작은 콘솔과 자기를 만드는 시도하고 거기에 마법처럼 작동합니다. 나는 그 문제가 IIS에서의 호스팅일지도 모른다고 생각하기 시작했다. 어떤 생각?
업데이트 3 내 대답보기
몸체 요소가 하나뿐이므로'Order = 1'은'MessageBodyMember' 속성에서 중복되는 것 같습니다. –