2012-04-27 7 views
0

コンソールアプリケーションからWCFサービスを参照するとメタデータエラーが発生します。 : "アドレスからメタデータをダウンロード中にエラーが発生しました"、。ここに私のサービスコードがあります。私はどんな助けにも感謝します。ここでメタデータのwcfエラー

namespace WcfService1 
{ 
    public class Service1 : IService1 
    { 
     public void test(string parm1, long parm2, Stream parm3) 
     { 

      string folder1 = @"C:\TEST"; 
      string fileName = Path.Combine(folder1, parm1); 

      using (FileStream target = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) 
      { 

        const int bufferLen = 65536; 
        byte[] buffer = new byte[bufferLen]; 
        int count = 0; 
        while ((count = parm3.Read(buffer, 0, bufferLen)) > 0) 
        { 
         target.Write(buffer, 0, count); 
        } 
      } 

     } 
    } 
} 

    namespace WcfService1 
    { 

     [ServiceContract] 
     public interface IService1 
     { 
      [OperationContract] 
      void test(string parm1, long parm2, Stream parm3); 
     } 
    } 

configです:

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 
+0

marc_s:私のCONFIGをご覧ください。 – nav100

答えて

0

おそらくこれには、テストするパラメータとしてSystem.IO.Streamを取るためです。私の経験では(誰かがここに来て、私を訂正するかもしれませんが)、次の2つのオプションがあります。

  1. リクエストオブジェクトにリクエストをラップします(以下を参照)。
  2. param1とparam2を削除し、Stream-paramのみを使用します。

サービスインタフェース:

[ServiceContract] 
public interface IService1 
{ 

     [OperationContract] 
     void test(Request request); 
} 

のDataContract:

namespace WcfService1 
{ 
    [DataContract] 
    public class Request 
    { 
     [DataMember] 
     public string Param1 { get; set; } 
     [DataMember] 
     public long Param2 { get; set; } 
     [DataMember] 
     public Stream Param3 { get; set; } 
    } 
} 

あなたは、ストリームのサブセットのために[KnownType]使用して、いくつかの追加作業が必要になる場合がありますが、私はこれを非常によくわからないんです。上記は、サービス参照を追加するときに表示されるMetaDataエラーから少なくとも離れる必要があります。

関連する問題