Difference between revisions of "Csharp webservice dll"

From OpenKM Documentation
Jump to: navigation, search
(Example of use)
Line 26: Line 26:
  
 
int serverVersion = OKMWebServiceFactory.PROFESSIONAL_6_4;
 
int serverVersion = OKMWebServiceFactory.PROFESSIONAL_6_4;
OKMWebservice okmWebservice = null;
+
OKMWebservice webservice= null;
 
if (serverVersion == OKMWebServiceFactory.PROFESSIONAL_6_4)
 
if (serverVersion == OKMWebServiceFactory.PROFESSIONAL_6_4)
 
{
 
{
okmWebservice = OKMWebServiceFactory.getInstance(host, user, password, OKMWebServiceFactory.PROFESSIONAL_6_4);
+
webservice= OKMWebServiceFactory.getInstance(host, user, password, OKMWebServiceFactory.PROFESSIONAL_6_4);
 
}
 
}
 
else
 
else
 
{
 
{
okmWebservice = OKMWebServiceFactory.getInstance(host, user, password, OKMWebServiceFactory.PROFESSIONAL_6_2);
+
webservice= OKMWebServiceFactory.getInstance(host, user, password, OKMWebServiceFactory.PROFESSIONAL_6_2);
 
}
 
}
 
</source>
 
</source>
 +
 +
== Controlling exceptions ==
 +
OKMWebservice dll will throw '''OKMWebserviceException''' if happens some error if good practice control in your source code.
 +
 +
<source lang="csharp">
 +
try {
 +
  webservice.login();
 +
} catch (OKMWebserviceExceptione){
 +
 +
}
 +
</source>
 +
  
 
[[Category: Extension Guide]]
 
[[Category: Extension Guide]]

Revision as of 13:13, 23 September 2013


Nota clasica.png Dll have been compiled for net 2.0 that should ensure go with any upper .net version

Download File:OKMWebservice.zip

Available api:

  • Webservices for OpenKM Professional 6.4
  • Webservices for OpenKM Professional 6.2
  • Webservices for OpenKM Community 6.0+

Understanding the basics

For all webservices methods are available two methods one with token and other without it. For example to get granted roles of some node path can be used:

Dictionary<String, int> getGrantedRoles(String nodePath);
Dictionary<String, int> getGrantedRoles(String token, String nodePath);

First case getGrantedRoles(nodePath) internally controls login and logout actions for you and is not needed a token.

On second getGrantedRoles(token, nodePath) is necessary provide a token. That means you take control of login and logout actions in your source code.

Example

String host = "http://localhost:8080";
String user = "okmAdmin";
String password = "admin";

int serverVersion = OKMWebServiceFactory.PROFESSIONAL_6_4;
OKMWebservice webservice= null;
if (serverVersion == OKMWebServiceFactory.PROFESSIONAL_6_4)
{
	webservice= OKMWebServiceFactory.getInstance(host, user, password, OKMWebServiceFactory.PROFESSIONAL_6_4);
}
else
{
	webservice= OKMWebServiceFactory.getInstance(host, user, password, OKMWebServiceFactory.PROFESSIONAL_6_2);
}

Controlling exceptions

OKMWebservice dll will throw OKMWebserviceException if happens some error if good practice control in your source code.

try {
  webservice.login();
} catch (OKMWebserviceExceptione){

}