Yaroslav Yakovlev
Yaroslav Yakovlev

Reputation: 6483

Remove namespace from WebService

I have a .Net web services that are called from flex. Our programmer receives the following xml when calling web service function:

<FunctionName xmlns="WSNamespace" 
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <FunctionName>Xml itself</FunctionName>

He would like to get all the same, but with no namespace as we do not need them. How can it be done on .Net part?

Upvotes: 1

Views: 3858

Answers (1)

Ulve
Ulve

Reputation: 309

Use

[WebService(Namespace = "")]

if you want no namespaces. But that is not the preferred way. Instead you can use the XmlNamespaceDeclaration to get a fully qualified namespace. Like this

[XmlNamespaceDeclarations]
public XmlSerializerNamespaces xmlns
{
   get
   {
      XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
      xsn.Add("me", "http://anamespace/");
      return xsn;
   }

   set 
   {
      // needed for serialization 
   }
}

Check out more info at: http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlnamespacedeclarationsattribute.aspx

Upvotes: 1

Related Questions