Mapping xsd:anyType element to Java.lang.Object

Hi,
I am using JAXB to parse a xml and in the XSD we have one element which is of the anyType and returns java.lang.object from JAXB generated classes. The issue is that when the node contains string and we type cast the returned object to string every thing runs fine but when the element contains embeded xml then the object returned can not be type cast to string.
code snippet:
*<xsd:element name="SignatureDefinition" type="xsd:anyType" />*
and the xml I am parsing contains:
*<SignatureDefinition>
<a>name</a>
<b> job</b>
</SignatureDefinition>*
That is the element contains a object which is a well formed xml.
Can any one guide or provide me the pointers.
Thanks
Regards,
Devesh

Hello Devesh,
The "SignatureDefinition" portion of the XML document should be unmarshalled as a DOM Element.
File file = new File("any.xml");
Root root = (Root) jaxbContext.createUnmarshaller().unmarshal(file);
Element element = (Element) root.getSignatureDefinition();
System.out.println(element.getTextContent());
If "SignatureDefintion" is the root of the XML document, you should get a JAXBElement wrapping a DOM Element.
File file = new File("any.xml");
JAXBElement<Element> root = (JAXBElement<Element>) jaxbContext.createUnmarshaller().unmarshal(file);
System.out.println(root.getValue().getTextContent());
-Blaise

