저는 Flex 초보자이며 WebAPI 서비스에서 정보를 받아 표시하는 MXML 응용 프로그램을 작성하고 있습니다.WebAPI에서 Flex로 객체 반환
지금까지 간단한 문자열로이를 처리했지만 복잡한 객체를 반환하려고하면 null을 반환합니다.
여기 그것은 매우 간단한 형태의, 내 코드입니다 :
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:acrs_surveys="services.acrs_surveys.*"
xmlns:valueObjects="valueObjects.*"
minWidth="955" minHeight="600">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
protected function button_clickHandler(event:MouseEvent):void
{
GetSurveyResult.token = acrs_surveys.GetSurvey(itemidTextInput.text);
}
protected function button2_clickHandler(event:MouseEvent):void
{
survey.SurveyId = surveyIdTextInput.text;
survey.Title = titleTextInput.text;
}
protected function assignSurveyResult(event:ResultEvent):void
{
survey = event.result as Survey;
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="GetSurveyResult" result="assignSurveyResult(event)"/>
<valueObjects:Survey id="survey"/>
<acrs_surveys:Acrs_surveys id="acrs_surveys" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true" />
</fx:Declarations>
<s:Form defaultButton="{button}">
<s:FormItem label="Itemid">
<s:TextInput id="itemidTextInput"/>
</s:FormItem>
<s:Button id="button" label="GetSurvey" click="button_clickHandler(event)"/>
</s:Form>
<s:Form defaultButton="{button2}">
<s:FormHeading label="Survey"/>
<s:FormItem label="Questions">
<s:Label id="QuestionsLabel" text="Questions_type[]"/>
</s:FormItem>
<s:FormItem label="SurveyId">
<s:TextInput id="surveyIdTextInput" text="{survey.SurveyId}"/>
</s:FormItem>
<s:FormItem label="Title">
<s:TextInput id="titleTextInput" text="{survey.Title}"/>
</s:FormItem>
<s:Button id="button2" label="Submit" click="button2_clickHandler(event)"/>
</s:Form>
</s:Application>
코드는 대부분 플래시 빌더의 마법사에 의해 생성되었습니다. "Survey"클래스는 Generate Service Call 마법사에 의해 생성되었으며 동일한 마법사에 의해 정의 된 GUID, Title 및 Question 개체 목록의 세 가지 속성을 포함합니다.
코드를 실행하면 오류가 발생하지 않고 네트워크 모니터에 따라 호출이 성공적으로 완료되고 데이터가 반환됩니다. 그러나 assignSurveyResult에서 코드를 해독하고 측량 객체를 검사하면 결과가 null입니다.
설문 제목 만 문자열로 반환하는 WebAPI 호출을 사용하도록 코드를 변경하면 올바르게 작동합니다. 그것은 작동하지 않는 객체 들인 것처럼 보입니다.
내가 뭘 잘못하고 있니?