我要实现的是把特定一段Soap加密WebService 的方法
public XmlDocument GetXmlDocument()
{
//创建一个用于返回的简单的XML文档
XmlDocument myDoc = new XmlDocument();
myDoc.InnerXml = 
"<EncryptedResponse>这里是敏感数据.</EncryptedResponse>"; //得到对外发送的回应报文的SoapContext
SoapContext myContext = HttpSoapContext.ResponseContext; //创建一个用于加密的对称密钥,由于密钥是对称的,这些相同的数据必须存在有需求的客户端上。 //定义共享的16字节数组,用来表示128位密钥
byte[] keyBytes = {48, 218, 89, 25, 222, 209, 227, 51, 50, 168, 146, 
188, 250, 166, 5, 206}; //定义共享的8字节(64位)数组,也就是初始化向量(IV)
byte[] ivBytes = {16, 143, 111, 77, 233, 137, 12, 72}; //创建三元DES算法的新实例
SymmetricAlgorithm mySymAlg = new TripleDESCryptoServiceProvider(); //设置好密钥和IV
mySymAlg.Key = keyBytes;
mySymAlg.IV = ivBytes;
//创建一个新的WSE对称加密密钥
EncryptionKey myKey = new SymmetricEncryptionKey(mySymAlg);
//给他取个名字?
KeyInfoName myKeyName = new KeyInfoName();
myKeyName.Value = "http://example.com/symmetrictestkey";
myKey.KeyInfo.AddClause(myKeyName);
//使用对称密钥来创建一个新的EncryptedData元素
EncryptedData myEncData = new EncryptedData(myKey);
//将EncryptedData元素添加到SOAP回应上,告诉过滤器用指定的密钥来加密信息正文 //myContext.Security.Elements.Add(myEncData); return myDoc;
}
Web.config也做了配置
      ......
      <soapExtensionTypes>
        <add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0" />
      </soapExtensionTypes>
      ......
但是发现GetXmlDocument方法中的myContext对象是NULL,无法运行程序。
请问我是不是有什么地方还要配置吗?