PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: kofiaddaquay on September 09, 2008, 12:46:03



Title: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 09, 2008, 12:46:03
Hi everyone, i really need some help figuring out why i am getting an error with my app. i am trying to rebuild the Login weborb sample, but this time using AMFPHP. all the logic for the remote object has been set up for working with AMFPHP. But when i try to log in, i get this error

Argument 1 passed to LoginService::getUser() must be an instance of LoginVO, array given

its driving me nuts, because a LoginVO type is what is sent to the _loginService remoteobject when the getUser is called

public function getUser( vo : LoginVO ):void
{
   _loginService.getUser( vo );  <-- HERE   
   CursorManager.setBusyCursor();
}

but i still get the above error ???

i am also suspecting that my php VO and my actionscript VO paths dont match. cant this really be a problem?

my login service has a source of

_loginService.source = "BuiPower.LoginService";

within my Services folder, i have the BuiPower folder then the LoginService.php file. it looks like this (i have removed code so this post isnt too chunky)

<?php

class LoginService
{
   public function __construct()
   {
      //code to connect to db etc
   }
   
   function getUser(LoginVO $loginVO)
   {
      include_once("../vo/net/scriptoninteractive/flex/weborb/buipower/model/vo/LoginVO.php");

    ....(more code to authenticate credentials)
    }
}

?>

finally my actionscript VO and php VO look like this

package net.scriptoninteractive.flex.weborb.buipower.model.vo
{
   [RemoteClass(alias="BuiPower.LoginVO")]   <--notice as VO path isnt same as php
      [Bindable]
   public class LoginVO
   {
      public var username: String;
      public var password: String;
      public var loginDate: Date;
   }   
}
and the php VO which is located in the services folder as
vo/net/scriptoninteractive/flex/weborb/buipower/model/vo/LoginVO.php is

<?php
class LoginVO
{
   var $username;
      var $password;
   var $loginDate;
   
   //explicit actionscript package
   var $_explicitType = "net.scriptoninteractive.flex.weborb.buipower.model.vo.LoginVO";
}
?>

does anyone have any idea...or can share how they have done it with AMFPHP. thanks a bunch!

Sincerely,
Kofi Addaquay


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 09, 2008, 01:14:21
Hi kofi,

The problem is server side, where do you have your LoginVO in amfphp? what directory? it may depend on your amfphp configurations.

Daniel Gomes


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 09, 2008, 08:50:10
Thanks for your reply Daniel...

the LoginVO is located in my Services folder under the "vo" folder...like this

Services -> vo -> net -> scriptoninteractive -> flex -> weborb -> buipower -> model -> vo -> LoginVO.php


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 09, 2008, 09:01:25
Try this on LoginVO.as:


package net.scriptoninteractive.flex.weborb.buipower.model.vo
{
   [RemoteClass(alias="net.scriptoninteractive.flex.weborb.buipower.model.vo.LoginVO")]   
      [Bindable]
   public class LoginVO
   {
      public var username: String;
      public var password: String;
      public var loginDate: Date;
   }   
}

The paths must be exactly in server side and client side.

Daniel Gomes


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 09, 2008, 09:22:40
thats what i thought too...but every time i have my LoginVO like this..

package net.scriptoninteractive.flex.weborb.buipower.model.vo
{
   [RemoteClass(alias="net.scriptoninteractive.flex.weborb.buipower.model.vo.LoginVO")]   
      [Bindable]
   public class LoginVO
   {
      public var username: String;
      public var password: String;
      public var loginDate: Date;
   }   
}

my php loginVO looks like this

<?php
class LoginVO
{
   var $username;
      var $password;
   var $loginDate;
   
   //explicit actionscript package
   var $_explicitType = "net.scriptoninteractive.flex.weborb.buipower.model.vo.LoginVO";   
}
?>



and then i change my remoteobject from

_loginService.source = "BuiPower.LoginService";

to this

_loginService.source = "net.scriptoninteractive.flex.weborb.buipower.LoginService";

I now get this error:

"Channel Disconnected"

and this happened when i noticed that the paths are supposed to be the same. my attempt to do has brought me to this error. do you know what this is Daniel?

Thanks


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 09, 2008, 09:28:36
where is your LoginService.php file? what directory?

if you have LoginService in services/LoginService.php

your source was to be like this: _loginService.source = "LoginService";

But when i use PureMVC i always use the same directory structure on both (server side and client side).

Use the Service Capture and see what happen.

And make sure that all paths are correctly.

Daniel Gomes


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 09, 2008, 09:40:27
my LoginService.php is located here:

Services -> net -> scriptoninteractive -> flex -> weborb -> buipower -> LoginService.php

thats why i have it like this

_loginService.source = "net.scriptoninteractive.flex.weborb.buipower.LoginService";

so that should work right?

what is service capture?


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 09, 2008, 09:43:27
Service Capture is a software to see what happens when you call web services you can download the trial here:

http://kevinlangdon.com/serviceCapture/

Probably it's working but maybe it's something wrong in your database connection or authenticate credentials and you only see it if you use Service Capture i think. Channel Disconnect can be a lot of tip of errors.

Daniel Gomes


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 09, 2008, 12:33:11
Have you ever seen this with servicecapture

correlationId (String):
faultCode (String): AMFPHP_FILE_NOT_FOUND
faultDetail (String): /Users/kofiaddaquay/Sites/amfphp2/core/shared/app/BasicActions.php on line 33
faultString (String): The class {Amf3Broker} could not be found under the class path {/Users/kofiaddaquay/Sites/amfphp2/services/amfphp/Amf3Broker.php}

