There are two choose for you on NAServer. The NAServer is a MapServer object extension that can be used to perform network analysis in a stateless environment using ArcGIS Server.
For publishing a network analysis service you can check out this tutorial...
1.Closest Facility Analysis: displays the best routes between incidents and facilities.

2.OD Cost Matrix: (origin–destination (OD) cost matrix) a table that contains the network impedance from each origin to each destination.


and showing them in a map as openlayers, you can use ArcGIS Server Service.
1.Go to Home > Network(NAServer) > Route
2.Select Solve Route
3.Define your points and barriers
4.Get format as JSON
5.Read json features and add them to vector layer.
example NAServer is here. beside this you have to define stops as following structure:
{
"features" : [
{
"geometry" : {"x" : -122.4079, "y" : 37.78356},
"attributes" : {"Name" : "From", "RouteName" : "Route A"}
},
{
"geometry" : {"x" : -122.404, "y" : 37.782},
"attributes" : {"Name" : "To", "RouteName" : "Route A"}
}
]
}
you can check out this example:
you should know this the link is so long:
_http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route/solve?stops={+%0D%0A%22features%22++%3A+[%0D%0A{%0D%0A++%22geometry%22+%3A+{%22x%22+%3A+-122.4079%2C+%22y%22+%3A+37.78356}%2C%0D%0A++%22attributes%22+%3A+{%22Name%22+%3A+%22From%22%2C+%22RouteName%22+%3A+%22Route+A%22}%0D%0A}%2C%0D%0A{%0D%0A++%22geometry%22+%3A+{%22x%22+%3A+-122.404%2C+%22y%22+%3A+37.782}%2C%0D%0A++%22attributes%22+%3A+{%22Name%22+%3A+%22To%22%2C+%22RouteName%22+%3A+%22Route+A%22}%0D%0A}%0D%0A]%0D%0A}%0D%0A&barriers=&polylineBarriers=&polygonBarriers=&outSR=4326&ignoreInvalidLocations=true&accumulateAttributeNames=&impedanceAttributeName=Time&restrictionAttributeNames=OneWay%2CTurnRestriction%2CAvoid+passenger+ferries%2CNon-routeable+segments&attributeParameterValues=&restrictUTurns=esriNFSBAllowBacktrack&useHierarchy=true&returnDirections=true&returnRoutes=true&returnStops=false&returnBarriers=false&returnPolylineBarriers=false&returnPolygonBarriers=false&directionsLanguage=en-US&directionsStyleName=NA+Desktop&outputLines=esriNAOutputLineTrueShape&findBestSequence=false&preserveFirstStop=true&preserveLastStop=true&useTimeWindows=true&startTime=1227663551096&outputGeometryPrecision=&outputGeometryPrecisionUnits=esriUnknownUnits&directionsTimeAttributeName=Time&directionsLengthUnits=esriNAUMiles&f=html