WCF
을 통해 파일을 업로드하는 방법을 설명하고 클라이언트와 서버간에 이 포함 된 클래스를 공유하려고 할 때 몇 가지 문제가있는 다양한 자습서를 따르고 있습니다. 다음과 같이messagecontract로 파일 업로드
기본적으로 내 문제는 다음과 같습니다
나는 별도의 클래스 라이브러리의 내부RemoteFileInfo
MessageContract
클래스가 :
[MessageContract]
public class RemoteFileInfo : IDisposable
{
private System.IO.Stream fileByteStream;
[MessageBodyMember(Order = 1)]
public System.IO.Stream FileByteStream
{
set { this.fileByteStream = value; }
get { return this.fileByteStream; }
}
/*More properties here declared as regular properties or [MessageHeader]*/
}
그때 서버와 클라이언트 모두에 해당 라이브러리를 공유 할 수 있습니다. 이는 클라이언트 이이 자신의 RemoteFileInfo
클래스를 구현하지 않아야 함을 의미합니다. 그러나 클라이언트 프로젝트에 .dll을 추가 한 다음 Reuse Types
을 사용하여 Add Service Reference
을 사용하면 서비스 참조의 네임 스페이스 내부에 RemoteFileInfo
클래스가 다시 만들어져 원래 클래스 라이브러리의 형식과 그 사이에 모호성이 생깁니다.
내 질문은 클라이언트와 서버간에 MessageContract
으로 선언 된 클래스를 어떻게 공유 할 수 있습니까? OperationContract
에 RemoteFileInfo
개체가 필요하고 원래 RemoteFileInfo
클래스에서 선언 한 동일한 속성을 유지하고 싶기 때문에이 작업을 수행해야합니다. 내 OperationContract
는 :
[OperationContract]
void uploadFile(RemoteFileInfo request);
나는이 서비스 계약에 선언하는 방법을 정확히 클라이언트 에서 해당 메소드를 호출 할 수 있어야합니다. 지금까지 서비스 참조를 추가 할 때 Generate message headers
옵션을 사용하여 주위를 둘러 보았을 때 스트림 대신 byte[]
매개 변수가있는 uploadFile
메서드로 끝나고 스트림이되어야합니다.
아이디어가 있으십니까?
편집 : 클라이언트 구성을 게시 할 예정 이었지만 기존의 app.config가 없으므로 Windows 스토어 응용 프로그램 용으로 개발 중이라고 언급해야합니다.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IRTMobileWebService" sendTimeout="00:05:00" />
</basicHttpBinding>
<netTcpBinding>
<binding name="uploadEndpoint" sendTimeout="00:05:00" transferMode="Streamed">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="http://ipaddress/RTWebServices/RTMobileWebService.svc/basic"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRTMobileWebService"
contract="IRTMobileWebService" name="BasicHttpBinding_IRTMobileWebService" />
<endpoint address="net.tcp://ipaddress/RTWebServices/RTMobileWebService.svc/upload"
binding="netTcpBinding" bindingConfiguration="uploadEndpoint"
contract="IRTMobileImageService" name="uploadEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
가 어떻게 더의 app.config과 윈도우 스토어 앱에서이를 복제 할 다음 WCF 테스트 클라이언트가 어쨌든 클라이언트 설정에 대해 생성 무엇을 Heres
?
내가 WCFTest 클라이언트에서 클라이언트 설정을 복사하여 얻을 수있는 엔드 포인트의 이름입니다
은 다음과 같이 그것을 코드에서 서비스를 사용하려면 Visual Studio에서 서비스를 실행하십시오. – user1806716예. 대답을 더 완전하게 만들기 위해 예제 클라이언트 구성을 잠시 추가 할 것입니다. – dodexahedron
nettcpbinding에 관한 새로운 오류와 함께 구성을 게시합니다. – user1806716