I've got a question to WCF masters.
First of all - I want to implement service, that will allow clients send fax.
So I need upload a file, and data like author, or dispatch date.
All client machines will be in the same local network - so I will use netTcpBinding.
And now, what is my problem?
Actually, I've already done that, it works, but the solution is not great and I've got a couple of problems:
- I can't return value, because of "MessageContract". So, when some connection problems happened, client will never knows.
- second, "MessageContract", some say that this is a bad solution and should be used rarely - don't know why.
- my third problem with that solution is, i basically can't send more than one file (in case I want to use that to send emails, with multiple attachments).
Here is my code on server-side:
Service:
[ServiceContract()]
public interface IFileTransferService
{
[OperationContract(IsOneWay = true)]
void Upload(FileTransferRequest request);
}
[MessageContract()]
public class FileTransferRequest
{
[MessageHeader(MustUnderstand = true)]
public string FileName;
[MessageBodyMember(Order = 1)]
public System.IO.Stream Data;
}
And my App.config:
="1.0"
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding
name ="MyTCP"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Streamed"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="209715200">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="service.FileTransferService" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/FileTransfer"/>
</baseAddresses>
</host>
<endpoint address="" binding="netTcpBinding" bindingConfiguration="MyTCP" contract="service.IFileTransferService"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Thank you for help,