2009-07-02 3 views

답변

0

WebService SOAP/WSDL은 어떻습니까?

그래서 php에서 웹 서비스를 제공하고 Flex/AS3/Flash에서 웹 서비스 메서드를 호출하여 정보를 보내고이를 mysql db에 저장할 수 있습니다.

로 서버 방법으로 쉽게 호출 할 클라이언트 측 있도록 플렉스, 클래스 WebService을 가지고 : 나는 SOAP/WSDL을 제공하는 다스 라이브러리가 확신 PHP 측면에서

var webService:WebService = new WebService(); 
webService.wsdl = "http://yoursite.com/webservice.wsdl"; 
webService.loadWSDL(); 
webService.this_is_method_from_php_server(your_object_serialized_as_xml); 

.

1

아직 XML 사용과 관련이 없다면 AMF을 사용하는 것이 좋습니다. PHP 용 AMF에 대한 많은 OSS 구현이 있는데, 분명히 amfphp이라는 이름부터 Zend Framework에 구현 된 것까지입니다. 여기에 경험이있는 누군가가 와서 더 좋은 대답을 주길 바랍니다.

0

amfPHP를 사용하여 PHP를 통해 Flash에 전달 된 MySQL 데이터베이스에서 정보를 얻는 것이 좋습니다. PHP를 사용하여 xml로 데이터베이스 결과를 출력하는 것보다 쉽고 빠르며 사용하기 쉽습니다. 기본적으로 amfPHP로하는 일은 LocalConnection 클래스를 사용하여 플래시에서 php 함수를 직접 호출 할 수 있다는 것입니다.

나는 그것이 어떻게 작동하는지 설명하기 위해 몇 가지 코드를 단순화 할 수 있습니다 :

//PHP code 
//Here's you main php class which all the sql commands will be called 

    class Main{ 
     public function saveUser($username, $password){ 
      //I'll send in the username and password to insert it into the users column 
      $this->db->query("INSERT INTO users VALUES ($username, $password)"); 
      //I'm using the MDB2 library for sql queries, 
      //you write less code when doing queries. 
     } 
    } 

    //Actionscript 3 code 

    //To pass parameters to my php function I have to make an array. 
    var amfParameters:Array = []; 
    amfParameters['username'] = "richard"; 
    amfParameters['password'] = "123123"; 

    //Then create a localconnection which will connect to amfphp. 
    var localConnection:LocalConnection = new LocalConnection(); 
    localConnection.connect(gatewayURL); //gatewayURL is the url to the gateway amfphp file 
    localConnection.call("testproject.Main.saveUser", loaderResponder, amfParameters); 
    //testproject.Main.saveUser is the path for our Main.php file and saveUser is the function 
    //loaderResponder is a Responder class which handles the callback from amfphp. 

그래서 기본적으로 당신은 플래시 PHP 함수를 호출합니다, 당신은 또한 aswell 플래시에 데이터를 반환 할 수 있습니다.

이것은 amfphp의 작동 방식을 약간 설명하기위한 것입니다. 완전한 코드 샘플이되는 것은 아닙니다. 간단한 생각을 말하면됩니다.

생각해 보면 재미있을 것 같아서 amfphp를 다운로드하여 사용해보십시오! 당신은 실망하지 않을 것입니다.

관련 문제