开发者

Remove namespace from WebService

开发者 https://www.devze.com 2022-12-20 00:26 出处:网络
I have a .Net web services that are called from flex. Our programmer receives the following xml when calling web service function:

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消