.NET Framework Bookmark and Share   
 index > ASMX Web Services and XML Serialization > Web Service Soap extension , how set attribute
 

Web Service Soap extension , how set attribute

How canI set soap extension attribute on client side:
For example:

Code on service side:

[AttributeUsage(AttributeTargets.Method)]
    public class EncryptMessageAttribute : SoapExtensionAttribute
    {
        private string[] xPathExpressionArray = new string[] {
        "/soap:Envelope"};

        public string StrKey
        {
            get { 
                return strKey; 
                }
            set { 
                strKey = value; 
                }    
        }

        public override Type ExtensionType
        {
            get
            {
                return typeof(EncryptMessage);
            }
        }

        public override int Priority
        {
            get
            {
                return 0;
            }
            set
            {
            }
        }

        public string XPathEncryption
        {
            get
            {
                StringBuilder sb = new StringBuilder();
                foreach (string query in xPathExpressionArray)
                {
                    sb.Append(query);
                    sb.Append(',');
                }
                return sb.ToString(0, sb.Length - 1);
            }
            set
            {
                xPathExpressionArray = value.Split(',');
            }
        }

        internal string[] XPathExpressionArray
        {
            get
            {
                return xPathExpressionArray;
            }
        }
    }
Soap extension class:
public class EncryptMessage : SoapExtension
{
...
}
Implementation in proxy class:

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/test", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[EncryptMessage(XPathEncryption = "//soap:Body/*/*", StrKey = "pass")]
public string test() {
object[] results = this.Invoke("test", new object[0]);
return ((string)(results[0]));
}



Soap extension attributes are:[EncryptMessage(XPathEncryption = "//soap:Body/*/*", StrKey = "pass")]

I can not call methods from class EncryptMessageAttribute : SoapExtensionAttribute in proxy class on client side . I want set soap attributes on server side and client side before I use soap extension in web methodos. Example: I call some method, wich set soap extension attributes on both side, before than soap extension is used. Can somebody help me ?
klerik123456
Are you asking how you can make your custom SoapExtension attribute appear automatically in the client's generated code?

I don't believe that's possible.
-steve
Brain.Save() -- http://hyperthink.net/blog
Steve Maine

You can use google to search for other answers

Custom Search

More Threads

• system.xml.serialization - Server side dynamic serialization
• Editing a MembershipUser without changing it’s logged on status or updating its last Activity date?
• Web Service Question
• Making WSE3 behave like WSE2 from client point of view
• Problem building C# Client consuming Java Web Service
• Private fields in a web service
• add web reference Error The remote server returned an error: (403) Forbidden.
• AJAX 6.10.6.2 and SSL
• WD2005(cs) ASP.net Security -Automatically activate user/account??
• decide at runtime whether to serialize a member?