2012-02-25 2 views
0

MS SQl 서버에 액세스하는 웹 서비스를 호출하는 flex 4.6 응용 프로그램이 있습니다. 내가 만든 웹 서비스를 사용하고 있습니다. 웹 서비스가 작동하고있는 것으로 보입니다. 반환되는 XML이 정상적으로 보이지만 아래 오류가 나타납니다.XML 파서 오류입니다. 요소의 형식이 잘못되었습니다. null

"XML parser failure: element is malformed. null" 

이 오류를 구글과 몇 가지 연구와 제가 수집는 XML 웹 서비스에서 오는 형식이 얼마나 의해 원인을했다.

나는 C#에서 웹 서비스를 작성하고 난,이 서비스는 다음과 같은 XML 구조 재곡되어 그것을 테스트 : 형식이 나에게 잘못 보이지 않는

<root> 
<pub> 
<PublicationId>BIA-B0112</PublicationId> 
<TargetPPODate>2012-02-28</TargetPPODate> 
<TargetPPIDate>2012-03-13</TargetPPIDate> 
<TargetRIPDate>2012-03-16</TargetRIPDate> 
</pub> 
</root> 

을이를 반환, 여기 내 C# 코드를 .

<?xml version="1.0" encoding="utf-8"?> 
<s:WindowedApplication 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:service1="services.service1.*" 
         width="529" height="322"> 

    <fx:Script> 
     <![CDATA[ 
      import com.adobe.serializers.utility.TypeUtility; 

      import mx.controls.Alert; 
      import mx.events.FlexEvent; 


      protected function dataGrid_creationCompleteHandler(event:FlexEvent):void 
      { 
       PubInfoResult.token = service1.PubInfo("FRP-Q0112"); 
      } 

     ]]> 
    </fx:Script> 

    <fx:Declarations> 
     <s:CallResponder id="PubInfoResult"/> 
     <service1:Service1 id="service1" 
          fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" 
          showBusyCursor="true"/> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 


    </fx:Declarations> 
    <s:TextInput id="BookCode" x="9" y="22"/> 
    <s:DataGrid id="dataGrid" x="75" y="95" 
       creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4"> 
     <s:columns> 
      <s:ArrayList> 
      </s:ArrayList> 
     </s:columns> 
     <s:typicalItem> 
      <fx:Object></fx:Object> 
     </s:typicalItem> 
     <s:AsyncListView list="{TypeUtility.convertToCollection(PubInfoResult.lastResult)}"/> 
    </s:DataGrid> 


</s:WindowedApplication> 

내가이 분야에서 몇 가지 문제가 있어요 그래서 새로운 플렉스 및 웹 서비스를 해요, 어떤 도움이 좋을 것 : 여기

// Connect to the database and run the query 
SqlConnection conn = new SqlConnection(bldr.ToString()); 
SqlCommand cmd = new SqlCommand("AWFE.dbo.Connect_PubInfo"); 
cmd.CommandType = System.Data.CommandType.StoredProcedure; 
cmd.Parameters.Clear(); 
cmd.Parameters.Add(new SqlParameter("@Pubid", BookName)); 
conn.Open(); 
cmd.Connection = conn; 

SqlDataAdapter da = new SqlDataAdapter(); 
DataSet ds = new DataSet(); 
ds.DataSetName = "root"; 
da.SelectCommand = cmd; 
da.Fill(ds, "pub"); 

// Return the data as XML 
XmlDocument xmlDoc = new XmlDocument(); 
xmlDoc.LoadXml(ds.GetXml()); 
return xmlDoc; 

내가 사용하고 액션 스크립트입니다.

+0

귀하의 XML이 정확하고'XmlDocument' ()가 귀하의 XML을로드 할 수 있습니다. 귀하의 버그는 다른 곳에 있습니다. 'ds.GetXml()'을 인쇄 해보십시오. –

답변

0

데이터 서비스에서 서비스의 리턴 유형을 설정하는 것은 플래시 빌더입니다. 일단 오류가 수정되면 완료됩니다. 이제 나는 연구해야 할 또 다른 문제에 봉착했다. 그것의 지금 반환 XML 파일의 루트 요소를 retuning, 나는 요소의 데이터가 필요합니다 ..

도움을 주신 모든 분들께 감사드립니다.

+0

PubInfoResult.lastResult를 PubInfoResult.lastResult.pub로 변경해보십시오. –

관련 문제