type tipo the respuesta pero not mensaje iscontenttypesupported esperaba encontrĂ³ does content contenido coincide cliente charset wcf types response message

wcf - tipo - iscontenttypesupported



WCF charset=utf-8 del mensaje de respuesta no coincide con el tipo de contenido del enlace(application/soap+xml; charset=utf-8) (7)

Como sospechaba, su configuración del lado del cliente se ve así:

<endpoint name="WSHttpBinding_ICommAccountingBinding" address="https://secure.inmatecanteen.com/CommAccountingService/CommAccountingWeb.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IInmateCanteenServiceWeb" contract="CommAccountingWeb.ICommAccountingWeb" />

Espera wsHttpBinding , pero la dirección del servidor al que se conecta es:

<service name="CommAccountingWeb.CommAccountingWeb" behaviorConfiguration="HttpMexBehavior"> <endpoint address="" behaviorConfiguration="httpBehavior" binding="webHttpBinding" bindingConfiguration="myWebHttpBinding" contract="CommAccountingWeb.ICommAccountingWeb" /> <host> <baseAddresses> <add baseAddress="https://secure.inmatecanteen.com/CommAccountingService/CommAccountingWeb.svc"></add> </baseAddresses> </host> </service>

y este punto final del servidor usa webHttpBinding .

Entonces, mientras el cliente espera un mensaje XML SOAP (tipo de contenido: application/soap+xml; charset=utf-8 ), el punto final del lado del servidor es un punto final REST que devuelve XML simple (tipo de contenido: application/xml; charset=utf-8 )

Solución: ¡debe asegurarse de que tanto el cliente como el punto final del servidor estén sincronizados con los enlaces y la configuración!

Estoy alojando un servicio WCF en IIS 7.5 usando .NET 4.0. También tengo una aplicación WPF que estoy usando como cliente que fue desarrollada con Visual Studio 2010 y .NET 4.0. Agregué mi referencia de servicio y cuando intento llamar a una función, obtengo la siguiente excepción

El tipo de contenido application / xml; charset = utf-8 del mensaje de respuesta no coincide con el tipo de contenido del enlace (application / soap + xml; charset = utf-8)

Puedo navegar al servicio en un navegador web y mis enlaces parecen ser los mismos entre el cliente y el servicio (enlaces WsHttp).

Sé que hay muchos resultados de Google sobre este error, pero ninguno de ellos parecía ser relevante / ayuda a mi problema específico. Intenté instalar funciones de Activación que no sean HTTP, así como una gran variedad de otros pequeños trucos. ¿Alguien puede ayudar? Gracias

editar, aquí están mis configuraciones (son bastante largas)

Cliente

<?xml version="1.0"?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="ContentSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> <binding name="OrderSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> <netTcpBinding> <binding name="NetTcpBindingEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147000000" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="2147000000"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:01:00" enabled="true" /> <security mode="None"> <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> <message clientCredentialType="Windows" /> </security> </binding> </netTcpBinding> <wsHttpBinding> <binding name="WSHttpBinding_IInmateCanteenServiceWeb" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="Transport"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint name="ContentSoap" address="http://media.team.twvending.net/storeservices/content.asmx" binding="basicHttpBinding" bindingConfiguration="ContentSoap" contract="MediaPortContent.ContentSoap" /> <endpoint name="OrderSoap" address="http://media.team.twvending.net/storeservices/order.asmx" binding="basicHttpBinding" bindingConfiguration="OrderSoap" contract="MediaPortOrder.OrderSoap" /> <endpoint name="NetTcpBindingEndpoint" address="..." binding="netTcpBinding" bindingConfiguration="NetTcpBindingEndpoint" contract="WebCallBack.ICallbackService" /> <endpoint name="WSHttpBinding_IInmateCanteenServiceWeb" address="..." binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IInmateCanteenServiceWeb" contract="InmateCanteenWeb.IInmateCanteenServiceWeb" /> <endpoint name="WSHttpBinding_ICommAccountingBinding" address="..." binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IInmateCanteenServiceWeb" contract="CommAccountingWeb.ICommAccountingWeb" /> </client> </system.serviceModel>

