2009-10-16 152 views
1

UPDATE阅读E4X格式的XML:这个问题是不是与 命名空间或Flex做的。我的 webservice正在返回包装 xml。我在责怪java之前最少遇到的语言...问题使用Flex从SOAP Web服务

我有一个基本的soap webservice,我无法从flex读取结果。

我是一个坚实的java程序员,只是试图让我的头围绕adobe flex。

documentation我应该可以使用“WebService”以e4x格式返回结果。

<mx:WebService id="CurrentLayersWS" wsdl="http://localhost:8080/myproject/ws/myservice.wsdl" showBusyCursor="true" result="updateSelected(event)" fault="Alert.show(event.fault.faultString), 'Error'"> 
     <mx:operation name="publisher" resultFormat="e4x"> 
     <mx:request> 
     <publisherRequest> 
      <getConfiguration/> 
     </publisherRequest> 
     </mx:request> 
     </mx:operation> 
    </mx:WebService> 

正如你所看到的,响应由功能“updateSelected”它看起来像处理:

private function updateSelected(event:ResultEvent):void { 
    var responseXml:XML = XML(event.result); 

遗憾的是,事件对象似乎嵌套和奇怪的编码。当我步骤槽与调试我看到的responseXML是含有一个元素(索引0)的XML类型,其只包含下面的XML类型为XMLList:

<sch:temp xmlns:sch="http://www.mycompany.co.uk/myproject/schemas" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt; 
&lt;ns2:publisherResponse xmlns:ns2="http://www.mycompany.co.uk/myproject/schemas"&gt; 
    &lt;getConfigurationResponse&gt; 
     &lt;configuration&gt; 
     ...etc 

为什么嵌套在文档内我的XML用根节点“sch:temp”?

+0

我认为问题在于wsdl。在浏览器中打开http:// localhost:8080/myproject/ws/myservice.wsdl以查看内容 - 使用查看源查看确切内容。 – Amarghosh 2009-10-16 16:42:46

回答

0

问题不在于命名空间或flex。我的web服务正在返回包装的XML。我在责怪java之前最不经历的语言......

0

这是一个命名空间。我不确定它为什么会出现,但是我们在我们的一个Flex应用程序中开始使用.NET WebServices后,必须处理类似的事情。我只需在ActionScript中引用命名空间:

<mx:Script> 
    <![CDATA[ 
     private namespace schNamespace = "http://www.mycompany.co.uk/myproject/schemas"; 

     use namespace schNamespace; 
    ]]> 
</mx:Script> 

试试看......它可能工作。