2012-01-06 17 views
6

ok, il mio file ha questa struttura.wcf file web.config

<system.serviceModel> 
    <services> 
     <service name="ManyaWCF.ServiceManya" behaviorConfiguration="ServiceBehaviour"> 
      <!-- Service Endpoints --> 
      <!-- Unless fully qualified, address is relative to base address supplied above --> 
      <endpoint address="" binding="webHttpBinding" contract="ManyaWCF.IServiceManya" behaviorConfiguration="web"> 
       <!-- 
      Upon deployment, the following identity element should be removed or replaced to reflect the 
      identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
      automatically. 
     --> 
      </endpoint> 
     </service> 

    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="ServiceBehaviour"> 
       <!-- 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="web"> 
       <webHttp /> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

ho ottenuto lo stesso web.config in un altro wcf e ho lavorato come un champ, ofc con diverse cartelle e file. la mia struttura di cartelle è la seguente.

enter image description here

Quando provo a giocare ottengo questo,

Service 

This is a Windows © Communication Foundation. 

The metadata publishing for this service is currently disabled. 

If you access the service, you can enable metadata publishing by completing the following steps to modify the configuration file or web application: 

1. Create the following service behavior configuration, or add the item to a configuration <serviceMetadata> existing service behavior: 

<behaviors> 
<serviceBehaviors> 
    <behavior name="MyServiceTypeBehaviors"> 
     httpGetEnabled="true" <serviceMetadata /> 
    </ Behavior> 
</ ServiceBehaviors> 
</ Behaviors> 
2. Add the behavior configuration to the service: 

    name="MyNamespace.MyServiceType" <service behaviorConfiguration="MyServiceTypeBehaviors"> 
    Note: The service name must match the name of the configuration for the service implementation. 

3. Add the following to end service configuration: 

binding="mexHttpBinding" contract="IMetadataExchange" <endpoint address="mex" /> 
Note: the service must have an http base address to add this. 

Here is an example of a service configuration file with metadata publishing enabled: 

<configuration> 
<system.serviceModel> 

    <services> 
     <! - Note: the service name must match the name of the configuration for the service implementation. -> 
     name="MyNamespace.MyServiceType" <service behaviorConfiguration="MyServiceTypeBehaviors"> 
      <! - Add the following end. -> 
      <! - Note: the service must have an http base address to add this. -> 
      binding="mexHttpBinding" contract="IMetadataExchange" <endpoint address="mex" /> 
     </ Service> 
    </ Services> 

    <behaviors> 
     <serviceBehaviors> 
      <behavior name="MyServiceTypeBehaviors"> 
       <! - Add the following item to the service behavior configuration. -> 
       httpGetEnabled="true" <serviceMetadata /> 
      </ Behavior> 
     </ ServiceBehaviors> 
    </ Behaviors> 

</ System.serviceModel> 
</ Configuration> 

    For more information about publishing metadata, see the following documentation: http://go.microsoft.com/fwlink/?LinkId=65455 (may be in English). 

così, ho fatto solo 1 WCF e ha lavorato bene con lo stesso web.conif. La mia fortuna di exp e conoscenza di questo mi sta uccidendo. Qualche idea?

Thx in anticipo.

risposta

4

Per quanto ne so, è necessario solo l'endpoint con mexHttpBinding se si desidera esporre il WSDL ai client. Visual Studio (o wcfutil.exe) richiede la descrizione WSDL per creare le classi client del servizio web.

Dopo aver creato queste classi client Webservice, non è necessario esporre più WSDL.

UPDATE: L'elemento <service> nel file di configurazione dovrebbe essere simile a questo:

<service name="ManyaWCF.ServiceManya" behaviorConfiguration="ServiceBehaviour"> 
    <endpoint address="" binding="webHttpBinding" 
     contract="ManyaWCF.IServiceManya" behaviorConfiguration="web" /> 

    <endpoint address="mex" binding="mexHttpBinding" 
     contract="IMetadataExchange" /> 
</service> 
+0

hmm. posso vedere mexhttpbinding sul codice. Non riesco a vedere se c'è qualcosa di sbagliato o ho bisogno di scoprire qualcosa –

+0

@Guillermo - Non vedo l'endpoint mex abilitato nel tuo file di configurazione. Forse il seguente articolo aiuta: http://blogs.msdn.com/b/brajens/archive/2007/04/26/accessing-description-metadata-wsdl-of-wcf-web-service.aspx –

+0

isnt it this, ?? –

-2
<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <httpRuntime maxRequestLength="1048576" executionTimeout="3600" /> 
    </system.web> 
    <appSettings> 
    </appSettings> 
    <connectionStrings> 
    <add name="SQLConnect" connectionString="Your_Connection_String";User id=sa;Password=welcome3#"/> 
    </connectionStrings> 
    <system.serviceModel> 
    <services> 
     <service name="WCFRestService.RestServiceSvc" behaviorConfiguration="serviceBehavior"> 
     <endpoint address="" bindingConfiguration="secureHttpBinding" binding="webHttpBinding" contract="WCFRestService.IRestServiceSvc" behaviorConfiguration="web"></endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="web"> 
      <webHttp /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="serviceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

    <bindings> 
     <webHttpBinding> 
     <binding name="secureHttpBinding" 
      maxBufferPoolSize="2147483647" 
      maxReceivedMessageSize="2147483647" 
      maxBufferSize="2147483647" transferMode="Streamed">  
     </binding> 
     </webHttpBinding> 
    </bindings> 

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <httpProtocol> 
     <customHeaders>  
     </customHeaders> 
    </httpProtocol> 
    <security> 
     <requestFiltering> 
     <requestLimits maxAllowedContentLength="1073741824" /> 
     </requestFiltering> 
    </security> 
    <directoryBrowse enabled="true" /> 
    </system.webServer> 
    <system.web.extensions> 
    <scripting> 
     <webServices> 
     <jsonSerialization maxJsonLength="50000000"/> 
     </webServices> 
    </scripting> 
    </system.web.extensions> 
</configuration> 
+0

La tua risposta, sebbene fornisca un esempio corretto, non aiuta a rispondere alla domanda OP. Consiglierei di fornire maggiori dettagli. – PseudoNinja

Problemi correlati