クライアント側で SOAP 拡張属性を設定してみます。例えば:
Web サービスでの実装:
[AttributeUsage(AttributeTargets.Method)]
public class EncryptMessageAttribute : SoapExtensionAttribute
{
private string strKey="null";
public string StrKey
{
get { return strKey; }
set { strKey = value; }
}
}
SOAP 拡張クラス:
public class EncryptMessage : SoapExtension
{
...
}
Web メソッドで使用:
[WebMethod]
[EncryptMessage( StrKey = "pass")]
public string test2()
{
return "ok";
}
Proxy クラスでの実装:
[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( StrKey = "pass")]
public string test() {
object[] results = this.Invoke("test", new object[0]);
return ((string)(results[0]));
}
SOAP拡張属性は::[EncryptMessage( StrKey = "pass")]
いくつかの Web メソッドを呼び出すときに、Soap 拡張機能を使用する前に、クライアント側で Soap 拡張属性を設定したいと考えています。
例: SOAP 拡張機能が使用される前に、両側に SOAP 拡張属性を設定するメソッドを呼び出します。誰かが私を助けることができますか?