2012-03-28 3 views
0

flex에서 웹 서비스를 호출 할 때 어떤 문제가 있습니다. 하나의 메소드 문자열 인 GetData (int i)를 사용하여 UserService라는 이름으로 서비스했습니다. 이 메서드를 flex에서 호출하여 데이터를 가져 오려고합니다. 내 코드는 여기에 있습니다 :flex에서 웹 서비스를 호출하는 방법

    protected function application1_creationCompleteHandler(event:FlexEvent):void 
     { 
      uService = new UserService(); 
      uService.addEventListener("hello", echoResultHandler); 
      uService.GetData(1);        
     } 

     public function echoResultHandler(event:ResultEvent):void { 
      var retStr:String = event.result as String;     
      var retInt:int = event.result.echoInt; 
      Alert.show('want to play', retStr); 
     } 

내 질문은 어렵지 않지만이 작품을 does't 왜 이해할 수 없다 .. 아무도 나를 도와 드릴 수 있습니다?

서비스 코드는 servee에 대한 참조를 추가 할 때 flex에 의해 생성됩니다.

internal class _Super_UserService extends com.adobe.fiber.services.wrapper.WebServiceWrapper 
{ 


    public function _Super_UserService() 
    { 

     _serviceControl = new mx.rpc.soap.mxml.WebService(); 
     var operations:Object = new Object(); 
     var operation:mx.rpc.soap.mxml.Operation; 

     operation = new mx.rpc.soap.mxml.Operation(null, "GetData"); 
     operation.resultType = String; 
     operations["GetData"] = operation; 

     _serviceControl.operations = operations; 
     try 
     { 
      _serviceControl.convertResultHandler = com.adobe.serializers.utility.TypeUtility.convertResultHandler; 
     } 
     catch (e: Error) 
     { } 


     preInitializeService(); 
     model_internal::initialize(); 
    } 

    protected function preInitializeService():void 
    { 


     _serviceControl.service = "UserService"; 
     _serviceControl.port = "BasicHttpBinding_IUserService"; 
     wsdl = "http://localhost:3905/UserService.svc?wsdl"; 
     model_internal::loadWSDLIfNecessary(); 
    } 

    public function GetData(value:int) : mx.rpc.AsyncToken 
    { 
     model_internal::loadWSDLIfNecessary(); 
     var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("GetData"); 
     var _internal_token:mx.rpc.AsyncToken = _internal_operation.send(value) ; 
     return _internal_token; 
    } 

} 

상속 클래스 :

public class UserService extends _Super_UserService 
{ 

    protected override function preInitializeService():void 
    { 
     super.preInitializeService(); 
     // Initialization customization goes here 
    } 

} 
+0

AsyncToken

var call : Asynctoken = uService.GetData(1); call.addResponder(new AsyncResponder(echoResultHandler)); 

대한 추가 정보를 원하시면, 무슨 일이 일어나고 있는지 알고 어려운 것입니다. UserService 코드를 보여주세요! – JeffryHouser

+0

나는 내가 이해하고 있는지 확신하지 못한다. .net 코드 또는 플렉스에 의해 생성 된 코드? – Radislav

+0

내 질문을 업데이트했습니다. – Radislav

답변

4

귀하의 UserService 클래스는 "안녕하세요"라는 이름의 이벤트를 전달하지; 따라서 결과 핸들러는 절대로 실행되지 않습니다. 결과 처리기를 ASynctoken에 추가해야한다고 생각합니다. 실제로 서비스를 호출하는 코드를보고하지 않고 AsyncResponder

+0

감사합니다. 나중에 확인하겠습니다. 희망이 도움이됩니다. – Radislav

+0

나는 당신이 말한 모든 것을했지만, 어떤 방식으로도 효과가 없습니다. echoResultHandler가 호출되지 않았습니다 ... 이유를 이해하지 못합니다. ( – Radislav

+0

감사합니다. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/에서 내 문제의 원인을 발견했습니다. AsyncResponder.html # AsyncResponder % 28 % 29 – Radislav

관련 문제