none
eliminating http://tempuri.org in wsdl

    Question

  • Hi,

     

    I have my service defined properly and provided namespace on contract and serviceBehavior attribute still I am getting reference of tempuri.org in the WSDL generated. Can someone tell me how can I remove this reference of tempuri.org from my WSDL.

     

    <wsdlBig Smileefinitions name="CountryService" targetNamespace=http://www.XXX.com/XXX/xxxxxxxxmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlnsTongue Tiedoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlnsTongue Tiedoapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.sungard.com/adaptiv/masterfiles" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://tempuri.org/" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlnsTongue Tiedoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
      <wsdl:import namespace="http://tempuri.org/" location=http://localhost:4040/xxxx/CountryService.svc?wsdl=wsdl0 />
     
    If I don't define namespace in [ServiceBehavior(Namespace = http://www.XXX.com/XXX/xxxxxxxx)], I get targetNamespace="http://tempuri.org" in <wsdlBig Smileefinition Tag
     
    Please help.
     
    Thanks in advance
    Monday, August 20, 2007 6:43 PM

Answers

  •  

    There are three places for simple services where the default namespace is tempuri.org: the contract, the behavior, and the binding. If you replace the namespace on all three, tempuri.org should disappear from your wsdl. The WSDL of the service below doesn't have it.

     

    public class TempuriOrg

    {

        [ServiceContract(Namespace = "MyContractNamespace")]

        public interface ITest

        {

            [OperationContract]

            string Echo(string str);

        }

        [ServiceBehavior(Namespace = "MyServiceNamespace")]

        public class Service : ITest

        {

            public string Echo(string str)

            {

                return str;

            }

        }

        public static void Main()

        {

            string baseAddress = "http://localhost:8000/Service";

            ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));

            BasicHttpBinding binding = new BasicHttpBinding();

            binding.Namespace = "MyBindingNamespace";

            host.AddServiceEndpoint(typeof(ITest), binding, "");

            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();

            smb.HttpGetEnabled = true;

            host.Description.Behaviors.Add(smb);

            host.Open();

            Console.WriteLine("WSDL address: " + baseAddress + "?wsdl");

            Console.Write("Press ENTER to close");

            Console.ReadLine();

            host.Close();

        }

    }

     

    Monday, August 20, 2007 7:09 PM

All replies

  •  

    There are three places for simple services where the default namespace is tempuri.org: the contract, the behavior, and the binding. If you replace the namespace on all three, tempuri.org should disappear from your wsdl. The WSDL of the service below doesn't have it.

     

    public class TempuriOrg

    {

        [ServiceContract(Namespace = "MyContractNamespace")]

        public interface ITest

        {

            [OperationContract]

            string Echo(string str);

        }

        [ServiceBehavior(Namespace = "MyServiceNamespace")]

        public class Service : ITest

        {

            public string Echo(string str)

            {

                return str;

            }

        }

        public static void Main()

        {

            string baseAddress = "http://localhost:8000/Service";

            ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));

            BasicHttpBinding binding = new BasicHttpBinding();

            binding.Namespace = "MyBindingNamespace";

            host.AddServiceEndpoint(typeof(ITest), binding, "");

            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();

            smb.HttpGetEnabled = true;

            host.Description.Behaviors.Add(smb);

            host.Open();

            Console.WriteLine("WSDL address: " + baseAddress + "?wsdl");

            Console.Write("Press ENTER to close");

            Console.ReadLine();

            host.Close();

        }

    }

     

    Monday, August 20, 2007 7:09 PM
  • Hi,

    Please have a look here on how to do this:


    Best regards,

    Alen
    • Edited by MisterY Saturday, June 06, 2009 4:36 AM added url reference
    Saturday, June 06, 2009 4:35 AM
  • Works superbly

    Regards

    peter

    Friday, November 04, 2011 9:11 AM
  • Also see http://www.c-sharpcorner.com/Forums/Thread/108822/get-rid-of-tempuri-in-wsdl.aspx if you have multiple services with explicit names. (The service implementation needs to name the service's configuration name in its ServiceBehavior ConfigurationName property)
    Tuesday, January 01, 2013 5:04 PM