.NET Framework Bookmark and Share   
 index > ASMX Web Services and XML Serialization > SoapExtensionAttribute , SoapExtension
 

SoapExtensionAttribute , SoapExtension

I have problem,I want set soap extension attribute in web method:
Soap extension in web service:
AttributeUsage(AttributeTargets.Method)]

public class EncryptMessageAttribute : SoapExtensionAttribute

{

private string strKey="null";



public void  setKey(string s)

{

strKey=s;

}

}

Soap extension class:
public class EncryptMessage : SoapExtension

{

....

}

Soap extension on web method:
[WebMethod]

[EncryptMessageAttribute(setKey("test"))]

public string test2()

{

return "ok";

}

or :

[WebMethod]

[EncryptMessage(setKey("test"))]

public string test2()

{

return "ok";

}

I try used method setKey from class EncryptMessageAttribute , but it finished with this compile error:

Error1The name 'setKey' does not exist in the current context

Can somebody help me??

or if I try :
public class Service1 : System.Web.Services.WebService
{
public string k;

[WebMethod]
[EncryptMessage(setKey(k))]
public string test2()
{
return "ok";
}
}
It finish with this error:
Error1The name 'setKey' does not exist in the current context
Error2An object reference is required for the non-static field, method, or property

klerik123456
Answered at http://stackoverflow.com/questions/1398479/calling-a-method-with-a-soapextensionattribute.

John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects
John Saunders

You can use google to search for other answers

Custom Search

More Threads

• .NET Framework 2.0 security update breaks my XmlSerializer
• Clarification On Object Caching In Web Service
• WebBrowser's DocumentCompleted is never called
• saving objects to application throwing null reference error
• WSDL version in .NET 2.0
• wsdl.exe to generate new proxy Reference.cs classes to obtain Begin... Async methods.
• Optional Parameters when creating web service.
• Send Pictures between My Com and a remote server using XML Web Services
• Newbie having trouble with WSE 3.0
• How to create a class model for using XmlSerializer.Deserialize() on a preset schema?