locked
WCF Namespace RRS feed

  • Question

  • User-221752185 posted

    I am kind of keen to just leave http://tempuri.org as the namespace. Does the namespace need to be an actual URL like http://srvs.mycompany.com/api/ ? If its running under SSL, then it should be https. If not, then it should be http. Thinking of making the namespace to be srvs.mycompany.com/api instead for this reason. How is others handling the problem?

    Also, in order to remove tempuri.org, you have to define the namespace at the contract, the service and in the configuration. Then for every datacontract defined. If those datacontracts are shared across multiple domains, how do you handle that? For instance, srvs.mycompany.ie/api  and srvs.mycompany.co.uk/api

    Any help would be appreciated. Please consider all my questions.

    Monday, May 6, 2013 4:54 PM

Answers

All replies

  • User-837620913 posted

    No need for SSL. And there does not need to be anything at the URL. The idea behind using your company's URL in the XML namespace is to ensure it is unique.

    Here's a little bit on XML Namespaces from this guide:

      • The URLs are usually used as addresses in internet. URL in XML namespace works mostly as a global unique identifier, not as an address.
      • Note the reverse names order in typical URLs, for example, not the http://com.company.domain but http://domain.company.com. If you don’t want to use XML namespaces that looks like the web addresses, consider to use the XML namespaces in the generic, nonreversible, sortable order
      • URLs are case-sensitive (Yes, they are!) You can use the upper case letters in XML namespaces, but make sure you are consistent with it.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2013 5:40 AM
  • User-221752185 posted

    Hi Darrell, thanks for your response.

    The WCF is hosted under SSL, so I would imagine that you would want the namespaces to reflect https. Otherwise browsers will flag that the document contains some non-secure elements.

    http://com.company.domain  is an interesting suggestion. However, I still have the same issue in the sense that for my .IE webservice and .co.uk webservice,  will have "com" in the namespace instead of "ie" or "co.uk".

    Tuesday, May 7, 2013 5:55 AM
  • User260886948 posted

    Hi,

    If you wan to change the wcf namespace in rid of the http://tempuri.org , you should do the following steps:

    - Apply the Namespace property to the ServiceContractAttribute on the service contract interface 
    - Apply the Namespace property to the ServiceBehaviorAttribute on the class that implements the service 
    - Apply the Namespace property to the DataContractAttribute on every class that is involved with the service (parameters, return values) 
    - Change the namespace for the binding, either on the binding class or in the .config file 

    For more details, please try to refer to:
    http://rebuildall.umbraworks.net/2010/11/10/WCF_service_namespaces .

    Here are some similar threads:

    http://www.c-sharpcorner.com/Forums/Thread/108822/get-rid-of-tempuri-in-wsdl.aspx
     .

    http://social.msdn.microsoft.com/forums/en-US/wcf/thread/5573326a-21b3-4d21-b05c-8e00b1674137/ .

    Hope it can help you.

    Best Regards,
    Amy Peng 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 14, 2013 3:53 AM