I’m not sure if the error was in the deserialization or the serialization back out.  What happens if you try to create the object for sending from scratch on the AS side?  Also can you post the WSDL that gets generated for this class?  I did see another bug the other day when we didn’t seem to serialize an array correctly, but in this case it seems like the whole thing is messed up, not just the array.

 

Matt

 


From: [email protected] [mailto:[email protected]] On Behalf Of Tim Dwelle
Sent: Friday, June 24, 2005 7:24 AM
To: [email protected]
Subject: [flexcoders] array blows up when passing to webservice

 

I am trying to communicate with a Java webservice implemented using Apache
Axis.  It has been working fine, until I tried sending an object with an
array property. When I call the webservice passing the array, I get the
following error:

org.xml.sax.SAXParseException: Element "xmlns:soapenc"cannot have "xmlns" as
its prefix.

I checked to make sure it wasn't an array.length = 1 issue... now I'm just
stumped. On the surface, it looks like Flex is not generating a valid SOAP
call to the webservice.

Below I have provided the Flex & Java code for a simplified example of the
problem.  The code has 2 buttons: 'Get Foo' which calls the webservice to
get a Foo object, and a 'Save Foo', which simply passes that Foo instance
back to the webservice. It blows up when you click 'Save Foo'.

I also have captured the SOAP traffic between client & server.

Any help would be appreciated.

Thanks in advance,

-Tim.



[Foo.java]

package com.dom.sampling.test;

import java.io.*;
import java.util.*;

public class Foo implements Serializable
{
      private Long id;
      private String name;
      private Set bars;

      public Long getId() { return id; }

      public void setId(Long id) { this.id = id; }

      public String getName() { return name; }

      public void setName(String name) { this.name = name; }

      public Set getBars() { return bars; }

      public void setBars(Set bars) { this.bars = bars; }
}


[Bar.java]

package com.dom.sampling.test;

import java.io.*;

public class Bar implements Serializable
{
      private Long id;
      private String name;

      public Long getId() { return id; }

      public void setId(Long id) { this.id = id; }

      public String getName() { return name; }

      public void setName(String name) { this.name = name; }
}


[FooService.java]

package com.dom.sampling.test;

import java.util.*;
import java.util.*;

public class FooService
{
      public Foo getFoo()
      {
            Bar bar1 = new Bar();
            bar1.setId(new Long(1));
            bar1.setName("bar1");

            Bar bar2 = new Bar();
            bar2.setId(new Long(2));
            bar2.setName("bar2");

            Set barSet = new HashSet();
            barSet.add(bar1);
            barSet.add(bar2);

            Foo foo = new Foo();
            foo.setId(new Long(1));
            foo.setName("foo");
            foo.setBars(barSet);

            return foo;
      }


      public Long saveFoo(Foo foo)
      {
            Set bars = foo.getBars();
            System.out.println("size = " + bars.size());
            return new Long(1);
      }
}


[Foo.as]

class com.dom.sampling.test.Foo
{
      public function Foo()
      {
            _remoteClass = "com.dom.sampling.test.Foo";
      }

      // properties
      public var id : Number;
      public var name : String;
      public var bars : Array = new Array();

      // remoting
      public var _remoteClass : String;
      private static var doRegister : Boolean =
Object.registerClass("com.dom.sampling.test.Foo", Foo);
}


[Bar.as]

class com.dom.sampling.test.Bar
{
      public function Bar()
      {
            _remoteClass = "com.dom.sampling.test.Bar";
      }

      // properties
      public var id : Number;
      public var name : String;

      // remoting
      public var _remoteClass : String;
      private static var doRegister : Boolean =
Object.registerClass("com.dom.sampling.test.Bar", Bar);
}


[Test.mxml]

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
                xmlns:dom="*">

      <mx:WebService id="service"
                     wsdl="/sampling-ws/services/FooService?wsdl"
                     showBusyCursor="true">

            <mx:operation name="getFoo"
                          result="model = event.result"/>

            <mx:operation name="saveFoo"
                          result="mx.controls.Alert.show('result='+event.result)"/>
      </mx:WebService>

      <mx:Script>
      <![CDATA[
            var model: com.dom.sampling.test.Foo;
      ]]>
      </mx:Script>

      <mx:Button label="Get Foo" click="service.getFoo()"/>

      <mx:Button label="Save Foo" click="service.saveFoo(model)"/>

</mx:Application>



[getFoo() request]


POST /sampling-ws/services/FooService HTTP/1.1

