none
HttpGetEnabled property

    Question

  • hi,

    I am developing some project including wcf service. I am getting some error while i host my service in IIS 5.1
    Please, Help me through this.

    The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address.  Either supply an http base address or set HttpGetUrl to an absolute address.


    my web.config file is


        <system.serviceModel>
            <services>
                <service behaviorConfiguration="ServiceBehavior" name="wcfservice.Service1">
                    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsBinding" contract="wcfservice.IService1">
                        <identity>
                            <dns value="localhost"/>
                        </identity>
                    </endpoint>
                    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
                </service>
            </services>
            <bindings>
                <wsHttpBinding>
                    <binding name="wsBinding">
                        <security mode="Transport"/>
                    </binding>
                </wsHttpBinding>
            </bindings>
            <behaviors>
       <serviceBehaviors>
        <behavior name="ServiceBehavior">
         <serviceMetadata httpGetEnabled="true"
          policyVersion="Default" />
         <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
       </serviceBehaviors>
      </behaviors>
        </system.serviceModel>

    please,help me.
    Thanx in advance,

    Saurabh
    Friday, April 24, 2009 5:11 PM

Answers

  • Hi Saurabh,

    you're using the transport security along with the wsHttpBinding, the primary mechanism for securing the transport is SSL over HTTP, i.e. HTTPS. You can either set up HTTPS, change the security mode or change the binding, whatever suits you more.

    Regards,
    John

    • Marked as answer by amolsaurabh Friday, April 24, 2009 7:39 PM
    Friday, April 24, 2009 6:56 PM

All replies

  • Hi Saurabh,

    try this:

    <serviceBehaviors>
        <behavior name="ServiceBehavior">
            <serviceMetadata httpGetEnabled="true" httpGetUrl="[service address]" />
        </behavior>
    </serviceBehaviors>

    Did it do the trick?

    Regards,
    John
    Friday, April 24, 2009 5:38 PM
  • hi john

    I did it,service get loaded.but when i tried to test it using testwcfclient tool. It says


    Failed to invoke the service. The service may be offline or inaccessible. Refer to the stack trace for details.


    An error occurred while making the HTTP request to https://saurya/iiswcf/MyService.svc. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.


    Do you have any clue what is this?

    Thanks and regards.

    Saurabh
    Friday, April 24, 2009 6:01 PM
  • Hi Saurabh,

    you're using the transport security along with the wsHttpBinding, the primary mechanism for securing the transport is SSL over HTTP, i.e. HTTPS. You can either set up HTTPS, change the security mode or change the binding, whatever suits you more.

    Regards,
    John

    • Marked as answer by amolsaurabh Friday, April 24, 2009 7:39 PM
    Friday, April 24, 2009 6:56 PM
  • Hi john,

    Thanx for the help,

    It worked..  i had to make certain changes in web.config file

    It becomes


    <?xml version="1.0"?>
    <!--
        Note: As an alternative to hand editing this file you can use the
        web admin tool to configure settings for your application. Use
        the Website->Asp.Net Configuration option in Visual Studio.
        A full list of settings and comments can be found in
        machine.config.comments usually located in
        \Windows\Microsoft.Net\Framework\v2.x\Config
    -->
    <configuration>
        <system.serviceModel>
           
      <services>
       <service behaviorConfiguration="ServiceBehavior" name="wcfservice.Service1">
        <endpoint address="http://192.168.1.2/iiswcf/MyService.svc" binding="basicHttpBinding"
         contract="wcfservice.IService1">
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
       </service>
      </services>
            <bindings>
       <!--<basicHttpBinding>
         <binding name="basicbinding" >
           <security mode="Transport">
           </security>
         </binding>
       </basicHttpBinding>-->
       <!--<wsHttpBinding>
        <binding name="wsBinding">
         <security mode="None" />
        </binding>
       </wsHttpBinding>-->
      </bindings>
            <behaviors>
       <serviceBehaviors>
        <behavior name="ServiceBehavior">
         <serviceMetadata httpGetEnabled="true" httpGetUrl="http://192.168.1.2/iiswcf/MyService.svc"
          httpsGetEnabled="false" policyVersion="Default" />
         <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
       </serviceBehaviors>
      </behaviors>
        </system.serviceModel>
        <system.web>
            <compilation debug="true"/></system.web></configuration>


    Thanks again for the help
    Friday, April 24, 2009 7:39 PM
  • You're more than welcome!

    Regards,
    John
    Friday, April 24, 2009 7:44 PM
  • No idea of what the syntax could be, trough C# code?

     

    The following does not work  (  Invalid URI: The format of the URI could not be determined.  , at the [service address] line )

     

    using System;
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    using System.ServiceModel.Description;
    
    
    namespace ConsoleWCFAllInOne
    {
        sealed class HelloWCF : IHelloWCF
        {
            static void Main()
            {   
                Uri address = new Uri("http://localhost:/IHelloWCF");
                BasicHttpBinding binding = new BasicHttpBinding();
                ServiceHost svc = new ServiceHost(typeof(HelloWCF));
    
                // service
                svc.AddServiceEndpoint(typeof(IHelloWCF), binding, address);
                svc.Open();
                Console.WriteLine("The HelloWCF receiving application is ready.");
    
                // metadata
                ServiceMetadataBehavior metadata = new ServiceMetadataBehavior();
                metadata.HttpGetEnabled = true;
                svc.Description.Behaviors.Add(metadata);
                Binding mexBinding = MetadataExchangeBindings.CreateMexTcpBinding();
                Uri mexAddress = new Uri("[service address]");
                svc.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, mexAddress);
    
    
    
    
    
                // client
                ChannelFactory<IHelloWCF> factory = new ChannelFactory<IHelloWCF>(binding, new EndpointAddress(address));
                IHelloWCF proxy = factory.CreateChannel();
                proxy.Say("Hi there, WCF.");
    
                // wait to close the program
                Console.ReadLine();
                svc.Close();
            }
    
            public void Say(String input)
            {
                Console.WriteLine("Message received, the body contains: {0}", input);
            }
        }
    
        [ServiceContract]
        public interface IHelloWCF
        {
            [OperationContract]
            void Say(String input);
        }
    
    }
    

     

     

    Monday, October 24, 2011 3:44 PM
  • Got my answer: the end point address of the service left blank (to indicate that it is the same as the service host) and the mex end point address set to "mex"  makes a winning combination, in code. (Note that in the supplied code, I open the service too soon, and it generates an error).
    Monday, October 24, 2011 8:26 PM