How to use NAServer inside SOE?

1287
1
Jump to solution
08-16-2016 07:17 AM
ImranRajjad
New Contributor III

Dear List,

We have an application that is making bulk requests to NAServer enabled on the map service. To tune and optimize the performance, we plan to consolidate all requests in a single request that should be handled by an SOE that would internally use NAServer for all the requests. So far I have been unable to find the path to acquire INAServer(2)`s reference from ServerObjectHelper that is passed in the init() method of SOE. Has anybody tried this before, or does the SOE need to load NA capabilities by accessing the actual MXD?

IMapServer3 ms = (IMapServer3) this.soHelper.getServerObject();

IServerObjectExtensionManager soeManager = new IServerObjectExtensionManagerProxy(ms);
IServerObjectExtension soe = soeManager.findExtensionByTypeName("NAServer"); // this is null ....tried Network Analyst, NA, NA_Server, NA_Extension
INAServer2 naServer = (INAServer2)soe ; // this is NULL

0 Kudos
1 Solution

Accepted Solutions
ImranRajjad
New Contributor III

It turns out that above code does not work inside init() method. Reference to NAserver can be obtained by same code when run after initialization of SOE is completed. So if you want to use NAserver in a REST/SOAP operation, below method can be used to get reference.

private INAServer2 getNAServerRef(){

if(this.naServer2 != null)
return this.naServer2;
try {
this.naServer2 = (INAServer2)((IServerObjectExtensionManager)this.soHelper.getServerObject()).findExtensionByTypeName("NAServer") ;
return naServer2;
} catch (AutomationException e) {

e.printStackTrace();
} catch (IOException e) {

e.printStackTrace();
}
return naServer2;
}

View solution in original post

1 Reply
ImranRajjad
New Contributor III

It turns out that above code does not work inside init() method. Reference to NAserver can be obtained by same code when run after initialization of SOE is completed. So if you want to use NAserver in a REST/SOAP operation, below method can be used to get reference.

private INAServer2 getNAServerRef(){

if(this.naServer2 != null)
return this.naServer2;
try {
this.naServer2 = (INAServer2)((IServerObjectExtensionManager)this.soHelper.getServerObject()).findExtensionByTypeName("NAServer") ;
return naServer2;
} catch (AutomationException e) {

e.printStackTrace();
} catch (IOException e) {

e.printStackTrace();
}
return naServer2;
}