Pregunta

Así que creé una aplicación de servicio WCF y la alojé en IIS7. Actualmente tiene algunos métodos de prueba 'Helloworld'. Cuando lo ejecuto en mi navegador obtengo esta pantalla:enter image description here

Ahora el servicio en sí funciona muy bien, pero ¿cómo puedo mostrar las operaciones como esta?enter image description here

Gracias a Marc_S por el enlace: http://www.dotnetcurry.com/showarticle.aspx?id=399 que he seguido para que mi configuración web ahora esté configurada como:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfServer.Service1">
        <endpoint address="" binding="webHttpBinding" contract="WcfServer.IService1" behaviorConfiguration="HelpBehaviour" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 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="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="AjaxBehavior">
          <enableWebScript />
        </behavior>
        <behavior name="HelpBehaviour">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
        <directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension" />
  </system.webServer>
</configuration>

Sin embargo, esto solo funciona localmente. Cuando publico en mi servidor en IIS7, obtengo una página de error 404 cuando hago clic en el enlace de ayuda. ¿Alguien sabe por qué esto es o lo ha encontrado antes?

(El último bit se resolvió corriendo: aspnet_regiis.exe -iru)

¿Fue útil?

Solución

Si tiene un servicio WCF con un enlace de jabón, desafortunadamente no tiene suerte: no hay forma de estar en WCF fuera de la caja para obtener una lista similar a ASMX con todos los servicios.

Con un enlace de descanso (webHttpBinding) y .NET 4.0, puede tener una página de ayuda automática generada que enumera las plantillas de URI, los métodos HTTP admitidos, etc. También puede ajustar esa página hasta cierto punto.

Para generar esa página de ayuda automática, debe definir (y hacer referencia) un comportamiento de punto final:

<behaviors>
   <endpointBehaviors>
       <behavior name="HelpBehavior">
           <webHttp helpEnabled="true" />
       </behavior>
   </endpointBehaviors>
</behaviors>

Luego haga referencia a ese comportamiento de su webHttpBinding punto final, y terminaste.

Lee todos los detalles:

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top