Select to view content in your preferred language

NA Route Rest services gives error

5146
10
03-14-2012 09:43 PM
MuhammadWaqar_ul_islam
Occasional Contributor
I have create Na Routing  sample to test
on arcgis info its works fine create route on the data
but when i create Network Analysis services through Arcgis server and  using rest services in silverlight sample
http://help.arcgis.com/en/webapi/silverlight/3.0/samples/start.htm#Routing
its gives error
Black"Routing error: Unable to complete operation unable to find atribute invalid Context" my rest services

i Have discuss this topic on arcgis silverlight forum one of esri person forward me to this forum

My services is
http://10.1.18.191/ArcGISSERVER/rest/services/network_Test/NAServer/Route

services properties
Network Layer: Route
Layer Type: esriNAServerRouteLayer

Impedance: Meters

Restrictions: Oneway, RestrictedTurn

Accumulate Attribute Names:

Attribute Parameter Values:

Use Hierarchy: false

Hierarchy Attribute Name:

Hierarchy Level Count: 0

Hierarchy Max Values:

Hierarchy Num Transitions:

Snap Tolerance: 0

Max Snap Tolerance: 5000

Snap Tolerance Units: esriMeters

Ignore Invalid Locations: true

Restrict U-Turns: esriNFSBAllowBacktrack

Output Spatial Reference: 32642

Find Best Sequence: false

Use Start Time: false

Start Time: Sat, 30 Dec 1899 08:00:00 GMT

Use Time Windows: false

Preserve First Stop: true

Preserve Last Stop: true

Output Line Type: esriNAOutputLineTrueShape

Directions Language: en-US

Direction Style Names: NA Desktop, NA Navigation

Directions Length Units: esriNAUMiles

Directions Time Attribute:

Network Analysis Classes:
Class Name: Stops
Field Name: Shape
Default Value:
Candidate Fields:
Field Name: Name
Default Value:
Candidate Fields: Name, Address, Label, Location, Stop, WayPoint, Description, Title, DepotName
Field Name: RouteName
Default Value:
Candidate Fields: RouteName, Route, RouteID
Field Name: Sequence
Default Value: 1
Candidate Fields:
Field Name: TimeWindowStart
Default Value:
Candidate Fields: TimeWindowStart1, TWStart1, FromTime1, FromTimeWindow1, FromTW1, From1, TimeWindowStart, TWStart, FromTime, FromTimeWindow, FromTW, From
Field Name: TimeWindowEnd
Default Value:
Candidate Fields: TimeWindowEnd1, TWEnd1, ToTime1, ToTimeWindow1, ToTW1, To1, TimeWindowEnd, TWEnd, ToTime, ToTimeWindow, ToTW, To
Field Name: SourceID
Default Value: -1
Candidate Fields: SourceID, SID, Source
Field Name: SourceOID
Default Value: -1
Candidate Fields: SourceOID, SOID
Field Name: PosAlong
Default Value: 0
Candidate Fields: PosAlong, PA, Pos
Field Name: SideOfEdge
Default Value: 2
Candidate Fields: SideOfEdge, SOE
Field Name: CurbApproach
Default Value: 0
Candidate Fields: CurbApproach, SideOfStreet, SideApproach, CurbSide, Curb
Field Name: Status
Default Value: 0
Candidate Fields:
Field Name: Attr_Meters
Default Value: 0
Candidate Fields: Attr_Meters, Meters
Class Name: Barriers
Field Name: Shape
Default Value:
Candidate Fields:
Field Name: Name
Default Value:
Candidate Fields: Name, Address, Label, Location, Barrier, Description, Title
Field Name: SourceID
Default Value: -1
Candidate Fields: SourceID, SID, Source
Field Name: SourceOID
Default Value: -1
Candidate Fields: SourceOID, SOID
Field Name: PosAlong
Default Value: 0
Candidate Fields: PosAlong, PA, Pos
Field Name: SideOfEdge
Default Value: 2
Candidate Fields: SideOfEdge, SOE
Field Name: CurbApproach
Default Value: 0
Candidate Fields: CurbApproach, SideOfStreet, SideApproach, CurbSide, Curb
Field Name: Status
Default Value: 0
Candidate Fields:
Field Name: FullEdge
Default Value: 0
Candidate Fields: FullEdge, IsFullEdge, BlockEntire
Field Name: BarrierType
Default Value: 0
Candidate Fields: BarrierType, BarType, BarrierTyp
Field Name: Attr_Meters
Default Value: 0
Candidate Fields: Attr_Meters, Meters
Class Name: PolylineBarriers
Field Name: Shape
Default Value:
Candidate Fields:
Field Name: Name
Default Value:
Candidate Fields: Name, Label, Locations, Barrier, Description, Title
Field Name: Locations
Default Value:
Candidate Fields: Locations, LocRanges
Field Name: BarrierType
Default Value: 0
Candidate Fields: BarrierType, BarType, BarrierTyp
Field Name: Attr_Meters
Default Value: 1
Candidate Fields: Attr_Meters, Meters
Class Name: PolygonBarriers
Field Name: Shape
Default Value:
Candidate Fields:
Field Name: Name
Default Value:
Candidate Fields: Name, Label, Locations, Barrier, Description, Title
Field Name: Locations
Default Value:
Candidate Fields: Locations, LocRanges
Field Name: BarrierType
Default Value: 0
Candidate Fields: BarrierType, BarType, BarrierTyp
Field Name: Attr_Meters
Default Value: 1
Candidate Fields: Attr_Meters, Meters
Network Dataset: RoadNetWork_ND


