I am trying to create a layer and add it into a MapControl from ArcGIS REST URL. For example I use the following URL http://sampleserver6.arcgisonline.com/arcgis/rest/services/EmergencyFacilities/MapServer
I can do this with the help of this post
However, the code in the post seems to derive a SOAP url from the REST url. So I have few questions regarding this.
- Can I create the layer without deriving a SOAP url from the REST url.
- Does it always guaranteed that the SOAP url can be derived in this way. For example If the service URL uses the "URL mapping", how will this method work? For instance how can I work with this URL https://maps.stats.govt.nz/wss/service/arcgis1/guest
Best Answer
In Arc 10.2 you can use IMapServerRESTLayer. Using this avoids using SOAP. Here is some code (VB.Net) that shows how it is used, with some extra code. This code is for a AddIn button. The extra code checks if the connection is OK by requesting a json file. Also, there is code for displaying the json file, and getting the REST file general information. I have not figured out a way of getting the other layer properties such as those under the source tab i.e. Data Type.
The url is typical. You need to find the url by going to the web service and looking it up.
There are other ways of NOT using SOAP. This article by Anthony Baker talks about using json files to consume REST services. Also the background information in http://rest.elkstein.org/2008/02/what-is-rest.html is very good.
Here is the code (tested under Arc10.2) Protected Overrides Sub OnClick() Const csProceedureName As String = "cmdListBaseMap_OnClick" MsgBox("In text version")