webERP Forum

Full Version: API integration with .net Web application
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all

Am quite new to webErp, I have an in-house developed .net application which I want to communicate with webErp through available XMLRPC APIs. Use cases will be like posting a transaction entry from the .net web application to webErp.
Could you provide me with some reference links or starting points to achieve this?

Thanks in advance

Regards
Sume MS
There is an API tutorial I wrote in the manual which you should have as part of your implementation.

Tim
Thanks Tim for quick response
I could find the API integration from PHP which is pretty straightforward using XML-RPC.
Do you have any .net library suggestions?

Regards
Sume MS



(11-12-2017, 06:28 PM)falkoner Wrote: [ -> ]There is an API tutorial I wrote in the manual which you should have as part of your implementation.

Tim

I don't have experience with .net myself, but this looks like a good starting point http://xml-rpc.net/

It seems fairly current and to have decent documentation.

Tim
Thanks Tim

Definitely, this would be a great starting point.

Regards
Sume MS
One more question,

Is it possible to have multiple databases in the api/api_php.php if I want to work on multiple companies from the application?

Regards
Sume MS

Sorry I found this is listed as a limitation of the design. Since it is mandatory for my application to work with multiple companies at the same time, I am thinking to create an api that can modify the api_php.php with required corresponding database name before every transaction.
Any comments?

regards
Sume MS
Hi, the problem with modifying the api is always to keep compatibility with existing applications that use it.

I would do something like the following (Nb I haven't tried this, so you may need to experiment a little)

Change each function call like this:

function InsertBranch($BranchDetails, $user, $password) becomes function InsertBranch($BranchDetails, $user, $password, $database_name='')

Then each function has a line

$db = db($user, $password);

which needs to be

$db = db($user, $password, $database_name);

Then within api_php.php the function declaration becomes:

function db($user, $password, $database_name) {
if (!isset($_SESSION['AccessLevel']) or $_SESSION['AccessLevel'] == '') {
// Login to default database = old clients.
if ($user != '' and $password != '') {
global $api_DatabaseName;
if ($database_name != '') {
$api_DatabaseName = $database_name;
}
$rc = LoginAPI($api_DatabaseName, $user, $password);
if ($rc[0] == UL_OK) {
return $_SESSION['db'];
}
}
return NoAuthorisation;
} else {
return $_SESSION['db'];
}
}

As I said I haven't actually tried it, but would be interested to know if it works out :-)

Tim
Hi
Interesting idea, I should give it a try and would let you know.

Thanks very much
Regards
Sume MS

(11-12-2017, 09:33 PM)falkoner Wrote: [ -> ]Hi, the problem with modifying the api is always to keep compatibility with existing applications that use it.

I would do something like the following (Nb I haven't tried this, so you may need to experiment a little)

Change each function call like this:

function InsertBranch($BranchDetails, $user, $password) becomes function InsertBranch($BranchDetails, $user, $password, $database_name='')

Then each function has a line

$db = db($user, $password);

which needs to be

$db = db($user, $password, $database_name);

Then within api_php.php the function declaration becomes:

function db($user, $password, $database_name) {
if (!isset($_SESSION['AccessLevel']) or $_SESSION['AccessLevel'] == '') {
// Login to default database = old clients.
if ($user != '' and $password != '') {
global $api_DatabaseName;
if ($database_name != '') {
$api_DatabaseName = $database_name;
}
$rc = LoginAPI($api_DatabaseName, $user, $password);
if ($rc[0] == UL_OK) {
return $_SESSION['db'];
}
}
return NoAuthorisation;
} else {
return $_SESSION['db'];
}
}

As I said I haven't actually tried it, but would be interested to know if it works out :-)

Tim


Hi

As a quick workaround, if I keep multiple folders for APIs with different databases, would it work?
For example:
http://domain.com/webERP/api-company1/api_xml-rpc.php
http://domain.com/webERP/api-company2/api_xml-rpc.php
http://domain.com/webERP/api-company3/api_xml-rpc.php

Regards
Sume
I think it is only api_php.php and api_xml-rpc.php that need a new version. So your client points to api_xml-rpc_1.php which in turn points to api_php_1.php etc, so you shouldn't need separate folders.

Again I haven't actually tried it, but it should work.

If my original solution works it is better because it is more generic and so could be put into the main line code.

Tim