none
WCF service: everything ok in locally debug but does not work on production iis server RRS feed

  • Question

  • Hi all,I created my first WCF service and 2 client applications for its test: a Windows forms and a webapp, all in the same solution and everything running right on development.

    Now I have to go into production. I created an application on IIS server and published the service. Calling.svc file i see the informations Page. It seems ok but definitely not able to put in place the endpoints.

    I would use the service through domain name eg:auth.mio.it but if I try to point it from the web client does not see him,he complains that can not find the metadata. If I configure the connection to the service does not go because he expects his things in http: //localhost:8733/Design_Time_Addresses/TestWCF/Service1/mex and not on the server..:-(

    Not to mention to publish the webclient.

    I need to put order.Thank you

    this is the app.config

    <services>
          <service name="AuthWCF.Servizio">
            <endpoint address="" binding="basicHttpBinding" contract="AuthWCF.IServizio">
              <identity>
                <dns value="localhost" />
                <!--<dns value="auth.mio.it"/>-->
              </identity>
            </endpoint>
            <!--boh-->
            <!--<endpoint address="http://auth.mio.it/authwcf.servizio.svc" binding="basicHttpBinding" contract="AuthWCF.IServizio" />-->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8733/Design_Time_Addresses/TestWCF/Service1/" />
              <!--<add baseAddress="auth.mio.it/" />-->
              </baseAddresses>
            </host>
          </service>

        
    Friday, August 22, 2014 8:03 AM

Answers

  • Hi Emanuele,

    Based on  your description, when you try to use the service through domain, it complains "can not find the metadata". For this scenario, you could try to check the following in your config file:

    1) a service behavior for metadata:

    <behaviors>
      <serviceBehaviors>
         <behavior name="Metadata"> 
            <serviceMetadata httpGetEnabled="true" />
         </behavior>
      </serviceBehaviors>
    </behaviors>

    2) reference that service behavior in your service config

    <service name="wcfLib.StockService 
             behaviorConfiguration="Metadata">
         ....
    </service>

    3) an endpoint for MEX (metadata exchange)

    <service name="wcfLib.StockService 
             behaviorConfiguration="Metadata">
         ....
        <endpoint name="mex"
                  address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
    </service>

    Besides, before consuming the WCF service, you could try to add the IIS hosted service reference, use the address of the .svc file.

    For more detailed information, you could refer to:

    http://blogs.msdn.com/b/trobbins/archive/2006/11/27/how-to-hosting-a-wcf-service-in-iis.aspx

    http://www.codeproject.com/Articles/550796/A-Beginners-Tutorial-on-How-to-Host-a-WCF-Service

    Regards

    Monday, August 25, 2014 2:32 AM
    Moderator
  • Hi Lanza,

    1. Based on your config things, you should remove the identity node of the config file in production server. Otherwise you cant access the service outer world. I mean , from other domain servers you cant access the service what ever hosted in production IIS. If the application is running under same domain not an issue.

    2. you should add the below markup addtionaly in you config.

    <behaviors>
      <serviceBehaviors>
         <behavior name="Metadata"> 
            <serviceMetadata httpGetEnabled="true" />
         </behavior>
      </serviceBehaviors>
    </behaviors>

    Map the behavior name in to service node with name of behaviourconfiguration and check.


    prabakaran.M

    Thursday, August 28, 2014 5:19 AM

All replies

  • Hi Emanuele,

    Based on  your description, when you try to use the service through domain, it complains "can not find the metadata". For this scenario, you could try to check the following in your config file:

    1) a service behavior for metadata:

    <behaviors>
      <serviceBehaviors>
         <behavior name="Metadata"> 
            <serviceMetadata httpGetEnabled="true" />
         </behavior>
      </serviceBehaviors>
    </behaviors>

    2) reference that service behavior in your service config

    <service name="wcfLib.StockService 
             behaviorConfiguration="Metadata">
         ....
    </service>

    3) an endpoint for MEX (metadata exchange)

    <service name="wcfLib.StockService 
             behaviorConfiguration="Metadata">
         ....
        <endpoint name="mex"
                  address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
    </service>

    Besides, before consuming the WCF service, you could try to add the IIS hosted service reference, use the address of the .svc file.

    For more detailed information, you could refer to:

    http://blogs.msdn.com/b/trobbins/archive/2006/11/27/how-to-hosting-a-wcf-service-in-iis.aspx

    http://www.codeproject.com/Articles/550796/A-Beginners-Tutorial-on-How-to-Host-a-WCF-Service

    Regards

    Monday, August 25, 2014 2:32 AM
    Moderator
  • It can't be localhost. Localhost means the Loop Back IP, which means the traffic between the WCF client and service never leaves the local machine. It would be the development machine in this case. And yes, it would work in debug mode on your development machine, but it's not going to work if the WCF client is on some client machine, and the WCF service was on some remote machine.

    The WCF client has to know the IP of the machine on the Local Area Network or Wide Area Network (LAN) or (WAN) with WAN meaning the Internet in order for the WCF client to make contact with the machine hosting the WCF service.

    http://en.wikipedia.org/wiki/Localhost

    Monday, August 25, 2014 3:01 AM
  • Sorry but three points you've highlighted are already satisfied

    Could you make an example about 'Besides, before consuming the WCF service, you could try to add the IIS hosted service reference, use the address of the .svc file. ' ?

    Wednesday, August 27, 2014 11:40 AM
  • i've already a public ip/domain in use but i need to know the exact formulas to use.. when i publish on the server the WCF service i don't see a mex directory with _vti_bin/ListData.svc/$metadata that is looked for when i try to refresh the servicereference in vstudio for the client webapp

    Wednesday, August 27, 2014 11:44 AM
  • Hi Lanza,

    1. Based on your config things, you should remove the identity node of the config file in production server. Otherwise you cant access the service outer world. I mean , from other domain servers you cant access the service what ever hosted in production IIS. If the application is running under same domain not an issue.

    2. you should add the below markup addtionaly in you config.

    <behaviors>
      <serviceBehaviors>
         <behavior name="Metadata"> 
            <serviceMetadata httpGetEnabled="true" />
         </behavior>
      </serviceBehaviors>
    </behaviors>

    Map the behavior name in to service node with name of behaviourconfiguration and check.


    prabakaran.M

    Thursday, August 28, 2014 5:19 AM