2015-10-01 25 views
5

私は、クラスライブラリ内のWCFサービスと、Webアプリケーション内のそのクラスライブラリを参照しています。私がサービスからメソッドを呼び出そうとすると、私は例外よりも下になります。WCF Webサービスの呼び出し中にエラーが発生しました

"Content Type multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:901bc2e6-6d57-4363-9f99-41ca4884ce16+id=1";start-info="text/xml" was not supported by service https://URL_OF_Service/. The client and service bindings may be mismatched." 

は、ここに私の構成

<system.serviceModel> 
    <bindings> 
     <customBinding> 
     <binding name="CoreSoapBinding"> 
      <textMessageEncoding messageVersion="Soap12" /> 
      <httpTransport /> 
     </binding> 
     </customBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://URL_OF_Service/" binding="customBinding" 
      bindingConfiguration="CoreSoapBinding" contract="ContractName" 
      name="CoreSoapPort" /> 
    </client> 
    </system.serviceModel> 

であると私は、アプリケーション内のバインディングオブジェクトを作成し、サービスに渡されました。

BasicHttpBinding binding = new BasicHttpBinding() 
      binding.Security.Mode = BasicHttpSecurityMode.Transport; 
      binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
      binding.Name = "CoreSoapPort"; 
      binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; 
      binding.BypassProxyOnLocal = false; 
      binding.UseDefaultWebProxy = true; 
      binding.MessageEncoding = WSMessageEncoding.Mtom; 
      binding.AllowCookies = false; 
      binding.TransferMode = TransferMode.Buffered; 
      binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; 
      Encoding textencoding = Encoding.UTF8; 
      binding.TextEncoding = textencoding; 
      binding.MaxReceivedMessageSize = Int32.MaxValue; 

サーバー構成に合わせて構成を複数に変更しようとしました。しかし、運がない。

+0

エラーメッセージは、mtomコンテンツタイプ(multipart/related)がサービスでサポートされていないというエラーメッセージが表示されます。コードで構成されたバインディングでmtomを指定する必要があると思われるのはなぜですか? – MattC

+0

私はあなたのためだと思う[WCFエラー:クライアントとサービスのバインディングが不一致かもしれません](http://stackoverflow.com/questions/2887776/wcf-error-the-client-and-service-bindings-may-be - ミスマッチ)それが助けてくれることを願っています。 –

+0

http://stackoverflow.com/questions/2887776/wcf-error-the-client-and-service-bindings-may-be-mismatched助けてくれると助かります –

答えて

0

メッセージのエンコード設定をMTOMに変更しようとしましたか? IMHO、私はあなたが頭痛の多くを与えるので、あなたは両方の設定ファイルとプログラムでWCFサービスを設定するために使用すべきではないと思います。私は1つに固執することをお勧めします、どちらかの設定ファイルかプログラムによって。

+0

上記のコードで私はこれを述べました。 binding.MessageEncoding = WSMessageEncoding.Mtom; – Pradeep

+0

私はそれが設定ファイルにあるべきであると言及しなかった。 – jtabuloc

+0

は、私は、最新の構成を有していて、 <セキュリティモード= "TransportWithMessageCredential" /> <= messageEncoding = "MTOM" "CoreSoapBinding" バインディング名> <エンドポイントアドレス= "https://でURL_OF_Service /" 結合= "customBinding" bindingConfiguration = "CoreSoapBinding" 契約= "ContractName" 名= "CoreSoapPort" /> Pradeep

0

バインディングの不一致によりエラーが発生します。 サーバーバインディングはBasicHttpBindingで、クライアントはCustomBindingです。あなたのサービスとして

BasicHttpBindingを使用している、同じ結合を使用してクライアントを構成しようとする、しかし、あなたはSOAP12を使用したい場合は、CustomBinding、このようなものとして、サーバー側を設定する必要があります。

CustomBinding binding = new CustomBinding(); 
      SymmetricSecurityBindingElement ssbe = 
       SecurityBindingElement.CreateSspiNegotiationBindingElement(true); 
      // Add the SymmetricSecurityBindingElement to the BindingElementCollection. 
      binding.Elements.Add(ssbe); 
      binding.Elements.Add(new TextMessageEncodingBindingElement()); 
      binding.Elements.Add(new HttpTransportBindingElement()); 

あなたはもっとここで読むことができます。https://msdn.microsoft.com/en-us/library/ms730305%28v=vs.110%29.aspx

はそれがお役に立てば幸いです。

関連する問題