3

少し複雑な WCF Service メソッドを開発しました。ストリーミング転送モードを使用したいのですが、複数のパラメーターがあるため、本文とヘッダーで MessageContract を定義しました。

[MessageContract]
public class ReportAudioMessage
{
    [MessageHeader]
    public int ReportId;

    [MessageHeader]
    public string FileName;

    [MessageHeader]
    public int FileLengthInBytes;

    [MessageHeader]
    public int LengthInSeconds;

    [MessageBodyMember]
    public Stream ReportAudio;
}

MSDN で読んだガイドラインに従って、ストリームが本体の唯一のメンバーであることに注意してください。

メソッドは次のように定義されます。

    [OperationContract]
    void SaveReportAudio(ReportAudioMessage reportToSave);

(リフレクションを使用して) メソッドを呼び出そうとすると、エラーが発生します。

操作 'SaveReportAudio' の要求メッセージの本文をデシリアライズ中にエラーが発生しました。OperationFormatter で無効なメッセージ本文が検出されました。名前が 'SaveReportAudio' で名前空間が ' http://tempuri.org/ ' のノード タイプ 'Element' が見つかるはずです。名前が「ReportAudioMessage」で名前空間が「http://tempuri.org/」のノード タイプ「要素」が見つかりました

SaveReportAudio は、呼び出しているサービス メソッドの名前です。ReportAudioMessage は、定義されている MessageContract の名前です。明らかに、私の Soap Message はジャッキアップされていますが、方法がわかりません... :(

以下は、サービスの Web 構成のサービス モデル ノードです。

<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>

クライアントの App.Config の Service Model ノードは次のとおりです。

<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>

4

1 に答える 1