Archived
This forum has been archived. Please start a new discussion on GitHub.
Can icePHP connect to Ice server by iceGrid Mode?
How config?
0
Comments
-
As Benoit previously told you before we can offer you any assistance you must fill in your signature details. The instructions are contained http://www.zeroc.com/vbulletin/showthread.php?p=7297#post7297.0
-
up
up,up,up
up,up,up
up,up,up
up,up,up0 -
Hi,
Yes, it's possible for an IcePHP client to connect to a server managed by IceGrid. Like any Ice client, you just need to configure IcePHP with the locator proxy of the IceGrid locator (with the Ice.Default.Locator property). See the Ice manual for more information (section 30.16 contains information about configuring an Ice client to use a locator and the IceGrid chapter also contains information on configuring clients to use the IceGrid locator, section 36.4 in particular).
Cheers,
Benoit.0 -
More specifically for IcePHP, you can specify this Ice.Default.Locator property either in a configuration file (use the ice.config php configuration property) or on the command line (ice.options configuration property).
For example, if the IceGrid registry is located on host foo.com at port 10000 and uses the IceGrid instance name MyIceGrid (IceGrid.InstanceName=MyIceGrid in the IceGrid configuration file) then you can use:
ice.options=--Ice.Default.Locator=MyIceGrid/Locator:tcp -h foo.com -p 100000 -
help
my php.ini config:
ice.slice = "-I/root/ice /root/ice/Util.ice /root/ice/Passport.ice"
ice.options="--Ice.Default.Locator=pce/Locator:tcp -h 172.16.0.97 -p 12000"
the Passport.ice is:
#ifndef PASSPORT_CORE
#define PASSPORT_CORE
#include "Util.ice"
module oak{
module passport{
module core{
exception PassportException
{
string message;
};
exception NoSuchUserException extends PassportException{};
exception InvalidPasswordException extends PassportException{};
class NameToId{//ReverseNameToId
int uid;
int getId();
};
//interface
class PassportManager{
MyUtil::Str2StrMap getUserById(int id);
MyUtil::Str2StrMap getUserByUsername(string username);
MyUtil::Str2StrMap getUserByNickname(string nickname);
MyUtil::Str2StrMap getUserByName(string name);
MyUtil::Str2StrMap getUserExtById(int id);
MyUtil::Str2StrMap loginById(int id,string password);
MyUtil::Str2StrMap loginByUsername(string username,string password);
MyUtil::Str2StrMap loginByNickname(string nickname,string password);
MyUtil::Str2StrMap loginByName(string name,string password);
MyUtil::Str2StrMap registerUser(MyUtil::Str2StrMap props,MyUtil::Str2StrMap extprops);
void modifyUser(int uid, MyUtil::Str2StrMap props,MyUtil::Str2StrMap extprops);
void modifyUserPassword(int uid,string oldpwd,string password);
void resetUserPassword(int uid,string password);
void initNameToId();
};
}; }; };
#endif
my php scripts:
<?php
ice_loadProfile();
//ice_dumpProfile();
try
{
$base = $ICE->stringToProxy("PassportManager:default -p 12000");
$passport = $base->ice_checkedCast("::oak::passport::core::PassportManager");
$name = $passport->getUserById(1);
print $name;
}
catch(Ice_LocalException $ex)
{
print_r($ex);
}
?>
It throw the error below:
Ice_UnknownLocalException Object
(
[unknown] => Network.cpp:669: Ice::ConnectionRefusedException:
connection refused: Connection refused
[message:protected] =>
[string:private] =>
[code:protected] => 0
[file:protected] => /usr/local/bin/passport.php
[line:protected] => 8
[trace:private] => Array
(
[0] => Array
(
[file] => /usr/local/bin/passport.php
[line] => 8
[function] => ice_checkedCast
[class] => Ice_ObjectPrx
[type] => ->
[args] => Array
(
[0] => ::oak::passport::core::PassportManager
)
)
)
)
please help me!0 -
Hi,
The following line in your code:$base = $ICE->stringToProxy("PassportManager:default -p 12000");
means that the IcePHP runtime will try to connect to the localhost on port 12000 to try to talk to the object with the identity PassportManager. The Ice::ConnectFailedException indicates that nothing is listening on this port.
If you registered the PassportManager object as a well-known object with IceGrid, you should simply use the following proxy:$base = $ICE->stringToProxy("PassportManager);
Did you register this object as a well-known object? (either through the IceGrid deployment mechanism or directly with the icegridadmin tool or admin interface).
Cheers,
Benoit.0 -
the php.ini set
ice.slice = "-I/root/ice /root/ice/Util.ice /root/ice/Passport.ice"
ice.config="/root/ice/ice.config"
my ice.config
Ice.MessageSizeMax=10240
Service.Passport.Adapter=@Passport
Service.Passport.PassportManager.Identity=PassportManager
Service.Waist.Adapter=@Waist
Service.Waist.WaistManager.Identity=WaistManager
Service.Consume.Adapter=@Consume
Service.Consume.AccountManager.Category=AccountManager
Service.Statistics.StatisticsManager.Category=StatisticsManager
Service.Statistics.Adapter=@Statistics
Ice.Default.Locator=pce/Locator:default -h 211.100.33.107 -p 12000
if change the code to:
<?php
ice_loadProfile();
//ice_dumpProfile();
try
{
$base = $ICE->stringToProxy("PassportManager");
$passport = $base->ice_checkedCast("::oak::passport::core::PassportManager");
$name = $passport->getUserById(1);
print $name;
}
catch(Ice_LocalException $ex)
{
print_r($ex);
}
?>
then throw
Ice_UnknownLocalException Object
(
[unknown] => LocatorInfo.cpp:337: Ice::NotRegisteredException:
no object with id `PassportManager' is registered
[message:protected] =>
[string:private] =>
[code:protected] => 0
[file:protected] => /usr/local/bin/passport.php
[line:protected] => 7
[trace:private] => Array
(
[0] => Array
(
[file] => /usr/local/bin/passport.php
[line] => 7
[function] => ice_checkedCast
[class] => Ice_ObjectPrx
[type] => ->
[args] => Array
(
[0] => ::oak::passport::core::PassportManager
)
)
)
)0 -
Hi,
What are the following properties?Service.Passport.Adapter=@Passport Service.Passport.PassportManager.Identity=Passport Manager
They are not used in your IcePHP service. Did you register the object with the identity `PassportManager' as a well-known object with IceGrid? The Ice::NotRegisteredException would indicate that you didn't.
How did you deploy your server? If you deployed your server with an XML descriptor, please post the XML descriptor.
Cheers,
Benoit.0 -
ok,thanks!:)0