file not found? i dont understand. everything is in the right position :(


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 09, 2008, 12:43:16
weird thing is that when i take the contents of the vo folder located in services and put it in the services root, it takes me back to the error

Argument 1 passed to LoginService::getUser() must be an instance of LoginVO, array given


instead of

vo/net/scriptoninteractive/flex/weborb/buipower/model/vo/LoginVO.php

i have

net/scriptoninteractive/flex/weborb/buipower/model/vo/LoginVO.php

then i get the above error. but amfphp requires you have it in the vo folder :(


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 09, 2008, 01:28:38
Take a look in LoginService

function getUser(LoginVO $loginVO)
   {
      include_once("../vo/net/scriptoninteractive/flex/weborb/buipower/model/vo/LoginVO.php"); <-------------- This path is totally correct?

    ....(more code to authenticate credentials)
    }


try change it to: "../../../../../../vo/net/scriptoninteractive/flex/weborb/buipower/model/vo/LoginVO.php"

Daniel Gomes


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 09, 2008, 09:44:23
well..every since you said you keep your services in the root of the services folder...i have now put the loginservice.php in that directory. the reverse domain syntax was also too long i cut it down. so the function looks like

function getUser(LoginVO $loginVO)
   {
      include_once("vo/net/scriptoninteractive/buipower/model/vo/LoginVO.php");

    ....(more code to authenticate credentials)
    }

but why ../../../../../../vo/net/scriptoninteractive/flex/weborb/buipower/model/vo/LoginVO.php? isnt that going too far back in the folder directory? i will try it anyway!


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 10, 2008, 01:48:11
well..every since you said you keep your services in the root of the services folder

My english is a little bad, but i think i never said that, because i always use the same file/directory structure in client side and server side, soo that's way i told you to return back in folder directory, but if you have it in your root Services it should work with ../vo/net/scriptoninteractive/flex/weborb/buipower/model/vo/LoginVO.php. But my advice is to use the same structure of PureMVC. The problem here is some path's that are incorrect or a little bug, use the amfphp browser and see if it's working (i'm talking about the LoginService).

Daniel Gomes


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 10, 2008, 11:20:11
Hi :)

thats another problem i am having. in the service browser you are asked for loginVO...what parameter do i put in? username and password are 2 params and not one. is there a way to format username and password into one string to test the service? like some kind of object..get what i mean?


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 10, 2008, 11:48:03
so, i make a call to the service using this json string

"[{username: 'kofi', password: 'kofi', loginDate:'test'}]"

and i get this

(Object)#0
  message = "faultCode:AMFPHP_RUNTIME_ERROR faultString:'Argument 1 passed to LoginServiceFacade::getUser() must be an instance of LoginVO, string given' faultDetail:'/Users/kofiaddaquay/Sites/amfphp2/services/LoginServiceFacade.php on line 26'"
  name = "Error"
  rootCause = (null)

one thing is for sure. the LoginVO class cannot be seen. why? i dont know


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 10, 2008, 01:58:05
Show all your php codes and folder/file structure, let's see what is happening, but it's strange for sure :| But for me the only problem is Paths or AMFPHP configuration.

Daniel Gomes


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 10, 2008, 08:14:49
Really appreciate the help Daniel.

so that i dont have code all over the page, i am attaching a link so you can see all the php files. its a simple structure. one service and one value object php file

http://www.scripton.net/flash/_projects/kofiamfphp.zip



Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 11, 2008, 02:35:32
I found the problem.

AMFPHP, only recognize VO and Paths if the VO and the php Service file have the same structure. So you need to have it:

The LoginServiceFacade.php have to be in this directory -> services/net/scriptoninteractive/buipower/model
The LoginVO.php have to be here -> services/vo/net/scriptoninteractive/buipower/model/vo

Now you have to change all paths inside of files, it should work now.

Daniel Gomes


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: kofiaddaquay on September 11, 2008, 08:19:11
i have done that..but still getting the error

correlationId (String):
faultCode (String): AMFPHP_FILE_NOT_FOUND
faultDetail (String): /Users/kofiaddaquay/Sites/amfphp2/core/shared/app/BasicActions.php on line 33
faultString (String): The class {Amf3Broker} could not be found under the class path {/Users/kofiaddaquay/Sites/amfphp2/services/amfphp/Amf3Broker.php}


BUT!..i did switch over to weborb, and my login works fine against the database! this makes me happy but at the same time i am not sure if i want to use weborb. do you use it? i was under the impression that amfphp has a larger community and i can get help when i need it than when i use weborb. please advice. i dont know if i want to waste anymore time debugging amfphp when the main focus should be on the main application.

i will still spend sometime and make sure all my paths are right for amfphp to see if i can continue there...but in the mean time i will continue with weborb so i can make progress. let me know your thoughts on the above. thanks for your time Daniel..i really appreciate it.

Kofi


Title: Re: Weborb Login Sample using AMFPHP instead
Post by: danielcsgomes on September 11, 2008, 11:24:07
Yes i use it, for me it's more easier to work then amfphp at least for PureMVC you don't need to have the VO in a different folder and Weborb can generate code and in the next release 3.5 you will have data management it will be a very nice feature :D

In AMFPHP it should work now, i tried and it works.

Daniel Gomes