Unmarshaling of XML

HI,
I am having a requriment where there are some columns in the SQL server and one of the column has the XML stored. I have to Unmarshaling of XML and do a mapping with the target system. Can any one help in Unmarshaling of XML which is a column in the source table.
Thanks,
RPRKrish.

Hi,
you do not have to unmarshal.
Today there is a similar post.
See:
" XML inside a field in XI  "
Regards Mario

Similar Messages

  • JAXB: How to unmarshal from xml contains two schemas?

    Hi, all.
    My question is in subject.
    Ex.)
    schema1.xsd:
    (snip)...
    <xsd:element name="xxx">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    ...(snip)
    schema2.xsd:
    (snip)...
    <xsd:element name="yyy">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="zzz" minOccurs="1" maxOccurs="1"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="zzz" type="xsd:string"/>
    if I have a xml like the following, xml validation is correct:
    sample.xml:
    (snip)...
    <ns1:xxx xmlns:ns1="...(schema1.xsd)...">
    <ns2:yyy xmlns:ns2="...(schema2.xsd)...">
    <ns2:zzz>SAMPLE</ns2:zzz>
    </ns2:yyy>
    </ns1:xxx>
    I want to unmarshal from this xml using JAXB, but actually ths xxx didn't have any tag in List class given getAny() method, because xxx doesn't know about yyy, I think.
    These schemas cannot change as requirements of customer.
    How to unmarshal from xml contains two schemas using JAXB?
    tx.

    I solved it myself.
    JAXBContext can be specified many context path at same time.
    Ex.)
    context = JAXBContext.newInstance("package1:package2:package3...");
    So, unmarshaller can know how to choose what be instanced.
    tx.

  • Unhandled Error (HTTP Status:500): unmarshal.invalid.xml

    Hello Gurus,
    I am facing a typical problem while assigning users to the Environment in BPC 10.0 NW SP 4.
    In BPC Web interface I am able to see the user list, but when I try to add user and save system pops an error nessage
    Unhandled Error (HTTP Status:500): unmarshal.invalid.xml
    waiting for your expert advice.
    Regards
    Manoj Damle

    Hi Manoj,
    Please see note - 1693703. It says environmentshell is not properly activated.
    Please implement 1615644 to fix the issue.
    Regards,
    Ashish

  • Cannot unmarshal an XML document to a JavaBean without its XML Schema?

    Hi,
    2 questions:
    1. I have an XML document and have the corresponding JavaBean (the 2 already exist). I tried to unmarshall the XML document using JAXB but I get a strange error of duplicate attributes/elements no matter if I use the annotations @XmlElement, @XmlAttribute etc. The code I use is simply:
    JAXBContext jc = JAXBContext.newInstance("MyClass.class");
    Unmarshaller u = jc.createUnmarshaller();
    MyClass myClass = (MyClass) u.unmarshal(new File("myxml.xml"));Do I always have to create the .xsd file of my xml, create the JavaBean using xjc and then run the above?
    2. Can I use JAXB to parse an XML file to a JavaBean but, because the xml file is a complicated one, to use xpaths to get the attributes?
    E.g. to use something like this?
    @XmlAttribute ("xpath/to/attribute")Thank you in advance for your replies.
    Best regards,
    John.

    Hi,
    2 questions:
    1. I have an XML document and have the corresponding JavaBean (the 2 already exist). I tried to unmarshall the XML document using JAXB but I get a strange error of duplicate attributes/elements no matter if I use the annotations @XmlElement, @XmlAttribute etc. The code I use is simply:
    JAXBContext jc = JAXBContext.newInstance("MyClass.class");
    Unmarshaller u = jc.createUnmarshaller();
    MyClass myClass = (MyClass) u.unmarshal(new File("myxml.xml"));Do I always have to create the .xsd file of my xml, create the JavaBean using xjc and then run the above?
    2. Can I use JAXB to parse an XML file to a JavaBean but, because the xml file is a complicated one, to use xpaths to get the attributes?
    E.g. to use something like this?
    @XmlAttribute ("xpath/to/attribute")Thank you in advance for your replies.
    Best regards,
    John.

  • How to unmarshal large XML file

    I have a large (170 MB) XML document. The size is due to a complex tree structure that is an array. It's taking approximately 45 minutes to unmarshal the document into the OTD. Not sure if there's a way to process this XML document in pieces (logical section)?? Suggestions are appreciated.

    I tried your suggestion, but get an error when I try to export the XSD node. It's expecting a TargetNamespace. Here is the beginning of the XSD that I imported:
    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="MeterReadingDocument" nillable="true" type="MeterReadingDocument" />
    <xs:complexType name="MeterReadingDocument">
    <xs:complexContent mixed="false">
    <xs:extension base="XmlDocumentBase">
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1" name="Remarks" type="ArrayOfString" />
    <xs:element minOccurs="0" maxOccurs="1" name="Header" type="ExportHeader" />
    <xs:element minOccurs="0" maxOccurs="1" name="ImportExportParameters" type="ImportExportParameters" />
    <xs:element minOccurs="0" maxOccurs="1" name="Channels" type="ArrayOfChannel" />
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    If I add a targetNamespace, then I get an exception when I attempt to unmarshal the file. I get the message:
    There was an error during unmarshal.
    Expect: '{http://www.w3.org/2001/XMLSchema}MeterReadingDocument', found: 'MeterReadingDocument'
    Not sure what to do.
    Thanks.

  • Unmarshal Exception on big XML files

    First, sorry for my english.
    I have a problem using a unmarshal method. I�m trying to unmarshal a XML file which size is almost 4.1Mb. When I do that an Unmarshal Exception is thrown. But if I broke the file in little parts (0.5Mb each) the unmarshal method works perfectly for all those little XML files. Is there any body that knows what is happening?
    Tanks.

    I don't have any solution. But I can remenber having already seen someone speaking about this problem on this forum. Try to find his thread which a search with keywords as XML, Exception, big file ... You'll perhaps find it. This subject was discussed a few weeks ago.

  • Unmarshal a modified xml file

    Hi,
    In my java project I need to unmarshal an xml file in order to get a list of objects.
    The unmarshalling works very fine but the problem is encontourned when the content of the file is modified. In fact in this project we can add new contents to this file by clicking on "addButon" but when i want to unmarshal another time the same file (after modification) i get only the old list of objects without the last elements (I have just added to this file).
    I already verified the physical xml file on the disk and I found all the last content I just added. Also I noticed that The only way to get the last list of objects is to close the appli and to reopen it again, which is unsuitable.
    Here is a piece of the code:
    //classe1.java
    Referentiel ref = null;
    File iniFile = new File(proprietesPerle.getRepReferentiel() + "referential.xml");
    FileInputStream fs = null;
    try
    fs = new FileInputStream(iniFile);     
    catch(FileNotFoundException fex)
    try
    ref = Referentiel.unmarshal(fs);     
    session.setAttribute("ref",(Object) ref);
    TreeMap map = ReferentielUtil.getApplication( ref );
    session.setAttribute("mapAppli", map);
    catch (UnmarshalException ex)
    logger.error(ex.getMessage());
    finally {
    try {
    fs.close();
    } catch (IOException e) {
    logger.error(e.getMessage());     
    //classe2.java
    TreeMap map = new TreeMap();
    List listPL = app.getPl(); //this list is unmarshalled from the xml file
    ListIterator itpl = listPL.listIterator();
    while (itpl.hasNext())
    Pl pl = (Pl)itpl.next();
    map.put(pl.getCode(), pl);
    return map;
    Please, do you have any idea to resolve this problem?
    Thank you in advance.

    The web.xml file is a standard file that is found in the WEB-INF directory. If you have not created one, below should be enough to get it working.
    Copy the following into Notepad and save as web.xml.
    Copy the web.xml file to your WEB-INF folder.
    Let'er rip.
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <!-- General description of your web application -->
    <display-name>WebName</display-name>
    <description>
    </description>
    </web-app>

  • Unmarshaling XML file with JAXB from JAR doesn't work?

    Hi
    I'm pretty new to JAXB... I'm unmarshaling an XML file, and everything works fine in my JUnit test, using XML files. However, the caller of my unmarshalling is a Web Start application using signed JARs.
    When I try to access the XML file, I log the URL and get an exception:
    INFO[slf5s.PRIORITY] javawsApplicationMain[slf5s.THREAD] ch.ige.main.client.menu.MenuBuilder[slf5s.CATEGORY] Creating menu from URL jar:file:C:/Program%20Files/JRE/1.4.2/cache/http/...Main.jar!/res/JippsAdminMenuBaum.xml[slf5s.MESSAGE]
    ERROR[slf5s.PRIORITY] javawsApplicationMain[slf5s.THREAD] ch.ige.main.client.MenuPane[slf5s.CATEGORY] exception caught[slf5s.MESSAGE]
    java.io.IOException: Couldn't unmarshal configuration from java.util.jar.JarVerifier$VerifierStream@15f1f9c: null
         at ch.ige.main.client.menu.MenuBuilder.unmarshalConfiguration(MenuBuilder.java:110)
         at ch.ige.main.client.menu.MenuBuilder.<init>(MenuBuilder.java:86)
         at ch.ige.main.client.MenuPane.createMenuBuilder(MenuPane.java:485)
         at ch.ige.main.client.MenuPane.createTreeLevel(MenuPane.java:460)
         at ch.ige.main.client.MenuPane.jbInit(MenuPane.java:316)
         at ch.ige.main.client.MenuPane.<init>(MenuPane.java:122)
         at ch.ige.jippsadmin.MepJipps.<init>(MepJipps.java:32)
         at ch.ige.jippsadmin.JippsMain.run(JippsMain.java:64)
         at ch.ige.auth.ClientAuthenticator.executePrivilegedCode(ClientAuthenticator.java:166)
         at ch.ige.authz.client.AuthMain.executePrivilegedCode(AuthMain.java:128)
         at ch.ige.authz.client.AuthMain.run(AuthMain.java:213)
         at ch.ige.jippsadmin.JippsMain.main(JippsMain.java:77)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at com.sun.javaws.Launcher.executeApplication(Unknown Source)
         at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
         at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
         at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
         at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)Btw, does anyone know where to find the runtime JARs that are required for JAXB (from JWSDP 1.5)?
    Thanks & best regards,
    Eric

    Well... once again this was a ClassLoader problem... solved!

  • Need help in displaying XML in JSP

    Hi there,
    i'm a newbi in XML and Java - I have the following prob, think for most of u nothing very difficult (or better thought so, I've posted this question in different forums here, but nobody answers :)
    I get an XML response from a search engine, now I want to display the search result in a jsp.
    The result is stored in the session [I hope I figured out correctly ;)]
    with the following command ->
    this.pageContext.getSession().setAttribute(SEARCHRESULT, dSearchResult);
    [its from the java class, which generates the result]
    Result example ->
    <?xml version="1.0" encoding="UTF-8"?>
    <FindSearchResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xml/SearchResult.xsd">
    <Result Hits="2" Name="OfficeLand_en_US">
    <Items>
    <Item Score="250">
    <Field FieldNo="0" Name="ProductID">KqvAqAB1Tq0AAADnFthtpZvC</Field>
    <Field FieldNo="1" Name="CatalogCategoryID">gh0KAAFvj3wAAADiW8SMtr6o</Field>
    </Item>
    <Item Score="250">
    <Field FieldNo="0" Name="ProductID">4rwKAAFvtNYAAADiwdCMtr6o</Field>
    <Field FieldNo="1" Name="CatalogCategoryID">gh0KAAFvj3wAAADiW8SMtr6o</Field>
    </Item>
    </Items>
    <HitDistribution>
    <Hit Hits="75" Score="0"/>
    <Hit Hits="2" Score="250"/>
    </HitDistribution>
    </Result>
    </FindSearchResult>
    How many 'Field' elements exist, depends on the query.
    The result example is a response, which is send to my JSP page. It is stored in an variable under the name SEARCHRESULT (it's the result of a query in a search engine).
    My JSP page is the page, which should display the searchresult.
    So i need to know, how to programm something in my JSP page to check the SEARCHRESULT to display not the whole xml file. I just want to display all Items (compare with result example) -> The name of each existing FieldNo, the Score and the HitDistribution.
    Please help me :)

    hi there,
    first create a xml schema for the xml you will be receiving.
    use jaxb or castor with the schema and create a class.
    in your jsp unmarshal the xml result you are getting with the class
    generated by either jaxb or castor. the class will have methods that return you the required elements.
    get to know xml schema better and just a pass thru of jaxb or castor will solve the problem.
    vedha_g

  • Unmarshalling a DOM node to an XML file with JAXB

    I'm trying to unmarshall a DOM node to an XML file using JAXB. However I keep receiving a NullPointerException. This only seems to occur when I create the DOM Node from scratch. The stack trace looks like the following:
    java.lang.NullPointerException
            at com.sun.xml.bind.unmarshaller.SAXUnmarshallerHandlerImpl.startElement
    (SAXUnmarshallerHandlerImpl.java:87)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:109)
            at com.sun.xml.bind.unmarshaller.DOMScanner.parse(DOMScanner.java:64)
            at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(Unmarshaller
    Impl.java:149)
            at Main.main(Main.java:103)(If I unmarshal an XML file into a DOM node, I can successfully marshall the DOM node out to a new XML file using JAXB without error.)
    Any insight into what I am doing wrong would be greatly appreciated!
    Sample code and XSD follow...
    Sample Code:
    import itemlistsample.*;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.JAXBException;
    import javax.xml.bind.Marshaller;
    import javax.xml.bind.Unmarshaller;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import org.w3c.dom.Text;
    public class Main
      public static void main(String[] args)
          try
              JAXBContext jc = JAXBContext.newInstance( "itemlistsample" );
              Unmarshaller u = jc.createUnmarshaller();
              * Set up DOM Node Document Object.
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              dbf.setNamespaceAware(true);                   
              DocumentBuilder db = dbf.newDocumentBuilder(); 
              Document doc = db.newDocument();
              System.out.println();
              System.out.println();
              System.out.println("Create a DOM Node and unmarshall to an XML file");
              * Generate elements within DOM document
              Element itemListElt = (Element)doc.createElement("item_list");
              Element itemInfo = (Element)doc.createElement("item_info");
              Element name = (Element)doc.createElement("name");
              Element price = (Element)doc.createElement("price");
              * 3-Ring Binder @ 4.99
              name.appendChild(doc.createTextNode("3-Ring Binder"));
              itemInfo.appendChild(name);
              price.appendChild(doc.createTextNode("4.99"));
              itemInfo.appendChild(price);
              itemListElt.appendChild(itemInfo);
              * Large Paper Clips @ 1.23
              itemInfo = (Element)doc.createElement("item_info");
              name = (Element)doc.createElement("name");
              price = (Element)doc.createElement("price");
              name.appendChild(doc.createTextNode("Large Paper Clips"));
              itemInfo.appendChild(name);
              price.appendChild(doc.createTextNode("1.23"));
              itemInfo.appendChild(price);
              itemListElt.appendChild(itemInfo);
              doc.appendChild(itemListElt);
              * Display DOM document as a sanity check
              itemListElt = doc.getDocumentElement();
              System.out.println(itemListElt.getTagName());
              NodeList nl = itemListElt.getElementsByTagName("item_info");
              traverse("  ", nl.item(0));
              * Use JAXB to unmarshal the DOM document into
              * an instance of the generated JAXB class for
              * the root element.  Stack trace occurs here!
              ItemListType il = (ItemListType)u.unmarshal(doc);
              * Marshal to an XML file
              Marshaller m = jc.createMarshaller();
              m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
              m.marshal( il, new FileOutputStream("item_new.xml") );
          catch (Exception e)
         e.printStackTrace();
      public static void traverse(String indent, Node n)
        if (n != null)
          if (n.getNodeName() != null)
            System.out.println(indent + n.getNodeName());
            traverse(indent + "  ", n.getFirstChild());
          if (n.getNodeValue() != null)
            System.out.println(indent + n.getNodeValue());
          traverse(indent, n.getNextSibling());
    }Sample XSD:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <xsd:element name="item_list" type="ItemListType"/>
         <xsd:complexType name="ItemListType">
              <xsd:sequence>
                   <xsd:element name="item_info" type="ItemInfoType" maxOccurs="unbounded"/>
              </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="ItemInfoType">
              <xsd:sequence>
                   <xsd:element name="name" type="xsd:string"/>
                   <xsd:element name="price" type="xsd:double"/>
              </xsd:sequence>
         </xsd:complexType>
    </xsd:schema>

    Modified schema
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="item_list">     
    <xsd:complexType>          
    <xsd:sequence>               
    <xsd:element ref="item_info" maxOccurs="unbounded"/>     
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="item_info">
         <xsd:complexType>          
    <xsd:sequence>               
    <xsd:element name="name" type="xsd:string"/>     
         <xsd:element name="price" type="xsd:double"/>     
         </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>

  • XML JAXB Binding issue

    Hi All
    Im using Webservices in which i need to Bind my XML to Java objects and reverse. Im trying to use JAXB (1.0) Ref Imp from SUN as binding framework. The problem which im facing is that for elements like:
    <xs:element name="inputRequests">
    <xs:complexType>
    <xs:sequence>
    <xs:element maxOccurs="unbounded" name="inputData" type="data" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    JAXB genetrates:
    1. InputRequest - Interface
    2. InputRequestImpl - Class
    3. InputRequestType - Interface
    4. InputRequestTypeImpl - Class
    in InputRequestType it has generated a getter method
    public java.util.List getInputData();
    but no setter method for 'inputData'.
    Can any one help on that how we can set a sequence element in JAXB classes. I even used JAXB 2.0, but faced same issue...
    No Setter for a LIST :-(((

    That method, getInputData() is returning a reference to a List Object that is already instantiated. Once you retrieve the reference, you can invoke all the methods in the List interface, but if there is a way to reassign the reference to refer to a different list, I'm not aware of one.
    I believe that limitation is necessary my the nature of JAXB. A JAXB Object, in your case a List, is guaranteed to be marshaled and unmarshaled to XML, if you redefine the reference to some arbitrary List, how could JAXB guarantee its functionality?
    I may be way off base here, I'm no JAXB expert by any means.
    Rather than redefining the reference to a different List, you have to manipulate the List
    ...getInputData().clear();
    ...getInputData().addAll(myRequestList);Right?

  • JAXB marshaling and unmarshaling

    I used JAXB to generate nine classes (one is simply a type-safe enum) to correspond to my XML DTD. I then wrote the code to instantiate the root and some child elements which are all added to the root content. Then I am able to call validate() and marshal() on the root element and produce the desired XML. Great!
    The trouble is that I'm having difficulty using these classes to unmarshal the XML that they validated and wrote. Has anyone else seen this? In some cases, the call to unmarshal() returns the root element with no content (e.g., "<myRoot/>"). In other cases, I get an InvalidContentException on a nested element that repeats (e.g., "Expected an end tag for a "fooList" element, but found a start tag for a "foo" element").
    Has anyone else seen this? I've been through the bug parade and didn't catch this mentioned there.
    Thanks!
    Mark

    Here's the code for the problem I'm running into. Is anyone able to reproduce the problem and diagnose it? I must be doing something wrong because the Checkbook example works just fine for me. Please help!
    The obvious trouble here is that Test4.java does not correctly unmarshal the XML that it writes to temp.xml. Where have I gone wrong?
    Thanks,
    Mark
    -------- begin cut (xyz.dtd) --------
    <!ELEMENT Id ( #PCDATA ) >
    <!ELEMENT Name ( #PCDATA ) >
    <!ELEMENT Amt ( #PCDATA ) >
    <!ELEMENT Transaction ( Id, Name, Amt ) >
    <!ELEMENT Transactions ( Transaction+ ) >
    <!ATTLIST Transactions count NMTOKEN #IMPLIED >
    --------- end cut (xyz.dtd) ---------
    -------- begin cut (xyz.xjs) --------
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <xml-java-binding-schema version="1.0-ea">
    <options package="xyz"/>
    <element name="Transactions" type="class" root="true">
    <attribute name="count" convert="int"/>
    <content>
    <element-ref name="Transaction"/>
    </content>
    </element>
    <element name="Name" type="value"/>
    <element name="Amt" type="value" convert="int"/>
    <element name="Id" type="value" convert="int"/>
    <element name="Transaction" type="class">
    <content>
    <element-ref name="Id"/>
    <element-ref name="Name"/>
    <element-ref name="Amt"/>
    </content>
    </element>
    </xml-java-binding-schema>
    --------- end cut (xyz.xjs) ---------
    -------- begin cut (Test4.java) --------
    import xyz.*;
    import javax.xml.bind.*;
    import javax.xml.marshal.*;
    import java.io.*;
    import java.util.Date;
    import java.util.Random;
    public class Test4 {
    private static Random rand = new Random();
    public static void main(String[] args) {
    // need file to work with...
    try {
    File f = new File( "temp.xml" );
    FileOutputStream fout =
    new FileOutputStream( f );
    // make some transactions
    int TransCt = 1;
    Transactions txns = new Transactions();
    java.util.List transactions = txns.getTransaction();
    for (int i=0; i < TransCt; i++) {
    Transaction t = makeBogus();
    transactions.add( t );
    txns.setCount( TransCt );
    txns.validate();
    txns.marshal( fout );
    fout.flush();
    fout.close();
    FileInputStream fin = new FileInputStream( f );
    Transactions t = new Transactions();
    t.unmarshal( fin );
    t.validate();
    t.marshal( System.out );
    catch (Exception e) {
    e.printStackTrace();
    private static Transaction makeBogus() {
    String[] names =
    { "Bob", "Larry", "Tom", "Ted", "Bill",
    "Gail", "Louise", "Sam", "Erin", "Wilma" };
    Transaction transaction = new Transaction();
    // calculate transaction id...
    int range = Integer.MAX_VALUE / 3 * 2;
    int Id = rand.nextInt(range);
    transaction.setId( Id );
    // pick a name
    transaction.setName( names[rand.nextInt(10)] );
    transaction.setAmt( rand.nextInt( 100 ) );
    return transaction;
    --------- end cut (Test4.java) ---------

  • Request response as xml

    I have been given an xsd file and asked to create a web service whose request/response is based on this provided xsd.
    and the requirement is to have request/response of web service in xml doc. This complete XML cannot be a sent as string.
    So, please let me know how to acheive this. i.e how to inject the required xml structure in the web service response.
    Edited by: jumst on Nov 2, 2009 2:58 AM

    jumst wrote:
    how would i pass on the request on to web service -From jaxb classes i can send the resquest in an xml doc to the web service? or how? and likewise the result ftom web service to jaxb classes?Answer of your question is XML Marshaling and Unmarshalling will be used for the above purpose.
    The Java Architecture for XML Binding (JAXB) provides a fast and convenient way to bind between XML schemas and Java representations, making it easy for Java developers to incorporate XML data and processing functions in Java applications. As part of this process, JAXB provides methods for unmarshalling XML instance documents into Java content trees, and then marshalling Java content trees back into XML instance documents. JAXB also provides a way to generate XML schema from Java objects.
    -- From [Java™ EE 5 Tutorial - Binding between XML Schema and Java Classes|http://java.sun.com/javaee/5/docs/tutorial/doc/bnazf.html]
    Other Ref:
    [JAXB Architecture|http://java.sun.com/javaee/5/docs/tutorial/doc/bnazg.html]
    [NetBeans.org - Binding WSDL to Java with JAXB|http://www.netbeans.org/kb/docs/websvc/jaxb.html]
    JAX-WS Client App                                                    JAX_WS Server App
                                                                         JAS-WS Web Service
    Consume JAX-WS Web            <--------------------------            Deployed here
    Service here using WSDL
    of the deployed Web
    Service. This is JAX-WS
    Client with all proxy and
    schema(JAXB) classes.       
    Client sends request to                                             
    server with JAXB                                                         
    classes. At the end JAX-WS                                          
    Client proxy classes will                                           
    marshal request to XML          
    and send to server.           -------------------------->            On request arrival JAX-WS Server
                                                                         classes will unmarshal incoming
                                                                         XML Request to JAXB Classes and
                                                                         invoke web service and web method.
                                                                         As web service response server
                                                                         prepares response using JAXB
                                                                         classes,and sends back to client.
                                                                         JAX-WS Web Service will marshal
                                                                         the response to XML and sends to
    Client receives XML response   <--------------------------           client.
    and JAX-WS client proxy
    classes will unmarshal the
    response to JAXB classes.
    Client app. will use these
    as response.Developing web service with JAX-WS, Server and client will do marshaling and unmarshaling of SOAP XML requests and response for you.
    Just go through tutorial given in my previous and current post. Use any good IDE to develop, I prefer NetBeans first and then Eclipse.
    Below two links will help you to build and consume a web service using NetBenas IDE.
    [Getting Started with JAX-WS Web Services|http://www.netbeans.org/kb/docs/websvc/jax-ws.html]
    [Advanced Web Service Interoperability|http://www.netbeans.org/kb/docs/websvc/wsit.html]
    Disclaimer: I am not an professional technical author so please forgive my English and Grammar.+ *:-))*
    *Cheers,
    typurohit* (Tejas Purohit)

  • Org.exolab.castor.xml.MarshalException:Unable to instantiate java.util.List

    Hi,
    I am using castor to unmarshal an xml into a java object.
    This object has member variables as collections (List).
    Even though in the mapping file I used collections attribute of <field> tag and has set it to arraylist, it is still throwing this exception.
    After doing a bit of research on this,I found that since UnmarshalHandler uses reflection to create object from xml, it is trying to invoke java.util.List.newInstance() which is causing this problem.
    The class which I am trying to unmarshal is an already existing class and I cannot change the type of the member variables to ArrayList from List.
    How can it be resolved?

    The exception trace is as below :
    Caused by: java.lang.InstantiationException: java.util.List() method not
    found
    at
    org.exolab.castor.xml.UnmarshalHandler.createInstance(UnmarshalHandler.java:2584)
    at
    org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:2348)
    at
    org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1436)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
    Source)
    at
    org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
    Source)

  • Hidden cast? - while unmarshalling XML

    Hi there,
    I'm creating a scheduler as a GUI wrapper for a pre-existing application. The existing application uses a web service to submitted an XML file to a remote application for processing.
    An XML file is then deposited locally for processing the response.
    The response with either contain a data such as:
    <rpc>
    <success>0</success>
    </rpc>
    or
    <rpc>
    <fault>fault description goes here</fault>
    </rpc>
    I can unmarshal the XML successfully; when a success is received and I call:
    re.getResponse().getSuccess(); - I get the int
    re.getResponse().getFault(); - I get the null
    but, bizarrely when transmission is unsuccessful I still get an int returned from the <success> even though that element simply doesn't exist in the XML... i.e.
    re.getResponse().getSuccess(); - I get the int
    re.getResponse().getFault(); - I get the String
    Has anyone got any ideas how this could be happening?
    - to reiterate I'm successfully returning a "0" from the getSuccess() method, even though the <success> element does not exist in the XML file being unmarshalled,
    thanks,
    Fergus.

    F.Y.I for anyone reading this, I've since spoken to the people who wrote the application that mine is wrapping, and they have got the same anomolous results - a bug in JAXB perchance?

Maybe you are looking for

  • Multiple APP run's for  same vendor

    Dear Friends, I would like to know whether it is possible to do multiple payment proposals for a vendor on same dates. here is the scenario: Each business area would like to creat and edit payment proposals for the same dates, for ex: Run date is 1.1

  • SAP Cloud SDK : Create Quick or List Modification form require in Embed Component

    Hi Experts, I need requirement to create the quick create or List Modification in embed component. I have already make button for "Quick Activity" but i need quick create or List Modification from. I have also try using the following blog. How to cre

  • BC-Adapter. Need proxy settings?

    Hi, i work on a idoc-scenario SAP -> XI -> BC ... In the RWB i got an error "Unknown Network". I think, this could be a proxy-problem, but in the bc-adapter i cannot find any settings to use a proxy? How can i solve this? Regards, Bernd

  • Nameless Nested Classes passed in Function Parameter?

    I am trying to get my head around the following code example: javax.swing.SwingUtilities.invokeLater( new Runnable() { public void run() { createAndShowGUI(); }});What is actually getting passed to the SwingUtilities.invokeLater() function? Can anyon

  • Work book transport problem

    Hi Experts, I have transported the work book to the production system and it went perfectly but my problem is now i have to place the work book under particular role but i am not able to find the work book under favourties or any where in analyzer bu