I have developed a bit of a complicated WCF Service method. I would like to use the Streaming transfer mode, and because I have more than one parameter, I have defined a MessageContract with a body and a header.
[MessageContract]
public class ReportAudioMessage
{
[MessageHeader]
public int ReportId;
[MessageHeader]
public string FileName;
[MessageHeader]
public int FileLengthInBytes;
[MessageHeader]
public int LengthInSeconds;
[MessageBodyMember]
public Stream ReportAudio;
}
Notice the stream is the only member of the body, per guidelines I read on MSDN.
The method is defined as such:
[OperationContract]
void SaveReportAudio(ReportAudioMessage reportToSave);
When I attempt to Invoke the method (using reflection), I get an error:
Error in deserializing body of request message for operation 'SaveReportAudio'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'SaveReportAudio' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'ReportAudioMessage' and namespace 'http://tempuri.org/'
SaveReportAudio is the name of the Service Method that I am calling. ReportAudioMessage is the name of the MessageContract that is defined. Clearly, my Soap Message is getting jacked up, but I don't know how... :(
The following is the Service Model node, of the Service's web config:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
<bindings>
<netTcpBinding>
<binding
name="VRManagerTcpBinding"
closeTimeout="00:01:00"
openTimeout="00:01:00"
sendTimeout="00:01:00"
receiveTimeout="00:01:00"
transferMode="Streamed">
<reliableSession enabled="false"/>
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="Radia.VoiceRecognition.Services.VRManager" behaviorConfiguration="VRManagerTcpBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8011/VRManager"/>
</baseAddresses>
</host>
<endpoint
address="VRManager.svc"
binding="netTcpBinding"
bindingConfiguration="VRManagerTcpBinding"
contract="Radia.VoiceRecognition.Services.IVRManager" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VRManagerTcpBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
And here is the Service Model node of the client's App.Config:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IVRManager" 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="65536">
<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="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://xxxxxxxxxxx:8012/VRManager.svc/VRManager.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IVRManager"
contract="VRManager.IVRManager" name="NetTcpBinding_IVRManager" />
</client>