简体   繁体   English

webservices 更改 ASMX Web 服务返回的命名空间前缀

[英]webservices change namespace prefix of ASMX Web Service Return

I am creating webservices and using an overall namespace:我正在创建 web 服务并使用一个整体命名空间:

[WebService(Namespace = "www.abcdef.com")]

when I ask for wsdl it gives me the namespace like xmlns:abc="www.abcdef.com"当我要求 wsdl 它给了我像xmlns:abc="www.abcdef.com"这样的命名空间

I would like to change the abc prefix to something else.我想将abc前缀更改为其他内容。 Is there a way to change it?有没有办法改变它?

Untested but give it a shot:未经测试,但试一试:

[WebService(Namespace = "http://mynamespace/")]
public class Service1 : System.Web.Services.WebService
{
            [XmlNamespaceDeclarations]
            public XmlSerializerNamespaces xmlns
            {
                get
                {
                    XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
                    xsn.Add("me", "http://mynamespace/");
                    return xsn;
                }
                set { /* needed for xml serialization */ }
            }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM