2012-08-10 17 views
7

Ajax Llamar:500 System.ServiceModel.ServiceActivationException al realizar una llamada Ajax para el servicio WCF resto

$.ajax({ 
     type: "POST", 
     url: "http://SomeService/ServiceName.svc/GetSearchResults", 
     data: JSON.stringify({ parameters: serviceParameters }), 
     contentType: "application/json; charset=utf-8", 
     dataType: "XML", 
     success: function (response) { 
      $("#xmlText").text(response.xml); 
     }, 
     error: function (msg) { 
      alert(msg.toString); 
     } 
    }) 

WCF Interfaz:

[OperationContract] 
     [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Json, 
        UriTemplate = "GetSearchResults")] 
     XElement GetSearchResults(inputParameters parameters); 

     [OperationContract] 
     [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate = "getFile")] 
     Stream GetFile(DocInfo info); 

Web.config:

<system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <customErrors mode="Off"/> 
    </system.web> 

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"> 
    </serviceHostingEnvironment> 
    <standardEndpoints> 
    <webHttpEndpoint> 
     <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint> 
    </webHttpEndpoint> 
    </standardEndpoints> 
</system.serviceModel> 

El el servicio está alojado en IIS6.

Cuando llamo el servicio me sale el siguiente mensaje de error:

500 System.ServiceModel.ServiceActivationException 

puedo llamar al método GetFile y obtener la secuencia de respuesta pero me sale el mensaje de error al llamar GetSearchResults.

Cualquier ayuda será apreciada.

+0

Sugeriría que habilite el rastreo (http://msdn.microsoft.com/en-us/library/ms733025.aspx) e inspeccione el registro de seguimiento para conocer el problema exacto al intentar invocar el método GetSearchResults – Rajesh

Respuesta

9

me encontré con este error por la razón mencionada a continuación

puertas de la memoria ha fallado la comprobación porque la memoria libre (258187264 bytes) es inferior al 5% del total de la memoria. Como resultado, el servicio no estará disponible para solicitudes entrantes. Para resolver esto, reduzca la carga en la máquina o ajuste el valor de minFreeMemoryPercentageToActivateService en el elemento de configuración serviceHostingEnvironment.

+3

I pude confirmar que este era mi problema al buscar errores en mi registro de eventos de Windows (aplicación). Actualizando la web.config para establecer minFreeMemoryPercentageToActivateService = "0" arregló el problema. – NorthFork

+0

Sin embargo, necesita plena confianza (privilegios de administrador) en su máquina para que funcione minFreeMemoryPercentageToActivateService. –

0

Muchas gracias por sus inspiradas respuestas y comentarios.

De hecho, me encontré con el mismo error pero con diferente historia:

Al principio, me "404 (no encontrado)" error de servidor, que se debe a que no tenía un transporte para "HTTPS", así como Ya tengo uno para el "HTTP".

he añadido un <httpsTransport> a mi elemento <binding>, por lo que se veía así:

<bindings> 
    <customBinding> 
    <binding name="CustomBinding_ITheService"> 
     <httpTransport keepAliveEnabled="True" transferMode="Streamed" authenticationScheme="None" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" manualAddressing="true" /> 
     <httpsTransport keepAliveEnabled="True" transferMode="Streamed" authenticationScheme="None" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" manualAddressing="true" /> 
    </binding> 
    </customBinding> 
</bindings> 

Entonces tuve el error 500 System.ServiceModel.ServiceActivationException. Sin embargo, navegué por "Visor de eventos> Registro de Windows> Aplicación" y descubrí que "los transportes no pueden definirse más de una vez para el mismo enlace". Entonces, decidí agregar un punto final adicional con un nuevo enlace para el transporte "HTTPS".

Al final, mi configuración tiene el siguiente aspecto:

<services> 
    <service name="TheService" behaviorConfiguration="WebHttpBehavior_ITheService"> 
    <endpoint binding="customBinding" bindingConfiguration="CustomBinding_ITheService" contract="ITheService" behaviorConfiguration="EndPointBehavior_ITheService" /> 
    <endpoint binding="customBinding" bindingConfiguration="CustomBinding_ITheService_Secured" contract="ITheService" behaviorConfiguration="EndPointBehavior_ITheService" /> 
    </service> 
</services> 

<bindings> 
    <customBinding> 
    <binding name="CustomBinding_ITheService"> 
     <httpTransport keepAliveEnabled="True" transferMode="Streamed" authenticationScheme="None" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" manualAddressing="true" /> 
    </binding> 
    <binding name="CustomBinding_ITheService_Secured"> 
     <httpsTransport keepAliveEnabled="True" transferMode="Streamed" authenticationScheme="None" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" manualAddressing="true" /> 
    </binding> 
    </customBinding> 
</bindings> 

Entonces cada cosas va por el camino correcto y funciona perfectamente.

En caso de que se desarrollan en estudio visual y utiliza IIS-Express "Cassini", recuerda opción SSL en las propiedades de la página web en proyectos, que le dice a IIS-Express para permitir a preparar una URL base para el HTTPS transporte que ha agregado anteriormente al enlace.

Cuestiones relacionadas