I'm struggling with finding a working JiBX binding for the client side of an
AndroMDA-generated Web Service and Axis2.
AndroMDA generates a WSDL and the POJOs. I want to use these server-side POJOs
also on the client side, by connecting them with JiBX to the WSDL. For
"singular" Value Object, this works fine, but a collection gives me problems.
The details: I have three UML classes, with a 1-to-* composition relation
between AContainer and AContainee:
@Service @WebService
class PeeringService{
+getContainers() : AContainer
}
@ValueObject
class AContainer{
+name : String
}
@ValueObject
class AContainee{
+id : int
}
AndroMDA generates this WSDL:
<wsdl:definitions ...>
<wsdl:types>
<xsd:schema ...>
<xsd:element name="getContainers">
<xsd:complexType/>
</xsd:element>
<xsd:element name="getContainersResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="getContainersReturn"
type="impl:AContainer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ArrayOfAContainee">
<xsd:sequence>
<xsd:element name="aContainee" minOccurs="0"
maxOccurs="unbounded" form="qualified" type="impl:AContainee" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="AContainee">
<xsd:all>
<xsd:element name="id" nillable="false" type="xsd:int"/>
<xsd:element name="aContainer" nillable="false"
type="impl:AContainer"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="AContainer">
<xsd:all>
<xsd:element name="name" nillable="false"
type="xsd:string"/>
<xsd:element name="aContainees" nillable="true"
type="impl:ArrayOfAContainee"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
...
</wsdl:definitions>
And these POJOs:
public class AContainer implements java.io.Serializable{
...
private String name;
public String getName(){ return this.name; }
public void setName(String name){ this.name = name; }
private AContainee[] aContainees;
public AContainee[] getAContainees(){ return this.aContainees; }
public void setAContainees(AContainee[] aContainees){ this.aContainees =
aContainees; }
}
public class AContainee implements java.io.Serializable{
...
private int id;
public int getId(){ return this.id; }
public void setId(int id){ this.id = id; }
private AContainer aContainer;
public AContainer getAContainer(){ return this.aContainer; }
public void setAContainer(AContainer aContainer){ this.aContainer =
aContainer; }
}
I'm trying this binding.xml:
<?xml version="1.0" encoding="UTF-8"?>
<binding force-classes="true" xmlns:tns="http://...peering.service"
value-style="element">
<namespace uri="http://...peering.service" default="elements"/>
<mapping abstract="true" type-name="tns:AContainee" class="AContainee"
ordered="false">
<value name="id" field="id" usage="optional"/>
<value name="aContainer" field="aContainer" usage="optional"/>
</mapping>
<mapping abstract="true" type-name="tns:AContainer" class="AContainer"
ordered="false">
<value name="name" field="name" usage="optional"/>
<collection field="aContainees" item-type="AContainee[]"/>
</mapping>
</binding>
The JiBX binding compiler runs fine.
Axis2's WSDL2Java runs fine, too.
My test implementation of the service gives me this response:
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getContainersResponse xmlns:ns="http://...peering.service">
<ns:getContainersReturn>
<ns:AContainees>
<ns:aContainee>
<ns:id>4711</ns:id>
</ns:aContainee>
<ns:aContainee>
<ns:id>4712</ns:id>
</ns:aContainee>
<ns:aContainee>
<ns:id>4713</ns:id>
</ns:aContainee>
<ns:aContainee>
<ns:id>4714</ns:id>
</ns:aContainee>
<ns:aContainee>
<ns:id>4715</ns:id>
</ns:aContainee>
</ns:AContainees>
<ns:name>name-of-container</ns:name>
</ns:getContainersReturn>
</ns:getContainersResponse>
</soapenv:Body>
</soapenv:Envelope>
But when I run the WSDL2Java-generated test client, it complains:
org.apache.axis2.AxisFault: No unmarshaller for element
"{http://..peering.service}AContainees" (line -1, col -1, in SOAP-message)
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:381)
at
...peering.client.PeeringServiceStub.convertException(PeeringServiceStub.java:808)
at
...peering.client.PeeringServiceStub.getContainers(PeeringServiceStub.java:368)
at ...peering.client.Main.main(Main.java:56)
Caused by: org.jibx.runtime.JiBXException: No unmarshaller for element
"{http://...peering.service}AContainees" (line -1, col -1, in SOAP-message)
at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2534)
at ...peering.service.JiBX_MungeAdapter.JiBX_binding_unmarshal_1_0()
at
...peering.service.AContainer.JiBX_binding_unmarshal_1_0(AContainer.java)
at ...peering.service.JiBX_bindingAContainer_access.unmarshal()
at
...peering.client.PeeringServiceStub.getContainers(PeeringServiceStub.java:352)
... 1 more
I then tried to deploy the TypedArrayMapper by adding this to binding.xml:
<mapping abstract="true"
type-name="tns:AContainees"
class="AContainee[]"
marshaller="org.jibx.extras.TypedArrayMapper"
unmarshaller="org.jibx.extras.TypedArrayMapper"/>
But it gives me the same runtime error.
I'm obviously missing a mapping definition, but I'm really lost here.
Besides getting this to work with a manually created binding.xml, is there a
more elegant way to even generate the binding.xml from (AndroMDA-generated)
WSDL?
Thanks!
-Max
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users