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).  Does
anyone have a concrete example of this working?

My service looks like this:

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


@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"));
    }
}


@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;
    }
}

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


The WSDL looks fine.  Here is the schema section:
<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>

The content returned when invoking getThings is:
<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>

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

Does anyone have any hints on how to solve this problem?

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

Thanks in advance, 

Tim

P.S.  When I invoke getStrings, the content returned by the server is
missing a closing </soap:Envelope> tag, but the XFire client seems to be
able to deal with this and it works fine.  The Axis1 client fails.  However,
I'm more interested in making the getThings() method work.

-- 
View this message in context: 
http://www.nabble.com/problem-returning-list-of-objects-w--jsr181-jaxb2-binding-tf3717048.html#a10398633
Sent from the XFire - User mailing list archive at Nabble.com.


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

    http://xircles.codehaus.org/manage_email

Reply via email to