[英]XML parser failure: element is malformed. null
I have a flex 4.6 application calling a web service that access a MS SQl server. 我有一个Flex 4.6应用程序,该应用程序调用访问MS SQl服务器的Web服务。 I'm using (or trying to use) a web service I created.
我正在使用(或尝试使用)我创建的Web服务。 the web service seems to be working the XML being return looks OK but I'm getting the below error.
Web服务似乎正在工作,返回的XML看起来还可以,但是出现以下错误。
"XML parser failure: element is malformed. null"
I Google this error and did some research and what I gather, it is cause by how the XML is format coming from the web service. 我对这个错误进行了Google搜索,并做了一些研究和收集,这是由于XML来自Web服务的格式是如何造成的。
I have written the web service in c# and I tested it, The service is retuning the following XML structure: 我已经用C#编写了Web服务并对其进行了测试,该服务正在重新调整以下XML结构:
<root>
<pub>
<PublicationId>BIA-B0112</PublicationId>
<TargetPPODate>2012-02-28</TargetPPODate>
<TargetPPIDate>2012-03-13</TargetPPIDate>
<TargetRIPDate>2012-03-16</TargetRIPDate>
</pub>
</root>
the format don't look wrong to me, here my C# code that returns this. 格式对我来说似乎没有错,这是我的C#代码返回的格式。
// 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;
and here is the action script I'm using: 这是我正在使用的动作脚本:
<?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>
I'm new flex and web services so I'm having some trouble in this area , any help would be great. 我是新的Flex和Web服务,所以在这方面遇到了一些麻烦,任何帮助都将非常有用。
What I did not do is set the return type of the service in the data service is flash builder, once I did that the error was fix. 我没有做的是在数据服务中将服务的返回类型设置为Flash Builder,一旦我确定该错误已解决。 now I ran into another issue which I have to research.
现在我遇到了另一个必须研究的问题。 its now only retuning the root element of the return XML file, I need the data in the element..
现在只调整返回XML文件的根元素,我需要元素中的数据。
thanks everyone for helping. 感谢大家的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.