Hi,
I'm afraid I'm not a java programmer so cannot provide examples there - but here's some PHP.
You need to include some kind of SOAP interface code - Sugar themselves use nusoap - so I used the same for our mods.
For the 'test' code you posted you could do something like the following:
Code:
<?php
require_once('C:\Program Files\Apache Group\Apache2\htdocs\sugarcrm\include\nusoap\nusoap.php');
$client = new nusoapclient('http://localhost/sugarcrm/soap.php');
$param1 = "Hello World!";
$result = $client->call('test',$param1);
?>
A more complex - but not very elegant - real world application would be like:
Code:
#!/php/php.exe
<?php
$GLOBALS['sugarEntry'] = true;
require_once('C:\Program Files\Apache Group\Apache2\htdocs\sugarcrm\include\nusoap\nusoap.php');
$client = new nusoapclient('http://localhost/sugarcrm/soap.php');
$client->debug_flag=true;
//LOGIN (array-based parameter structure for the soap call)
$a1 = "A_USERNAME";
$a2 = "3456f2b06265498g54333bff4e1234567";
$a3 = ".01";
$p1 = array(
'user_name' => $a1,
'password' => $a2,
'version' => $a3
);
$result = $client->call('login',array('parameters' => $p1));
$sessionId = $result[id];
..
..
..
//execute select query on 'users' table to select those with give email address.
$aa1 = $sessionId;
$aa2 = "Users";
$aa3 = "email1 = '".$userEmail."' OR email2 = '".$userEmail."'";
$aa4 = "";
$aa5 = 0;
$aa6 = array('user_name');
$aa7 = 0;
//a more complex array structure
$pp1 = array(
'session' => $aa1,
'module_name' => $aa2,
'query' => $aa3,
'order_by' => $aa4,
'offset' => $aa5,
'select_fields' => $aa6,
'max_results' => $aa7
);
$queryresult = $client->call('get_entry_list', $pp1);
..
..
..
//LOGOUT (simple string based call)
$param1 = $sessionId;
$result = $client->call('logout',$param1);
?> Doesn't include error checking - usually part of the data structure returned in the result. Eg. for the login:
Code:
..
..
$result = $client->call('login',array('parameters' => $p1));
if($result[error][number]!='0') {
myLoggingCode($result[error][description]);
Die;
}
Bookmarks