users@jax-rpc.java.net

Serializing XML

From: Honorez Dylan <Dylan.Honorez_at_cronos.be>
Date: Tue, 1 Mar 2005 12:33:45 +0100

Hi,

 

It was brought to my attention that wscompile generates serializers from
my wsdl, next to the objects. In a previous version, I generated xml by
myself from the objects I had, but it would be interesting to see if I
can do this with the generated serializers.

 

Problem is, I've been trying this a week ago, but still couldn't
generate a decent XML. Has anybody any experience with this?

 

Sample code:

 

//vma initialized by soap message

vma = new VersionManagedApplication(newVersionManagedApplicationRequest,
UUIDGenerator.newId(), c, null);

 

VersionManagedApplication_LiteralSerializer vmals = new
VersionManagedApplication_LiteralSerializer(

new QName("http://www.xt-i.com/version/", "VersionManagedApplication"),
"UTF-8"

);

 

xmlw = new XMLWriterImpl(new
FileOutputStream(xmlFileDir.getAbsolutePath() + "/" +
newVersionManagedApplicationRequest + ".xml"), "UTF-8", true);

VersionManager_SerializerRegistry vmsr = new
VersionManager_SerializerRegistry();

vmals.initialize(new
InternalTypeMappingRegistryImpl(vmsr.getRegistry()));

vmals.serialize(vma, new QName("VersionManagedApplication"), null, xmlw,
new SOAPSerializationContext());

 

 

When executing, I get this error message:

serialization error: XML writer error: no prefix for URI:
"http://schemas.xmlsoap.org/soap/envelope/"

            at
com.sun.xml.rpc.encoding.literal.LiteralObjectSerializerBase.serialize(L
iteralObjectSerializerBase.java:111)

            at
com.xti.version.VersionManager.newVersionManagedApplication(VersionManag
er.java:123)

            at com.xti.test.Test.main(Test.java:19)

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)

            at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)

            at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)

            at java.lang.reflect.Method.invoke(Method.java:324)

            at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)

 

And this is the generated xml:

<?xml version="1.0" encoding="UTF-8"?>

<VersionManagedApplication

 

 

Kind regards,

Dylan Honorez,

dylan.honorez_at_xt-i.com <mailto:dylan.honorez_at_xt-i.com>

http://www.xt-i.com/ <http://www.xt-i.com/>