Content-Based Routing
プレミアムWebサービスに関する設定
static readonly string PremiumNamespaceUri = "http://schemas.microsoft.com/wse/1/samples/advanced/cbr";
static readonly string PremiumHeaderName = "Premium";
protected override Uri ProcessRequestMessage(SoapEnvelope message)
ということで、SOAPヘッダーを調べて、プレミアムサービスのタグがついていたら、プレミアムWebサービスへの
XmlNodeList headersMatched = message.Header.GetElementsByTagName(PremiumHeaderName, PremiumNamespaceUri);
if (headersMatched.Count == 0)
{
//
// Defer to the WSE RoutingHandler's implementation
//
return base.ProcessRequestMessage(message);
}
else
{
//
// Add a new via and send it off to the premium service by adding
// the new via in front.
//
return premiumServiceUri;
}
誘導をしているわけね。
でも、このPremiumHeaderを含むプロキシクラスはどうやって作られたんだろう。
ちょっと見たところ、後付で手動で追加したようにみえるのですが。
とりあえず、プロキシクラスの中で、
として、属性ベースで
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://schemas.microsoft.com/wse/1/samples/advanced/cbr")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.microsoft.com/wse/1/samples/advanced/cbr", ElementName = "Premium", IsNullable = true)]
public class PremiumHeader : SoapHeader
{
}
として"PremiumHeader"を追加しているように見えます。
///
[System.Web.Services.Protocols.SoapHeaderAttribute("PremiumHeader")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://stockservice.contoso.com/wse/samples/2005/10/StockQuoteRequest", RequestNamespace="http://stockservice.contoso.com/wse/samples/2005/10", ResponseElementName="StockQuotes", ResponseNamespace="http://stockservice.contoso.com/wse/samples/2005/10", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("StockQuote")]
public StockQuote[] StockQuoteRequest([System.Xml.Serialization.XmlArrayAttribute(IsNullable=true)] [System.Xml.Serialization.XmlArrayItemAttribute("Symbol", IsNullable=false)] string[] symbols) {
object[] results = this.Invoke("StockQuoteRequest", new object[] {
symbols});
return ((StockQuote[])(results[0]));
}
AppBase:ConfigureProxy
AppSettings["remoteHost"]からプロキシのアクセス先のURIを設定する。
該当設定が見つからなければ何も設定しない。