2009-06-13 5 views
1

私のメソッドの1つは、ファイルのbyte []を返します。他のすべてのメソッドは、文字列オブジェクトまたはカスタムオブジェクトのいずれかを返します。ファイルを返すWCFサービスを消費しようとするとエラーが発生する

ブラウザ経由でWSDLを表示できます。私はWCfExtrasを使用しているので、ドキュメントを表示することもできます。

私のテストアプリケーションでは、C#Webアプリケーションで、テストサーバーでホストされているmy svcへの参照を追加します。私は、次のようなエラーが表示されます。

 The document was understood, but it could not be processed. 
    - The WSDL document contains links that could not be resolved. 
    - There was an error downloading ... 
    - Unable to connect to remote server 
    - No connection could be made because the target machine actively refused it 

    Content Type application/soap+xml; charset=utf-8 was not supported by service . The client and service bindings may be mismatched. 
    The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. 
    If the service is defined in the current solution, try building the solution and adding the service reference again. 

これは私のapp.configを

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <connectionStrings> 
    <add name="TestApp.Properties.Settings.TestDBConnectionString" 
     connectionString="Data Source=192.168.2.130;Initial Catalog=TestDB;Persist Security Info=True;User ID=sa;Password=xerox" 
     providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service behaviorConfiguration="TestApp.Service1Behavior" 
     name="TestApp.SearchService"> 
     <endpoint address="" behaviorConfiguration="Sample.WsdlSampleEndpointBehavior" 
      binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding" contract="TestApp.ISearchService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8731/TestApp/Service1/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="Sample.WsdlSampleEndpointBehavior"> 
      <wsdlExtensions location="http://localhost:8731/TestApp/Service1/"/> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="TestApp.Service1Behavior"> 
      <!-- 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="true" /> 
     </behavior> 

     </serviceBehaviors> 
    </behaviors> 
    <extensions> 
     <behaviorExtensions> 
     <!-- Declare that we have an extension called WSDL Extras--> 
     <add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
     </behaviorExtensions> 
    </extensions> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="WsHttpMtomBinding" messageEncoding="Mtom" transferMode="StreamedResponse" /> 
     </basicHttpBinding> 
    </bindings> 
    </system.serviceModel> 
</configuration> 

私はこの問題を解決する方法を上の任意のアイデアですか? 2つの異なるバインディング、1つはバイト[]を返すメソッドのための非バイト[]とMtomを返すメソッドの1つですか?もしそうなら、メソッドごとにバインディングを適用する方法は?

はWcfTestClient.exeでそれを実行している試み、これはエラークライアントアプリで

rror: Cannot import wsdl:portTypeDetail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporterError: Schema with target namespace 'http://tempuri.org/' could not be found.XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISearchService']Error: Cannot import wsdl:bindingDetail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISearchService']XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_ISearchService']Error: Cannot import wsdl:portDetail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_ISearchService']XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='SearchService']/wsdl:port[@name='BasicHttpBinding_ISearchService']Warning: No code was generated.If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or servicesor because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option. 

答えて

0

である、あなたはWCFExtrasアセンブリへの参照を持っているのですか?このエラーは、WCFExtrasによって導入された拡張のために、バインディングが認識されないことを示しているようです。クライアントの設定ファイルに、サーバの設定ファイルと同じ拡張機能セクションを追加してみてください。

+0

Jacob、VS2008の一部であるWCfTestClient.exeを使用して、自分のサービスを呼び出して使用しようとしています。 WcfTestClient.exeのrefをどのように追加するかわからない – user38230

+0

私はあなたのクライアントアプリケーションに拡張機能を追加できるということを意味していました。Webサービスのクライアントを作成していると仮定していて、そこに参照を追加できないという問題がありました。私はWcfTestClient.exeに慣れていません。 生成されているWSDLを投稿すると、より簡単に役立つかもしれません。 – Jacob

+0

Jacobは、サーバーが利用可能になると、WSDLを1日または明日までに投稿します。 – user38230

0

バインディングはbasicHttpBindingですが、バインド設定はwsHttpMTOMBindingです。

これは不一致のようですが、あなたが与えた名前だけかもしれません。

設定ファイルに矛盾がある場合は、WCF設定ツールで設定ファイルを開いてみてください(ファイルを開くことを拒否する)。これは

シラーズ

+0

Shiraz、 ファイルの内容を返すメソッドが1つあり、戻り値の型はBytes []です。私の他のすべてのメソッドは文字列とintを返します。したがって、私はMtomバインド設定に行きました。私は大きなファイルをBytes []として返すメソッドに異なるバインディング設定を適用でき、文字列とintを返すメソッドに異なるバインディング設定を適用できるかどうかはわかりません – user38230

+0

私が言っているのは、basichttpとwshttpを同じエンドポイントに組み合わせることができないということでした。私たちのプロジェクトの1つでは、あなたと同じ状況があります。ここでは単純なbasichtttpbindingを使用しました。メッセージサイズは十分に高く設定されています。これを使って最大30MBのファイルを送信しました。これは、メモリ使用量に関してMTOMを使用するのと同じくらい効率的ではありませんが、十分なメモリがあるため、問題はありませんでした。 まず、MTOMを使わずにbasichttpバインディングを試してみることをお勧めします。 MTOMが必要な場合は、契約を分割し、wshttpbindingを使用していることを確認します。 –

0

を助け

ホープこれが本当の答えすることはできませんが、私は私のapp.configファイルからWCfExtras参照を削除し、展開した後、物事は動作するようです。

これは私が達成しようとしましたが、誰もがどのように、私が間違って設定さの考えを持っている場合、この列にアドバイスしてください

WCF Extras

当分の間、放棄したものです。

多くのおかげ

0

は私がWCFテストクライアントを使用できるようにするための答えは、このようなウェブの設定で設定singleFile =「true」を設定することです。

<behavior name="Sample.WsdlSampleEndpointBehavior"> 
     <wsdlExtensions location="http://localhost:8731/TestApp/Service1/" singleFile="true" /> 
</behavior> 
1

私は同じ問題があります。私はIIS上のリモートwin2008サーバー上でwcfをホストしていました。私のために働いた解決策は、Webサイトを追加するときにホスト名を設定することでした。ホスティングのために他のすべてのデータを設定した後、空白にしないでください!

関連する問題