If you need to remove the references to “http://tempuri.org” from the WSDL of your web service, the following are the steps to do so:
The above three points will make all the references to “tempuri.org” disappear from the WSDL contract of the service (i.e. http://localhost/MyService.svc?wsdl).
References: eliminating http://tempuri.org in wsdl (link), wsdl:import namespace (link)
- Add [ServiceContract(Namespace = "MyContractNamespace")] to the Interface definition. Example:
[ServiceContract(Namespace = "MyContractNamespace")] public interface ITest { [OperationContract] string Echo(string str); }
- Add [ServiceBehavior(Namespace = "MyServiceNamespace")] to the service implementation. Example:
[ServiceBehavior(Namespace = "MyServiceNamespace")] public class Service : ITest { public string Echo(string str) { return str; } }
- Add bindingNamespace=”MyServiceNamespace” to each endpoint definition in the Web.config file. Example:
<endpoint contract="ITest" binding="wsHttpBinding" address="" bindingNamespace="MyServiceNamespace">
The above three points will make all the references to “tempuri.org” disappear from the WSDL contract of the service (i.e. http://localhost/MyService.svc?wsdl).
References: eliminating http://tempuri.org in wsdl (link), wsdl:import namespace (link)
1 comment:
Helpful post. In the above for the binding example, the attribute name should be bindingNamespace (case sensitive).
Post a Comment