y Servidor

<system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="httpBehavior"> <!--<webHttp />--> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceCredentials> <clientCertificate> <authentication revocationMode="NoCheck" /> </clientCertificate> <serviceCertificate findValue="CN=secure.inmatecanteen.com" /> </serviceCredentials> <serviceMetadata httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> <behavior name="MexBehavior"> <serviceMetadata httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> <behavior name="HttpMexBehavior"> <serviceMetadata httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> <behavior name="BasicHttpMexBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> <behavior name=""> <serviceMetadata httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" /> <bindings> <wsHttpBinding> <binding name="myWsHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> </wsHttpBinding> <webHttpBinding> <binding name="myWebHttpBinding"> <security mode="Transport"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> </security> </binding> </webHttpBinding> <basicHttpBinding> <binding name="myBasicHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding> </bindings> <services> <service name="CommAccountingWeb.CommAccountingWeb" behaviorConfiguration="HttpMexBehavior"> <endpoint address="" behaviorConfiguration="httpBehavior" binding="webHttpBinding" bindingConfiguration="myWebHttpBinding" contract="CommAccountingWeb.ICommAccountingWeb" /> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="..."></add> </baseAddresses> </host> </service> <service name="CommAccountingWeb.CommAccountingBasic" behaviorConfiguration="BasicHttpMexBehavior"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBasicHttpBinding" contract="CommAccountingWeb.ICommAccountingBasic" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="..." /> </baseAddresses> </host> </service> </services> </system.serviceModel>


Obtuve este problema después de agregar un método que devolvía una colección de instancias de una clase base que no tenía un atributo [KnownType] que se resolviera en una instancia concreta. Con el atributo [KnownType] en su lugar, el problema desapareció.

[ServiceContract] public interface IService { [OperationContract] IEnumerable<ItemBase> GetItems(); } [DataContract] // [KnownType(typeof(RealItemA))] <--- without these attributes you will get a problem // [KnownType(typeof(RealItemB))] public class ItemBase { } [DataContract] public class RealItemA : ItemBase { } [DataContract] public class RealItemB : ITemBase { }


en mi caso el mismo error fue causado por la falta

[datacontract] [datamember]

atributos en el tipo de datos devuelto.

El mensaje de error fue realmente engañoso.


Me encontré con un error similar al crear un servicio al cliente a uno de los servidores web existentes del lado del servidor. Podría rectificarlo usando el protocolo de transporte SOAP 1.1 en el cliente. De alguna manera, soap 1.2 está dando / esperando un formato diferente. Este rastro vuelve a la diferencia entre BasicHttpBinding vs WebHttpBinding vs WsHttpBinding.


Asegúrese de que no haya realizado cambios en los enlaces, contratos y puntos finales generados en app.config al agregar la referencia del servicio.

Agregue MessageEncoding como Mtom en el código .NET y luego verifique si aún recibe el mensaje.

He intentado explicar la creación de un consumo del servicio wcf usando el protocolo soap para wshttpbinding y basichttpbinding y los problemas que se presentan aquí: http://www.writeulearn.com/consume-wcf-soap-service-csharp/. Por favor revise.


Como dice uno de los comentarios en esta pregunta , agregue ?wsdl a la dirección del punto final de su cliente, y debería tener más suerte con el servicio. ?wsdl es importante, significa que el navegador acaba de obtener el "Lenguaje de descripción de servicios web" para el servicio y no llama al servicio.

Tuve el mismo problema y ?wsdl resolvió mi dolor de cabeza.


Tengo este error debido a la versión diferente de Syste.Web.MVC DLL. Puede referir la respuesta aquí en otra pregunta de desbordamiento de pila.