I'm using JAXWS 1.2 and I am trying to generate a web service client from a
wsdl, it works but I have a couple of minor issues:
1) Unmarshalling does not find a needed class
Inside of my wsdl I have the following type:
...
| <s:complexType name="ItemValue">
| <s:sequence>
| <s:element minOccurs="0" maxOccurs="1" name="DiagnosticInfo"
type="s:string"/>
| <s:element minOccurs="0" maxOccurs="1" name="Value"/>
| </s:sequence>
| <s:attribute name="ItemName" type="s:string"/>
| </s:complexType>
| ...
wsconsume generates the following java class file
import javax.xml.bind.annotation.*;
|
| @XmlAccessorType(XmlAccessType.FIELD)
| @XmlType(name = "ItemValue", propOrder = {
| "value"
| })
| public class ItemValue {
|
| @XmlElement(name = "Value")
| protected Object value;
| @XmlAttribute(name = "ItemName")
| protected String itemName;
|
| //... getters and setters
| }
Everything works fine if "value" is a java type, for instance float
<ItemValue xmlns='http://opcfoundation.org/webservices/XMLDA/1.0/'
ItemName='Channel1.Device1.ComulativeElectric'>
| <Value xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:type='xsd:float'>6428.76806640625</Value>
| </ItemValue>
However, if value is of some other generated type, in my case
ArrayOfUnsignedInt, this class is not visible to the JAXBContent used at
unmarshalling and the value is left unmarshalled (DOM element).
What is the proper way to provide JAXBContent with the extra class needed for
unmarshalling?
I believe somewhere I would need to put something like:
JAXBContext jaxbContext = JAXBContext.newInstance(ItemValue.class,
ArrayOfUnsignedInt.class);
Or is there some annotation that could be added to class ItemValue which would
provide JAXB with the necessary information for unmarshalling? Or could I
somehow modify the wsdl (created by a third party)?
2) Modifying binding
The received SOAP message contains a 64-bit value marked as 'xsd:float'
<ItemValue xmlns='http://opcfoundation.org/webservices/XMLDA/1.0/'
ItemName='Channel1.Device1.ComulativeElectric'>
| <Value xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:type='xsd:float'>6428.76806640625</Value>
| </ItemValue>
JAXB (correctly) unmarshals this value to 6428.768 (java.lang.Float).
What is the easiest way to override this binding (to say java.lang.Double) in a
web service client?
Regards,
Magnus
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4027437#4027437
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4027437
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user