Query WMS Layer

5158
6
06-30-2011 10:32 AM
MarieChan-Gove
New Contributor
Hello
I am a newbie at Siverlight and WMS.  I followed the Silverlight Interactive SDK and able to load WmsLayer in XAML successfully; thus, I can see the features on the map.  But, I am not able to go further, i.e. query info in the WmsLayer.  I tried QueryTask but it gave me errors.

I am looking for example C# code and/or documentation of how to query WmsLayer. 

Please help.
0 Kudos
6 Replies
dotMorten_esri
Esri Notable Contributor
The WMS Layer in the API does not provide support for the GetFeature request in WMS Layers out of the box.
0 Kudos
OscarLexell
New Contributor
I've a similar problem.

Following the example for spatial query and replacing the commented link with a new link

//QueryTask queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");
QueryTask queryTask = new QueryTask("http://maps.helcom.fi/ArcGIS/rest/services/DataDeliveryNoSublayers/MapServer/132");


And
 //query.OutFields.AddRange(new string[] { "STATE_NAME", "SUB_REGION", "STATE_FIPS", "STATE_ABBR", "POP2000", "POP2007" });
                query.OutFields.AddRange(new string[] { "ET_FID", "ID", "COUNTRY", "AIRCRAFT", "SPEED_KN", "RS_EQUIP" });


The wms layer is defined as
<esri:WmsLayer ID="- Aircrafts" Url="http://maps.helcom.fi/ArcGIS/services/DataDelivery/MapServer/WMSServer?" 
                            ProxyUrl="http://serverapps.esri.com/SilverlightDemos/ProxyPage/proxy.ashx"  Version="1.3.0" Layers="179"
                               SkipGetCapabilities="True" Initialized="WmsLayer_Initialized" Visible="True" InitializationFailed="layer_InitializationFailed"/>
            

the WMS layer is inside two group layers

Trying this i got this error
[ATTACH=CONFIG]13484[/ATTACH]

the crossdomain.xml file I think is in the correct location.

Maybe the problem is more layers being selected and Query tasks trying to query the wrong layer?

Any good sugestion on how to get on?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
As you need a proxy for your map service, likely you need one for the query task as well.
Did you put a proxy for the query task?

Else you can look to the query sent to the server by using an HTTP sniffer such as fiddler. This might give a clue.
0 Kudos
OscarLexell
New Contributor
Thank you.

The proxy was of no use. bur fiddler give a clue.
I've found the crossdomain.xml is not in the root.
http://maps.helcom.fi/website/crossdomain.xml
How to tell Silverlight to look for the crossdomain.xml here instead?
I'm not sure if this will help, but it is the only crossdomain or clientaccesspolicy I can find.

Edit, by using Fiddler AutoResponder I can trick the application to read a local clientaccesspolicy.xml or the crossdomain linked above. Now the query works and I will start to figure out how to query several layers.

Still interesting in knowing if it is possible to read the crossdomain.xml file without using fiddler AutoResponder.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The proxy was of no use.

Strange. If you are able to display the layer using a proxy, you should be able to query it by using the same proxy.


I've found the crossdomain.xml is not in the root.
http://maps.helcom.fi/website/crossdomain.xml
How to tell Silverlight to look for the crossdomain.xml here instead?

crossdomain or cliantaccesspolicy files must be in the root of the website. AFAIK, there is no way to change this behavior.

Still interesting in knowing if it is possible to read the crossdomain.xml file without using fiddler AutoResponder.

Proxy should be the solution.
0 Kudos
İsmailZAMBAKCI
New Contributor II
Hi, You can write a proxy page has that capabilites;
-Gets arcgis request from any arcgis client api (flex-silverlight-javascript-...).
-Prepares the wms request for send to geoserver or other ogc servers.
-Gets response of the ogc getcapabilities,describefeaturetype and the other request types responses.
-Convert response xml or xsd reponses that returns from wms, to ArcGIS json format.


And you can use an ogc service as below,
layer = new ArcGISDynamicMapServiceLayer()
{ ID ="GeoServer WMS",
   Url = "http://demo.opengeo.org/geoserver/osm/wms",
   ProxyURL = "Your proxy page "
};

I have written that proxy and Im looking for editing capabilities for convert to use wfs-t services.
I think, It will not be easy 🙂
0 Kudos