Network Attributes:

Meters
Usage Type: esriNAUTCost
Units: esriNAUMeters
Data Type: esriNADTDouble
Parameter Names:
Oneway
Usage Type: esriNAUTRestriction
Units: esriNAUUnknown
Data Type: esriNADTBoolean
Parameter Names:
RoadClass
Usage Type: esriNAUTDescriptor
Units: esriNAUUnknown
Data Type: esriNADTInteger
Parameter Names:
RestrictedTurn
Usage Type: esriNAUTRestriction
Units: esriNAUUnknown
Data Type: esriNADTBoolean
Parameter Names:
Network Sources:

Street
Element Type: esriNETEdge
Source Type:esriNSTEdgeFeature
ID: 1

RoadNetWork_ND_Junctions
Element Type: esriNETJunction
Source Type:esriNSTSystemJunction
ID: 3

RestrictedTurns
Element Type: esriNETTurn
Source Type:esriNSTTurnFeature
ID: 2

Supported Operations: Solve Route


i have attached gdb in Northkarachi.gdb.rar
for u testing
help me out what i m doing wrong
Tags (2)
0 Kudos
10 Replies
DmitryKudinov
Regular Contributor
Hi Muhammad,

Please try building a route on your network dataset using ArcMap first - will it work?

If it works, then download Fiddler http debugger tool (http://www.fiddler2.com/fiddler2/version.asp) and have it running while sending requests from your Silverlight application.

Check with Fiddler that all the attributes which are sent by the application present in your network dataset.

if there are some invalid attributes in requests whereas you do not specify them in your Silverlight code, try overriding these values explicitly.

Let us know if it doesn't help.

Dmitry
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
I have tired to used fiddler utilities
unable to understand fiddler result

what i get from fiddler i m paste

GET /ArcGISSERVER/rest/services/network_Test/NAServer/Route/solve?stops=%7b%22features%22%3a%5b%7b%22geometry%22%3a%7b%22x%22%3a303831.809058898%2c%22y%22%3a2763214.26130914%2c%22spatialReference%22%3a%7b%22wkid%22%3a32642%7d%7d%7d%2c%7b%22geometry%22%3a%7b%22x%22%3a304055.883835564%2c%22y%22%3a2763292.20034173%2c%22spatialReference%22%3a%7b%22wkid%22%3a32642%7d%7d%7d%5d%7d&returnDirections=false&returnRoutes=true&returnStops=false&returnBarriers=false&returnPolylineBarriers=false&returnPolygonBarriers=false&outSR=32642&ignoreInvalidLocations=true&preserveFirstStop=true&preserveLastStop=true&useHierarchy=true&outputGeometryPrecision=0&outputGeometryPrecisionUnits=esriUnknownUnits&f=json& HTTP/1.1


GET /ArcGISSERVER/rest/services/network_Test/NAServer/Route/solve?stops={"features":[{"geometry":{"x":303831.809058898,"y":2763214.26130914,"spatialReference":{"wkid":32642}}},{"geometry":{"x":304055.883835564,"y":2763292.20034173,"spatialReference":{"wkid":32642}}}]}&returnDirections=false&returnRoutes=true&returnStops=false&returnBarriers=false&returnPolylineBarriers=false&returnPolygonBarriers=false&outSR=32642&ignoreInvalidLocations=true&preserveFirstStop=true&preserveLastStop=true&useHierarchy=true&outputGeometryPrecision=0&outputGeometryPrecisionUnits=esriUnknownUnits&f=json& HTTP/1.1

{"error":{"code":400,"message":"Unable to complete  operation.","details":["Unable to find attribute .  Invalid context.  NALayer saved on server with token ec21144d19a2405db79d867307031d55_1325852015."]}}

what next to solved this issue
0 Kudos
DmitryKudinov
Regular Contributor
Hi Muhammad,

Looking at the error message, it might be the case that the network dataset on your Server is different from the one you used in ArcMap during service authoring (when you were creating the MXD which was later published).

So, please first verify that the network dataset on server is the same.

If network dataset is exactly the same on both Desktop and Server and service still fails, rerun the same request again and note the error message, particularly the part about "NALayer saved on server with token ...". The token value will tell you the name of LYR file in ArcGIS Server output directory (_ags<token>.lyr) - find this file, open it in ArcMap, and try solving it. Most probably the solve will fail in ArcMap as well and this will give you much better clue on what is going wrong.

Dmitry
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
i have open the _ags token  layer ( from output directory of arcgisserver)  in arcmap 
and solved the solution in arcmap
its works fine
no error occurs
what next to solved this issue
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
i have created new NA ROUTE SERVICES
using fiddler it gives this error

GET /ArcGISSERVER/rest/services/Network_ANAlysis/NAServer/Route/solve?stops=%7b%22features%22%3a%5b%7b%22geometry%22%3a%7b%22x%22%3a303867.994872106%2c%22y%22%3a2763839.39565207%2c%22spatialReference%22%3a%7b%22wkid%22%3a32642%7d%7d%7d%2c%7b%22geometry%22%3a%7b%22x%22%3a303975.44353541%2c%22y%22%3a2762960.26995024%2c%22spatialReference%22%3a%7b%22wkid%22%3a32642%7d%7d%7d%5d%7d&returnDirections=false&returnRoutes=true&returnStops=false&returnBarriers=false&returnPolylineBarriers=false&returnPolygonBarriers=false&outSR=32642&ignoreInvalidLocations=true&preserveFirstStop=true&preserveLastStop=true&useHierarchy=true&outputGeometryPrecision=0&outputGeometryPrecisionUnits=esriUnknownUnits&f=json& HTTP/1.1


{"error":{"code":400,"message":"Unable to complete operation.","details":["Unable to find attribute . Invalid context. NALayer saved on server with token 

when i open this ags_file in arcmap its work fine

help me out please
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
attached file
0 Kudos
DmitryKudinov
Regular Contributor
Hi Muhammad,

Please open the Route description page (http://<server>/ArcGISSERVER/rest/services/Network_ANAlysis/NAServer/Route) in a browser and look for all the attributes of the esriNAUTCost usage type; write down the name of the attribute you are interested to solve on.

Next, in your HTTP request, specify the impedanceAttributeName parameter with the value set to attribute name you noted at the previous step.

Please let us know what will be the result.

Dmitry
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
Hi Muhammad,

Please open the Route description page (http://<server>/ArcGISSERVER/rest/services/Network_ANAlysis/NAServer/Route) in a browser and look for all the attributes of the esriNAUTCost usage type; write down the name of the attribute you are interested to solve on.

Next, in your HTTP request, specify the impedanceAttributeName parameter with the value set to attribute name you noted at the previous step.

Please let us know what will be the result.

Dmitry


Network Dataset: RoadNetWork_ND


Network Attributes:

Meters
Usage Type: esriNAUTCost
Units: esriNAUMeters
Data Type: esriNADTDouble
Parameter Names:
Oneway
Usage Type: esriNAUTRestriction
Units: esriNAUUnknown
Data Type: esriNADTBoolean
Parameter Names:
RoadClass
Usage Type: esriNAUTDescriptor
Units: esriNAUUnknown
Data Type: esriNADTInteger
Parameter Names:
RestrictedTurn
Usage Type: esriNAUTRestriction
Units: esriNAUUnknown
Data Type: esriNADTBoolean
Parameter Names:
Network Sources:

Street
Element Type: esriNETEdge
Source Type:esriNSTEdgeFeature
ID: 1

RoadNetWork_ND_Junctions
Element Type: esriNETJunction
Source Type:esriNSTSystemJunction
ID: 3

RestrictedTurns
Element Type: esriNETTurn
Source Type:esriNSTTurnFeature
ID: 2


i have also solved  the route on  http://<server>/ArcGISSERVER/rest/services/Network_ANAlysis/NAServer/Route/Solve

Result i get
Directions:

Route: 1.Location 1 - Location 2
Summary:

    Total Length: 290.725276854782 Total time: 0 Total Drive Time: 0
    Envelope:
        Envelope:
        XMin: 303831.274002066
        YMin: 2763214.2613
        XMax: 304055.8838
        YMax: 2763300.41672698
        Spatial Reference: 32642

Directions:

    Text: Start at Location 1 Length: 0 Time: 0 ETA: 12/30/1899 12:00:00 AM Maneuver: esriDMTDepart
    Compressed Geometry: +1+98mn+2kaes+0+0

    Text: Go east Length: 176.920221727059 Time: 0 ETA: 12/30/1899 12:00:00 AM Maneuver: esriDMTStraight
    Compressed Geometry: +1+98mn+2kaes+5h+7

    Text: Turn left Length: 63.667495198 Time: 0 ETA: 12/30/1899 12:00:00 AM Maneuver: esriDMTTurnLeft
    Compressed Geometry: +1+98s8+2kaf3-3+20

    Text: Turn right Length: 50.1375599297227 Time: 0 ETA: 12/30/1899 12:00:00 AM Maneuver: esriDMTTurnRight
    Compressed Geometry: +1+98s5+2kah3+1j+1

    Text: Finish at Location 2, on the right Length: 0 Time: 0 ETA: 12/30/1899 12:00:00 AM Maneuver: esriDMTStop
    Compressed Geometry: +1+98to+2kah4+0+0

Routes

#records: 1

    ObjectID: 1
    Name: Location 1 - Location 2
    FirstStopID: 1
    LastStopID: 2
    StopCount: 2
    Total_Meters: 290.725276854782
    Shape_Length: 290.725186211174

    Polyline:
    Path0:[303831.274,2763228.1893],[303885.5364,2763230.274],[303895.8829,2763230.6672]...5 more...


Next, in your HTTP request, specify the impedanceAttributeName parameter with the value set to attribute name you noted at the previous step.

i do not understand what ur asking in above line  but what i understand is impedanceAttributeName is 
Impedance Attribute Name: METER 

{  RESULT IN JSON
  "directions" : [
    {
      "routeId" : 1,
      "routeName" : "Location 1 - Location 2",
      "summary" : {
        "totalLength" : 290.725276854782,
        "totalTime" : 0,
        "totalDriveTime" : 0,
        "envelope" : {
          "xmin" : 303831.274002066,
          "ymin" : 2763214.2613,
          "xmax" : 304055.8838,
          "ymax" : 2763300.41672698,
          "spatialReference" : {
            "wkid" : 32642
          }
        }
      },
      "features" : [
        {
          "attributes" : {
            "length" : 0,
            "time" : 0,
            "text" : "Start at Location 1",
            "ETA" : -2209161600000,
            "maneuverType" : "esriDMTDepart"
          },
          "compressedGeometry" : "+1+98mn+2kaes+0+0"
        },
        {
          "attributes" : {
            "length" : 176.920221727059,
            "time" : 0,
            "text" : "Go east",
            "ETA" : -2209161600000,
            "maneuverType" : "esriDMTStraight"
          },
          "compressedGeometry" : "+1+98mn+2kaes+5h+7"
        },
        {
          "attributes" : {
            "length" : 63.667495198,
            "time" : 0,
            "text" : "Turn left",
            "ETA" : -2209161600000,
            "maneuverType" : "esriDMTTurnLeft"
          },
          "compressedGeometry" : "+1+98s8+2kaf3-3+20"
        },
        {
          "attributes" : {
            "length" : 50.1375599297227,
            "time" : 0,
            "text" : "Turn right",
            "ETA" : -2209161600000,
            "maneuverType" : "esriDMTTurnRight"
          },
          "compressedGeometry" : "+1+98s5+2kah3+1j+1"
        },
        {
          "attributes" : {
            "length" : 0,
            "time" : 0,
            "text" : "Finish at Location 2, on the right",
            "ETA" : -2209161600000,
            "maneuverType" : "esriDMTStop"
          },
          "compressedGeometry" : "+1+98to+2kah4+0+0"
        }
      ]
    }
  ],
  "routes" : {"spatialReference" : {
      "wkid" : 32642
    },
   
    "features" : [
      {
        "attributes" : {
          "ObjectID" : 1,
          "Name" : "Location 1 - Location 2",
          "FirstStopID" : 1,
          "LastStopID" : 2,
          "StopCount" : 2,
          "Total_Meters" : 290.725276854782,
          "Shape_Length" : 290.725186211174
        }
        ,
        "geometry" :
        {
          "paths" :
          [
            [
              [303831.274, 2763228.1893],
              [303885.5364, 2763230.274],
              [303895.8829, 2763230.6672],
              [303964.0281, 2763233.2845],
              [304008.0642, 2763234.9721],
              [304008.0642, 2763235.0171],
              [304005.4796, 2763298.587],
              [304055.5837, 2763300.4167]
            ]
          ]
        }
      }
    ]
  },
  "messages" : [
  ]
}


What next to solved this
and Many thanks for providing help
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
please reply to this thread
awaiting for your reply
0 Kudos