I am trying to impelemnt content based routing using XPath in wcf.
I have create class library which contains service contract and data contract as following.
[ServiceContract(Namespace = "http://orders/")]
public interface IService5
{
[OperationContract]
string GetData(int value);
}
[DataContract]
public class Quantity
{
[DataMember]
public int value1 { get; set; }
}
I created one service as follows:
public class Service5 : IService5
{
public string GetData(int value)
{
return string.Format("You entered in service 5: {0}", value);
}
}
And I am trying to implement routing based on 'value'
In app.config (inside router project) i hav added following lines for namespace and XPath filter
<namespaceTable>
<add prefix="cc" namespace="http:orders/Quantity/"/>
</namespaceTable>
<filters>
<filter name="All" filterType="XPath" filterData="cc://value1 > 500 " />
But whenever i run the code i get an exception for ' cc://value1 > 500 ' as invalid qualified name exception.
How can i resolve this ?
There are multiple things wrong here:
Quantity
on which you appear to want to apply the filter does not feature in your service contract at all, so will be entirely absent in the XML for filtering purposes.http:orders
, when the service contract namespace startshttp://orders
./Quantity
, when the service contract namespace does not.