Hi,
Could someone please tell me how to access ArcSDE Geodatabase, which is published as GeoData service, into IWorkspace interface using ArcObjects.
I am trying to initialize IGeoDataServer as below and then trying to cast this object to instantiate IGeoDataServerObjects interface and then call IGeoDataServerObjects::getDefaultWorkingWorkspace() to get object of IWorkspace.
<SPAN class="keyword token">static</SPAN> IGeoDataServer <SPAN class="token function">initGeoDataServerFromInternetServer</SPAN><SPAN class="punctuation token">(</SPAN>String url<SPAN class="punctuation token">,</SPAN> String
serviceName<SPAN class="punctuation token">)</SPAN><SPAN class="keyword token">throws</SPAN> Exception<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Create a property set for connection properties.</SPAN>
IPropertySet propertySet <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">PropertySet</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
propertySet<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setProperty</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"URL"</SPAN><SPAN class="punctuation token">,</SPAN> url<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Connect to the server and get an enumerator for its objects.</SPAN>
IAGSServerConnectionFactory agsServerConnectionFactory <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN>
<SPAN class="token class-name">AGSServerConnectionFactory</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IAGSServerConnection agsServerConnection <SPAN class="operator token">=</SPAN> agsServerConnectionFactory<SPAN class="punctuation token">.</SPAN>open
<SPAN class="punctuation token">(</SPAN>propertySet<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IAGSEnumServerObjectName enumServerObjectName <SPAN class="operator token">=</SPAN>
agsServerConnection<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getServerObjectNames</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
enumServerObjectName<SPAN class="punctuation token">.</SPAN><SPAN class="token function">reset</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Iterate through the objects to locate the geodata service.</SPAN>
IAGSServerObjectName serverObjectName <SPAN class="operator token">=</SPAN> null<SPAN class="punctuation token">;</SPAN>
IGeoDataServer geoDataServer <SPAN class="operator token">=</SPAN> null<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">while</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>serverObjectName <SPAN class="operator token">=</SPAN> enumServerObjectName<SPAN class="punctuation token">.</SPAN><SPAN class="token function">next</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">!=</SPAN> null<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>serverObjectName<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getName</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">equals</SPAN><SPAN class="punctuation token">(</SPAN>serviceName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN>
IName name <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IName<SPAN class="punctuation token">)</SPAN>serverObjectName<SPAN class="punctuation token">;</SPAN>
geoDataServer <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IGeoDataServer<SPAN class="punctuation token">)</SPAN>name<SPAN class="punctuation token">.</SPAN><SPAN class="token function">open</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">break</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">return</SPAN> geoDataServer<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>However, unable to cast object of IGeoDataServer neither to GeoDataServer nor IGeoDataServerObjects interface.
Please let me know if I am not clear anywhere.
Thanks &Regards,
Vara Prasad.