views:

145

answers:

1

Hi, everybody!

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"&gt;
  <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?

A: 

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

Ulve
and: http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializernamespaces.add.aspx
Ulve
-1 since he said he did _not_ want namespaces. You and I both know that's a bad idea, but it's what he wants, and maybe flex is too dumb to deal with namespaces.
John Saunders