Similar Messages

  • JAXB map to java.lang.Object.

    Hi people,
    I need to create objects using the JAXB xjc tool.
    There is an element/attribute in my XMLSchema that needs to be maped to java.lang.Object.
    I tried to use anySimpleType this way:
    <element name="try1" type="anySimpleType" maxOccurs="1" minOccurs="0"/>Also tried this:
    <attribute name="try2" type="anySimpleType" use="optional"/>But this way it maps to java.lang.String.
    Thanks for any help, references, sugestions.
    Att,
    TJ.

    Ok, try1 is working, I'm sorry.
    Thanks.

  • Sort(java.util.LinkedList java.lang.Object ) doesn't work

    Why doesn't this work?
    LinkedList<Object> sysPropsKeys = new LinkedList<Object>(System.getProperties().keySet());
    Collections.sort(sysPropsKeys);
    cannot fnd symbol
    symbol : method sort(java.util.LinkedList<java.lang.Object>)
    location: class java.util.Collections

    I will admit to not having Java1.5 installed on my machine. Haven't yet had the chance to play with generics, but the above DOES work in 1.4, and SHOULD work in 1.5
    Maybe I'm naive but, System.getProperties() returns a Properties object right?
    According to the API: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html: Each key and its corresponding value in the property list is a string.
    All the keys SHOULD be strings.
    AFAIK string are comparable, and shouldn't throw class cast exceptions
    Thus the keys returned from getProperties SHOULD be comparable, and compatible for comparision.
    Ok, I can see your point in that some hackers abuse the Properties class by putting non string keys/values into the Properties Map. In that case the code would become more like your above. I'd probably still go with a TreeMap though, rather than a sorted list of keys. Most time you want the keys, you want the values as well. So if the intention is to print out a sorted list of system properties, and their values, keeping it in a map is best.
    Just my 2 cents,
    evnafets

  • Weblogic - a web service with java.lang.Object parameter

    hi all,
    i'm creating a web service with a java.lang.Object parameter.
    my question is as follows:
    when a client calls the web service, how to i get the soap message object and convert it to soap message string using the parameter?
    thanks,
    alex

    Here's some code from one of the Axis samples, this shows the basic process of making a call:
    package samples.message;
    import org.apache.axis.client.Service;
    import org.apache.axis.client.Call;
    import org.apache.axis.message.SOAPBodyElement;
    import org.apache.axis.utils.Options;
    import org.apache.axis.utils.XMLUtils;
    import org.w3c.dom.Element;
    import java.net.URL;
    import java.util.Vector;
    public class TestMsg {
    public String doit(String[] args) throws Exception {
    Options opts = new Options(args);
    opts.setDefaultURL("http://localhost:8080/axis/services/MessageService");
    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress( new URL(opts.getURL()) );
    SOAPBodyElement[] input = new SOAPBodyElement[2];
    input[0] = new SOAPBodyElement(XMLUtils.StringToElement("urn:foo",
    "e1", "Hello"));
    input[1] = new SOAPBodyElement(XMLUtils.StringToElement("urn:foo",
    "e1", "World"));
    Vector elems = (Vector) call.invoke( input );
    SOAPBodyElement elem = null ;
    Element e = null ;
    elem = (SOAPBodyElement) elems.get(0);
    e = elem.getAsDOM();
    String str = "Res elem[0]=" + XMLUtils.ElementToString(e);
    elem = (SOAPBodyElement) elems.get(1);
    e = elem.getAsDOM();
    str = str + "Res elem[1]=" + XMLUtils.ElementToString(e);
    return( str );
    public static void main(String[] args) throws Exception {
    String res = (new TestMsg()).doit(args);
    System.out.println(res);

  • Error: initialization error: file java\lang\Object.class not found

    when the error listed my classpath's its not the same list that is in my Windows XP environment variable list?
    I am on 9.0.3
    I am assuming I have to set some varible to my new jdk\bin directory. I reinstalled it. I have set it to use jdk 1.4 using the ojvm tool a while back.

    Please help!!
    I did change the jdev.conf file setting:
    SetJavaHome /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home
    and I still get this error:
    initiallization erro: file java/lang/Object.class not found in classpath
    I am usgin Oracle JDeveloper 10g 10.1.2 on a Mac OS X Tiger
    Could someone please help?
    thanks a bunch!!!

  • How to assign and transform or how to deal with xsd:anyType elements in 10g

    Hi,
    Any Update on this please...
    Hi,
    we are using canonical model as part of 10g, here I am not able to assign or tranform elements of type xsd:anyType to/from to other type elements. Solution with an example and quick reply is appreciated.
    =========================================
    Hi,
    By using copy-of xslt construct again input element structure is getting copied into the target mapper file, by using value-of xsl:construct just the value is getting assigned. Can you please elaborate on how to use this xsd:anyType elements in assign and tranform activities, overall how to use these elements in 10g, while implementing the canonical model.
    ex:
    xsl file: by using value-of
    <xsl:template match="/">
    <ns1:abstractRef>
    <ns1:amount>
    <xsl:value-of select="/ns1:BPELProcess1ProcessRequest/ns1:input"/>
    </ns1:amount>
    </ns1:abstractRef>
    </xsl:template>
    Result:
    <abstract1>
    -<abstractRef xmlns:ns1="http://xmlns.oracle.com/BPELProcess1" xmlns="http://sample/test">
    <ns1:amount>6556</ns1:amount>
    </abstractRef>
    </abstract1>
    Here amount is of type xsd;anyType which is present in the abstract complexType.
    xsl file: by using copy-of:
    <xsl:template match="/">
    <ns1:abstractRef>
    <ns1:amount>
    <xsl:copy-of select="/ns1:BPELProcess1ProcessRequest/ns1:input"/>
    </ns1:amount>
    </ns1:abstractRef>
    </xsl:template>
    Result:
    <abstract1>
    -<abstractRef xmlns:ns1="http://xmlns.oracle.com/BPELProcess1" xmlns="http://sample/test">
    <ns1:amount>
    <ns1:input>6556</ns1:input>
    </ns1:amount>
    </abstractRef>
    </abstract1>
    and while using it on assign activity, it is not assigning the input value to the xsd:anyType element, please provide an example on how to do this activity along with tranform.
    Edited by: user12679330 on Mar 1, 2010 4:46 AM

    >
    Try bpelx:append as a copy rule.
    >
    Since this thread is over three years old it will be interesting to see if OP is still waiting for a reply. ;)

  • Error: invalid file 'java/lang/Object.class' (wrong version: 48, expected 4

    hi all
    ive installed jdk1.4.1 from jdk1.3 .
    When i try to compile a java file i get this error.
    Error: invalid file 'java/lang/Object.class' (wrong version: 48, expected 45)
    anyone has any idea abt this.
    im stuck :( pls help.
    thanks
    Jan

    Did you uninstall 1.3 completely? Completely in the sense both jdk and jre.
    You may get this error if you use javac of one version and the rt.jar of another version.
    Sudha

  • Java/lang/NoClassDefFoundError: java/lang/Object

    Hi Experts,
    We are installing Java "1.6.0_31.We have updated the environment variables with the correct Java Path but which checking the java -version we are getting the following error.
    java -version
    Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object
    hence the DAC service is not starting giving the following error.
    startserver.h: startserver.h: cannot open
    OS detected: SunOS
    ld.so.1: java: fatal: libjli.so: open failed: No such file or directory
    Killed
    Following are the environment variable entries.
    PATH=/opt/SUNWspro/bin:/../oracle/product/10.2.0/client_1/bin:/.../Informatica/PowerCenter8.6.1/server/bin:/usr/sfw/bin:/...../JAVA631/jdk1.6.0_31/bin/sparcv9:/.../JAVA631/jdk1.6.0_31/lib:/..../JAVA631/jdk1.6.0_31/jre/lib/sparcv9/jli:/...../JAVA631/jdk1.6.0_31/jre/lib/sparcv9:$PATH
    export PATH
    Need ur support.
    Thanks

    Where do you run shell script?
    What's your Oracle's version?
    What's text of your shell script?
    By asking 100 questions and keeping 90 of them "unanswered" you throw yourself to the list of "blacklist users"
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]
    Edited by: Kamran Agayev A. on May 19, 2009 1:28 PM

  • NoClassDefFound java/lang/Object error

    Hi all,
    I just tried to install JRE 1.4.1 on Win98 and encountered this error when I typed in java -version:
    error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object
    After I installed I added SET CLASSPATH = and the path to my rt.jar and tools.jar to my autoexec.bat, but that didn't seem to work.
    Sorry about posting this here if it isn't appropriate, I tried a forum search but kept getting Server Error.
    Steve

    Look at this thread:
    http://forum.java.sun.com/thread.jsp?forum=54&thread=106425
    Think it is reply 3 or 4, where you have to rename the the java.exe file somewhere in your system path

  • Javah error java.lang.Object not found

    Hi guys-
    I'm trying to run a javah command to generate a .h file... I'm using windows2000 & jdk1.1.8... when I run the command from DOS prompt I keep getting the same eror as java.lang.Object not found: aborting.. I've checked all the classpath and it seems ok ... I have CLASSPATH=..;c:\jdk1.1.8\lib\classes.zip
    Can anybody help me with this???
    Thanx

    Maybe try ; right click my computer ,click the advanced tab and select enviroment variables,click on classpath and then edit,check if it's correct.I had the sam problem and that seemed to fix it. :)

  • Finalizer.register(java.lang.Object)

    I need to know th use of Finalizer.register(java.lang.Object) method.
    Can someone please help me...Its urgent!!!!
    Thank you!!
    Message was edited by:
    Java_Freak

    I am instantiating a MQQueue object..... When I run
    the memory debugger it says a call is made to the
    Finalizer.register method and the FInalizer object is
    on heap even after the GC...Why is this a problem? If it is a problem again
    1) Consult the bug database
    2) Post formatted code that reproduces your problem.
    Other than that consult these
    http://java.sun.com/developer/technicalArticles/ALT/RefObj/
    http://www.javaworld.com/javaworld/javatips/jw-javatip79.html
    This is the best and only advice I can give you based on your problem description.

  • The first quthor of java.lang.Object

    The biggest mystery for me in Java still exists as to who really coded the mother of all classes java.lang.Object.
    Here�s what the source of it says in JavaDocs
    * Class <code>Object</code> is the root of the class hierarchy.
    * Every class has <code>Object</code> as a superclass. All objects,
    * including arrays, implement the methods of this class.
    * @author unascribed
    * @version 1.61, 01/23/03
    * @see java.lang.Class
    * @since JDK1.0
    public class Object {

    See the annotation @author above, it says �unascribed� which means unknown. Any one who can solve this mystery for me and come up with the real author of this jni implementation class called �Object�
    I mean, the first one to code Object class...Please help me

    cross-post

  • Who is the author of java.lang.Object

    The biggest mystery for me in Java still exists as to who really coded the mother of all classes java.lang.Object.
    Here�s what the source of it says in JavaDocs
    * Class <code>Object</code> is the root of the class hierarchy.
    * Every class has <code>Object</code> as a superclass. All objects,
    * including arrays, implement the methods of this class.
    * @author unascribed
    * @version 1.61, 01/23/03
    * @see java.lang.Class
    * @since JDK1.0
    public class Object {

    See the annotation @author above, it says �unascribed� which means unknown. Any one who can solve this mystery for me and come up with the real author of this jni implementation class called �Object�
    I mean the first one to write java.lang.Object. Please help me...

    Please don't cross-post

  • HELP!! Deploying with DC, missing type java.lang.Object

    Hi Folks,
    I have a WebDynpro project created with a DC. I have been deploying the project directly from the application node, but I just built the associated DC for the first time, and now I get errors in my source code that I have the missing type java.lang.Object.
    I have tried the repair-->project structure and classpath option already. Looks like some basic links are broken.
    This is hopefully simple, but I have no Idea what I need to do.
    Thanks
    Message was edited by:
            Todd Fisher

    Hi there,
    If it's because of broken links, did you try closing the project and opening it again?
    Kind regards,
    J.

  • Java newbie: java.lang.Object[]

    Hi: I have a method which returns a java.lang.Object[]. I have tried a number of things. But can't seem to How do I print the contents of the object?
    The method I am calling is the following
    ==============
    public java.lang.Object[] getAllUsers() {
    if (super.cachedEndpoint == null) {
    throw new org.apache.axis.NoEndPointException();
    org.apache.axis.client.Call _call = createCall();
    call.setOperation(operations[125]);
    _call.setUseSOAPAction(true);
    _call.setSOAPActionURI("");
    call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11CONSTANTS);
    _call.setOperationName(new javax.xml.namespace.QName("Urn:ApiService", "getAllUsers"));
    setRequestHeaders(_call);
    setAttachments(_call);
    try {        java.lang.Object _resp = _call.invoke(new java.lang.Object[] {});
    if (_resp instanceof java.rmi.RemoteException) {
    throw (java.rmi.RemoteException)_resp;
    else {
    extractAttachments(_call);
    try {
    return (java.lang.Object[]) _resp;
    } catch (java.lang.Exception _exception) {
    return (java.lang.Object[]) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.Object[].class);
    =============
    Thanks
    Ravi

    Where in that code do you claim you are doing that? Post a SSCCE .
    edit: Should you really be trying to work with web services if you don't know the basics of Java?

Maybe you are looking for

  • Performance blocker on cFP-2020: file-I/O! How to improve?

    Hi all, after resolving my serial-communication problems I still have a performance problem. The code is way too slow which causes e.g. the ftp-server on the fieldpoint to not respond anymore to requests from my PC. I always get timeouts. I also freq

  • To print local time in format of HH:MM in a smartform

    Hi Guys, I need to print the local time ofp rinting in a smartform eliminaitng the seconds. i.e., Need to print only HH:MM. How Do I do that?

  • Exit Button not working

    ok so I have a button symbol called button2 ( I know, very catchy ) and I have this code set for it- button2.onRelease = function() { fscommand("quit"); When I check for errors it says there are none but when I click the button in the SWF, it doesn't

  • Internal and external super drives dont work

    DVD is ejected after about 30 seconds on the internal.  External spins but does nothing and doesn't display in Finder. Both drives are found and seem OK in system information. Have tried cleaning, clearing the SMC, starting is safe mode and pretty mu

  • Can I have variable widths of columns in a table in pages for ipad?

    I would like to make a table in Pages that has a larger column for the first column than the others so I can put labels in this column. Is that possible on the ipad? I know I can do this in Pages on a computer.