Problem returning list of objects with jsr181/jaxb2 binding
-----------------------------------------------------------

                 Key: XFIRE-992
                 URL: http://jira.codehaus.org/browse/XFIRE-992
             Project: XFire
          Issue Type: Bug
          Components: JAXB 2.0
    Affects Versions: 1.2.6
         Environment: Linux, Java 1.5
            Reporter: Tim Morrow
            Assignee: Dan Diephouse


I'm using XFire 1.2.6 and trying to return a list of objects from a service 
method.  I'm using jsr181 and jaxb2 annotations.  I just can't seem to get it 
to work.  It seems like the XML produced by the server does not match the WSDL 
(or at least, doesn't match what WSDL-generated clients expect). 

I'm _pretty_ sure its not a namespace issue.

My service looks like this:

{code:title=MyService.java}
@SOAPBinding
@WebService(name = "MyServiceInterface", targetNamespace = 
"http://ws.mycompany.com";)
public interface MyService
{
    List<Thing> getThings();
    List<String> getStrings();
}
{code}

{code:title=MyServiceImpl.java}
@WebService(serviceName = "MyService", endpointInterface = 
"com.mycompany.MyService")
public class MyServiceImpl implements MyService
{
    public List<String> getStrings()
    {
        return Collections.singletonList("the string");
    }
    public List<Thing> getThings()
    {
        return Collections.singletonList(new Thing("the thing"));
    }
}
{code}

{code:title=Thing.java}
@XmlType(
        name = "Thing",
        namespace = "http://ws.mycompany.com/model";
    )
public class Thing
{
    private String name;
    public Thing()
    {
        super();
    }
    public Thing(String name)
    {
        this.name = name;
    }
    public String getName()
    {
        return name;
    }
    public void setName(String name)
    {
        this.name = name;
    }
}
{code}

I do have a package-info.java in the same package as Thing.java with this:
{code:title=package-info.java}
@javax.xml.bind.annotation.XmlSchema(namespace = 
"http://ws.mycompany.com/model";, elementFormDefault = 
javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
{code}

The WSDL looks fine.  Here is the schema section:
{code:xml}
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
attributeFormDefault="qualified" elementFormDefault="qualified"
  targetNamespace="http://ws.mycompany.com";>
  <xsd:element name="getStrings">
    <xsd:complexType />
  </xsd:element>
  <xsd:complexType name="ArrayOfString">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="string" 
nillable="true" type="xsd:string" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="getStringsResponse">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" 
type="tns:ArrayOfString" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="getThings">
    <xsd:complexType />
  </xsd:element>
  <xsd:element name="getThingsResponse">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" 
type="ns1:ArrayOfThing" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
attributeFormDefault="qualified" elementFormDefault="qualified"
  targetNamespace="http://ws.mycompany.com/model";>
  <xsd:complexType name="ArrayOfThing">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="Thing" 
nillable="true" type="ns1:Thing" />
    </xsd:sequence>
  </xsd:complexType>
  <xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema"; name="Thing">
    <xs:sequence>
      <xs:element minOccurs="0" name="name" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xsd:schema>
{code}

The content returned when invoking getThings is:
{code:xml}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <soap:Body>
    <getThingsResponse xmlns="http://ws.mycompany.com";>
      <out xmlns="http://ws.mycompany.com";>
        <ns2:out xmlns="http://ws.mycompany.com/model"; 
xmlns:ns2="http://ws.mycompany.com";>
          <name>the thing</name>
        </ns2:out>
      </out>
    </getThingsResponse>
  </soap:Body>
</soap:Envelope>
{code}

With an XFire-generated JAXB client, it fails (silently!) to unmarshall the 
XML.  I also tried an Axis1 generated client, it failed with this message:
{{org.xml.sax.SAXException: Invalid element in 
com.mycompany.ws.model.ArrayOfThing - out}}

My workaround is to not return {{List<Thing>}}, instead create my own container 
class (i.e. manually create ArrayOfThing) and everything works fine.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to