all Technical posts

Sentinet – Leverage the standard WCF extensibility points

Sentinet is highly extendable through standard Microsoft .NET, WCF and WIF extensibility points, and thorough the Sentinet API interfaces.

In the previous post we saw how to build a custom access rule expression (standard .NET library), With this post I would like to continue the serie about the Sentinet Extensibility and demonstrate how to leverage the WCF extensibility setting up my virtual service with a custom endpoint behavior.

Scenario

The scenario is pretty simple. A third party REST service, GetCalledNumbers, that provides the list of the recent called numbers needs to be exposed. To meet the customer’s privacy policies it’s been required to mask the dialed phone numbers.

To achieve these requirements I created a REST façade service that virtualizes the third party one. Then I built a custom endpoint behavior that replaces the phone numbers with asterisks except the last 4 digits.

In this demo the inspector has been positioned at the client side so the IClientMessageInspector interface has been implemented. It’s not the intent of this post to describe how to build a message inspector, here, you can find a complete example.

InspectorCode

Register

To use the custom component, first it has to be registered.

The register procedure is pretty straightforward:

  1. Drop Codit.Demo.Sentinet.Extensions.dll in the bin directory of both Repository and Nodes applications (for Sentinet Nodes you might need to create empty bin directory first).
  2. Register/add behavior extension in web.config files of both Repository and Nodes applications
    <behaviorExtensions>
    <add name=”jsonMask” type=”Codit.Demo.Sentinet.Extensions.Formatting.JsonFormatterEndpointBehaviorExtension, Codit.Demo.Sentinet.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9fc8943ef10c782f”/>
    </behaviorExtensions>
  3. Then you can add this endpoint behavior in the Sentinet Console shared behaviors (for the future re-use of this shared component between virtual services):
    <behavior name=”JsonFieldMask”><jsonMask toBeBlurred=”PhoneNumber” /></behavior>
  4. Now you can apply this shared endpoint behavior to the inbound endpoint(s) of the virtual service.

Using the Sentinet Administration console, first create a new behavior:

CreateBehaviors

Then apply it to the virtual service.

AddEndpointBehavior

Test

For testing the virtual service I used postman to send a GET request to my virtual API.
PostmanTest

During this test I enabled the full transaction recording so that in the Monitor tab I can access to the content transmitted and check the result  of the message inspector.

MonitorRecording

Conclusion

Message inspectors are the most used extensibility points of the WCF runtime. In this article we saw how to set-up and use custom / third party components in Sentinet. In the next post I will discuss about the Sentinet’s routing feature and how to build a custom router.

Cheers,

Massimo

Subscribe to our RSS feed

Thanks, we've sent the link to your inbox

Invalid email address

Submit

Your download should start shortly!

Stay in Touch - Subscribe to Our Newsletter

Keep up to date with industry trends, events and the latest customer stories

Invalid email address

Submit

Great you’re on the list!