Accept: */*

x-flash-version: 7,0,19,0

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.1.4322)

Connection: Keep-Alive

Cache-Control: no-cache

Content-Type: text/xml; charset=utf-8

SOAPAction: ""

Host: 127.0.0.1

Cookie: $Version=0;
JSESSIONID=C8RMvp219rrF8SQPrLFs5bLM0Cv54SxcTXC29PqRZdng1MLwPfBQ!-1472445939

Content-Length: 388



<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body
xmlns:ns1="http://test.sampling.dom.com"><ns1:getFoo
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/></SOAP-ENV:Body></SOAP-ENV:Envelope>


[getFoo() response]


<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
  <ns1:getFooResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://test.sampling.dom.com">
   <getFooReturn href="">
  </ns1:getFooResponse>
  <multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:Foo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="urn:Dominion">
   <bars href="">
   <id href="">
   <name xsi:type="soapenc:string">foo</name>
  </multiRef>
  <multiRef id="id1" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <multiRef href="">
   <multiRef href="">
  </multiRef>
  <multiRef id="id2" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="soapenc:long"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</multiRef>
  <multiRef id="id3" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns3:Bar" xmlns:ns3="urn:Dominion"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <id href="">
   <name xsi:type="soapenc:string">bar2</name>
  </multiRef>
  <multiRef id="id4" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns4:Bar" xmlns:ns4="urn:Dominion"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <id href="">
   <name xsi:type="soapenc:string">bar1</name>
  </multiRef>
  <multiRef id="id6" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="soapenc:long"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</multiRef>
  <multiRef id="id5" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="soapenc:long"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2</multiRef>
</soapenv:Body>
</soapenv:Envelope>


[saveFoo() request]

POST /sampling-ws/services/FooService HTTP/1.1

Accept: */*

x-flash-version: 7,0,19,0

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.1.4322)

Connection: Keep-Alive

Cache-Control: no-cache

Content-Type: text/xml; charset=utf-8

SOAPAction: ""

Host: 127.0.0.1

Cookie: $Version=0;
JSESSIONID=C8RMvp219rrF8SQPrLFs5bLM0Cv54SxcTXC29PqRZdng1MLwPfBQ!-1472445939

Content-Length: 1707



<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body
xmlns:ns1="http://test.sampling.dom.com"><ns1:saveFoo
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><foo
xsi:type="ns2:Foo" xmlns:ns2="urn:Dominion"><bars
soapenc:arrayType="xsd:anyType[2]"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="soapenc:Array"><item xsi:type="xsd:anyType"><xmlns:soapenc
xsi:type="xsd:string">http://schemas.xmlsoap.org/soap/encoding/</xmlns:soapenc><xmlns:ns3
xsi:type="xsd:string">urn:Dominion</xmlns:ns3><xsi:type
xsi:type="xsd:string">ns3:Bar</xsi:type><soapenv:encodingStyle
xsi:type="xsd:string">http://schemas.xmlsoap.org/soap/encoding/</soapenv:encodingStyle><soapenc:root
xsi:type="xsd:string">0</soapenc:root><name
xsi:type="xsd:string">bar2</name><id
xsi:type="xsd:string">id3</id></item><item
xsi:type="xsd:anyType"><xmlns:soapenc
xsi:type="xsd:string">http://schemas.xmlsoap.org/soap/encoding/</xmlns:soapenc><xmlns:ns4
xsi:type="xsd:string">urn:Dominion</xmlns:ns4><xsi:type
xsi:type="xsd:string">ns4:Bar</xsi:type><soapenv:encodingStyle
xsi:type="xsd:string">http://schemas.xmlsoap.org/soap/encoding/</soapenv:encodingStyle><soapenc:root
xsi:type="xsd:string">0</soapenc:root><name
xsi:type="xsd:string">bar1</name><id
xsi:type="xsd:string">id4</id></item></bars><id xsi:type="ns3:long"
xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/">1</id><name
xsi:type="ns4:string"
xmlns:ns4="http://schemas.xmlsoap.org/soap/encoding/">foo</name></foo></ns1:saveFoo></SOAP-ENV:Body></SOAP-ENV:Envelope>


[saveFoo() response]


<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
  <soapenv:Fault>
   <faultcode>soapenv:Server.userException</faultcode>
   <faultstring>org.xml.sax.SAXParseException: Element
&quot;xmlns:soapenc&quot; cannot have &quot;xmlns&quot; as its
prefix.</faultstring>
   <detail>
    <ns1:hostname
xmlns:ns1="http://xml.apache.org/axis/">L110024794</ns1:hostname>
   </detail>
  </soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to