Select to view content in your preferred language

Publishing FeatureService in REST API from a MPK

1170
1
06-04-2012 11:54 PM
GwendalPrioux1
New Contributor
Hello,
I try in vain to publish a FeatureService from a MPK, with the ArcGIS JAVA runtime. But I see only the MapService published in the Rest API.
My goal is to use this API with a Flex Rest Viewer I need to see this from FeatureService Rest API.
Would you tell me what method I should use Java to see this appear in the API FeatureService Rest.
Thank you

Pascal

PS : A sample of code is welcome 😉

PS : I 've tried this :
  ArcGISLocalDynamicMapServiceLayer localMSLayer = new ArcGISLocalDynamicMapServiceLayer("C:\\PROJECT\\mpk\\digsure.mpk");
  map.setSpatialReference(com.esri.core.geometry.SpatialReference.create(2154));
  LayerList layers = map.getLayers();
  layers.add(localMSLayer);

   ArcGISLocalFeatureLayer featureLayer1 = new ArcGISLocalFeatureLayer("C:\\PROJECT\\mpk\\digsure.mpk", 7, true);
  layers.add(featureLayer1);
0 Kudos
1 Reply
DaudiHusbands
Deactivated User
Hi,
You have two options.
Firstly, try adding your FeatureLayer before adding the MapServiceLayer. This will cause both FeatureService and MapService to start.
You can then add your MapServiceLayer.

Alternatively, you may wish to start your LocalFeatureService asynchronously as shown in the code below.
       
        // create the local feature service
        LocalFeatureService featureService = new LocalFeatureService("path to .mpk");
        featureService.addLocalServiceStartCompleteListener(new LocalServiceStartCompleteListener() {

            @Override
            public void localServiceStartComplete(LocalServiceStartCompleteEvent arg0) {

                // once service started, create and add feature layers to the map
                ArcGISFeatureLayer myFeatureLayer = new ArcGISFeatureLayer(arg0.getUrl() + "/0");
               
                map.getLayers().add(myFeatureLayer);

            }
        });
        // start the service
        featureService.startAsync();

Regards,
Daudi
0 Kudos