Hi,
my name is Mirco Casoni and I'm working on an open source project
(http://jbi4corba.sourceforge.net/) where we are using XFire.
I have a problem in the "JAVA to WSDL" transformation related to the bug
XFIRE-462.
I have a class with a java byte attribute mapped to the following WSDL
[...]
<xsd:element minOccurs="0" name="fieldOctet" type="ns2:byte"/>
<xsd:complexType abstract="true" name="byte"/>
[...]
But I'm expected something like
<xsd:element minOccurs="0" name="fieldOctet" type="xsd:byte"/>
because this is the right mapping defined in the specification. (CORBA
to WSDL/SOAP Interworking Specification Version 1.2)
To solve the problem I implemented a "custom mapping" for the primitive
java byte (using the class in attachment) and now the WSDL is exactly as
I expected and I have no more problems runtime when I send a soap
message that contains this kind of data type.
I hope this solution may help somebody and I'd like your opinion about it.
thanks
mirco
package it.imolinfo.jbi4corba.webservice.runtime;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.aegis.MessageReader;
import org.codehaus.xfire.aegis.MessageWriter;
import org.codehaus.xfire.aegis.type.Type;
import org.codehaus.xfire.fault.XFireFault;
/**
* This class is used to customize the 'byte' data type (java) mapping in XFire.
*/
public class ByteType extends Type {
/**
* Logger.
*/
private static final Log LOG = LogFactory.getLog(ByteType.class);
/**
* Empty Constructor.
*
* Setting up the XML Schema.
*/
public ByteType() {
setNillable(true);
setSchemaType(new QName("http://www.w3.org/2001/XMLSchema","byte"));
setTypeClass(byte.class);
}
@Override
public Object readObject(MessageReader reader, MessageContext context)
throws XFireFault {
LOG.debug(">>>>> ByteType.readObject - begin:" + reader.getValue());
String value = reader.getValue();
if (value == null || "".equals(value)){
LOG.debug("<<<<< ByteType.readObject - end: the value is null.");
return null;
}
LOG.debug("<<<<< ByteType.readObject - end: the value is " + value);
return new Byte(value);
}
@Override
public void writeObject(Object object,
MessageWriter writer,
MessageContext context) throws XFireFault {
LOG.debug(">>>>> ByteType.writeObject - begin: object=" + object
+ "; class=" + object == null ? "" :object.getClass());
writer.writeValue(object == null ? "" : object.toString());
LOG.debug("<<<<< ByteType.writeObject - end");
}
}
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email