2017-04-14 4 views
0

新しいVisual Studio WCF Connectedサービスを使用して.NET Core Web APIからWCFサービスメソッドを呼び出そうとしています。.NET Coreアプリケーションのコンテンツ問題WCFサービスの使用

しかし、私はこれをテストしていたとき、私は次のエラーを取得する: -

The content type multipart/related; type="application/xop+xml"; start=" http://tempuri.org/0 "; boundary="uuid:9e7f9b02-4d9c-4ec1-bad4-1007704a579a+id=1197"; start-info="text/xml" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' --uuid:9e7f9b02-4d9c-4ec1-bad4-1007704a579a+id=1197 Content-ID: http://tempuri.org/0 Content-Transfer-Encoding: 8bit Content-Type: application/xop+xml;charset=utf-8;type="text/xml"

さらさWCFサービスがMTOM MessageEncodingを使用し、従来の.NETフレームワークのクライアントアプリケーションでは、我々はMTOMを使用するようにクライアントを設定することができますアプリケーションの設定ファイルですが、.NETコアでは、MessageEncodingを設定できる設定ファイルがありません。 は、Reference.cs(生成されたファイルです)にあるコードで処理されます。 私はMessageEncodingを設定するためにこの生成されたファイルを変更することは良い選択肢ではないと考えています。

この問題を処理する最善の方法は何ですか?

+0

私は(それが自動的に最新のverionにあなたのネットコアを更新するのVisual Studioの最新バージョンをインストールすることでのVisual Studio 2017の最新バージョンをインストールすることで問題を修正1.1.2)。 – Houtan

+1

お返事ありがとうございます。私のケースでは、もう一方の側のWCFサービスは、まだ.NETコアクライアントでサポートされていないMTOMを使用しています。 –

答えて

0

WCFコアチームから、現在のところMTOMエンコーディングが.NETコアベースのクライアントでサポートされていないことがわかりました。これは将来のバージョンで利用可能となる予定の機能です。私はそれが自動的に最新のverionにあなたのネットコアを更新するのVisual Studioの最新バージョンをインストールすることでのVisual Studio 2017の最新バージョンをインストールすることで問題を修正

0

Adding MTOM support in WCF runtime(1.1.2: はここでより多くの情報を持っているgithubのリンクあり)。

あなたも「binaryMessageEncodingBindingElement」を使用することができ

 ChannelFactory<ITestService> factory = null; 
     ITestService serviceProxy = null; 

     BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement(); 
     binaryMessageEncodingBindingElement.CompressionFormat = CompressionFormat.GZip; 

     HttpTransportBindingElement httpTransportBindingElement = new HttpTransportBindingElement(); 
     httpTransportBindingElement.MaxReceivedMessageSize = int.MaxValue; 

     CustomBinding customBinding = new CustomBinding(new BindingElement[] { binaryMessageEncodingBindingElement, httpTransportBindingElement }); 

     factory = new ChannelFactory<ITestService>(customBinding, new EndpointAddress("http://localhost/test.svc/mex")); 
     serviceProxy = factory.CreateChannel(); 

     var result = serviceProxy.GetResultData(50); 
+0

公開されているWCFサービスはMTOMエンコーディングを使用しており、私たちが制御できない別の会社によって所有され、管理されているため、これをバイナリに変更することはできません。 –

関連する問題