Building Objects with JAXB...

How on earth do I write the .xjs file for this DTD? It should be simple but
          I'm really stumped. What I want is for all of the elements within <inpea>
          to end up in a single list (<choice collection="list"....>) so that I can
          cycle through depending on which element in the fields is etc. add delete
          and append new records to the XML from a web based form.
          Here is the DTD:
          <!ELEMENT inpea (cols*)>
          <!ELEMENT cols (header1*, header2*, content*, link*, options*)>
          <!ATTLIST cols number CDATA "1">
          <!ELEMENT header1 (#PCDATA)>
          <!ELEMENT header2 (#PCDATA)>
          <!ELEMENT content (#PCDATA)>
          <!ELEMENT link (#PCDATA)>
          <!ATTLIST link href CDATA "">
          <!ELEMENT options (option*)>
          <!ELEMENT option (#PCDATA)>
          The .xjs file is currently as follows...
          <xml-java-binding-schema version="1.0ea">
               <element name="inpea" type="class" root="true"/>
               <element name="cols" type="class" root="true">
               <attribute name="number" convert="int"/>
               </element>
          </xml-java-binding-schema>
          Any help on doing this is very much appreciated! Thank you!
          I also thought that I would be able to use #CDATA to preserve the formatting
          of the <content> contents... I don't seem to be able to get it to work hence
          why its not in the DTD.
          Thanks Again!
          

Hi everybody,
I am working on an example with the JAXB, which in
many ways is an extraordinary technology, but I have
quite a problem.
I have compiled my schema with xjc - no problem, but i
am missing to setMethods both of which is regarding a
List. I've got
java.util.List getSparepart() and java.util.List
getCategory() but am missing the two set methods and I
don't understand why.You don't need the SET methods for that. You can get to the list via the GET methods and then add/remove elements to/from it or empty/clear it. If you want to set an entirely different list, you could always use-
getSparePart().clear();
getSparePart().addAll(myNewList);
Hope this helps.

Similar Messages

  • Error when building object with DCOM Connector

    Hello everybody,
    I'm new to SAP programming so please forgive my ignorance...
    We are trying to build a com object to call some RFC-functions from a VB 6 application. We use DCOM Connector V6.2, I have MS Visual C++ 6.0 installed, unfortunately I don't know the R/3 version of our client.
    Every time I click the button "Build Component DLL", the following message appears: "cannot read value of registry entry software\sap\mts\proxygenerator\additionalincludedirs"
    This registry entry exists, so I don't know, whats wrong. I run DCOM Connector on Win XP, IE 6. I also tried on a Windows 2000 system, with the same error message.
    I hope you can help me, I searched a long time on the forums and didn't find anything.

    Obviously my question did not get to much interest. Luckily I found out the answer myself.
    The message from the component builder results from this registry key beeing empty. For some reason the SAP GUI installation routine did not fill it out. I then found that by inserting whatever value into that key, the compilation started and hung with another error (file mkenv.inc not found). After surching for that file I found it was installed in C:\Programme\SAP\FrontEnd\SAPgui\rfcsdk\include
    So, bingo, the empty registry value "software\sap\mts\proxygenerator\additionalincludedirs" must be filled "C:\Programme\SAP\FrontEnd\SAPgui\rfcsdk\include" or what corresponds to your installation and it works. At least the component dll was built, I have to test now if it is running correctly...

  • Set methods or typecasting objects with JAXB

    Hi everybody,
    I am working on an example with the JAXB, which in many ways is an extraordinary technology, but I have quite a problem.
    I have compiled my schema with xjc - no problem, but i am missing to setMethods both of which is regarding a List. I've got
    java.util.List getSparepart() and java.util.List getCategory() but am missing the two set methods and I don't understand why.
    I have tried to solve the problem by defining the methods myself, which is allright right until the point where I use the methods.
    Here is a snip of the code:
    spTest.jaxb.CatalogType.VendorType vNowTemp = (spTest.jaxb.CatalogType.VendorType) objFactory.createCatalogTypeVendorType();
    vNowTemp = vNow;
    vNowTemp.setSparePartCategory(categoryResult);
    vNowTemp = vNow;
    result.add(vNowTemp);
    The problem is that there seems to be no difference between vNow or vNowTemp at any point, which there should be.
    I have tried to convert the java.util.List I get when I use getSparePart to a com.sun.xml.bind.util.ListImpl (which is the object type used within the classes JAXB's xjc produced) but this seems to be impossible.
    Could any one help me on this one please
    /Sebastian
    [email protected]

    Hi everybody,
    I am working on an example with the JAXB, which in
    many ways is an extraordinary technology, but I have
    quite a problem.
    I have compiled my schema with xjc - no problem, but i
    am missing to setMethods both of which is regarding a
    List. I've got
    java.util.List getSparepart() and java.util.List
    getCategory() but am missing the two set methods and I
    don't understand why.You don't need the SET methods for that. You can get to the list via the GET methods and then add/remove elements to/from it or empty/clear it. If you want to set an entirely different list, you could always use-
    getSparePart().clear();
    getSparePart().addAll(myNewList);
    Hope this helps.

  • Can an arbitrary object be marshalled with JAXB?

    Is it possible to marshall an arbitrary Java object with JAXB?
    I would think this is possible if
    (i) marshalling works on non-public fields
    (ii) xml can handle all Java primitive types, including byte[]
    And, it it is possible, how would you unmarshall it?
    bw

    I don't believe it is possible for JAXB to marshal and un-marshal an arbitrary object. Your object would need to implement the MarshallableObject. Usually with JAXB you wouldn't actually create the MarshallableObject yourself, you would just create it from your binding schema and DTD.

  • Web services with JAXB

    Hi All,
    I am new to Web services with JAXB in ECLIPS.
    When I tried to unmarshal the XML file, I am getting the following exception.
    javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"order"). Expected elements are <{http://webservices/}read>,<{http://webservices/}readResponse>
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent
    xml , schema and java class are in follow.
    Please help me to solve this issue.
    Mohseni Rad.
    ----------------------------------po.xsd-----------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="order" type="OrderType"/>
    <xsd:complexType name="OrderType">
    <xsd:sequence>
    <xsd:element name="shipTo" type="xsd:string"/>
    <xsd:element name="billTo" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    ------------------------------------po.xml----------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <order>
    <shipTo>shipto</shipTo>
    <billTo>billto</billTo>
    </order>
    ------------------TestWS.java---------------------
    import java.io.FileInputStream;
    import java.io.IOException;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.JAXBElement;
    import javax.xml.bind.JAXBException;
    import javax.xml.bind.Unmarshaller;
    import wsclient.*;
    public class TestWs {
         public static void main(String[] args) {
              try{
                   SecondWebServices webService = new SecondWebServicesService
    .getSecondWebServicesPort();
                   JAXBContext jctx = JAXBContext.newInstance("wsclient");
                   Unmarshaller unmarshaller = jctx.createUnmarshaller();
                   FileInputStream fl = new FileInputStream( "etc//po.xml" );
         JAXBElement<?> order = (JAXBElement<?>)unmarshaller.unmarshal( fl );
                   OrderType orderType = (OrderType)order.getValue();
                   webService.read( orderType);
              }catch (JAXBException je) {
                   je.printStackTrace();
              catch (IOException ioe) {
                   ioe.printStackTrace();
    }

    Hi,
    When you are using JAX-WS, there is a tool wsimport, with which you are going to generate the artifacts required to implement the web service.
    When you pass the WSDL as a parameter to the wsimport tool, it will be create the required beans also(JAXB Objects).
    So need of any other external implementation of JAXB when you are working with JAXWS
    Thanks,

  • Unable to transport Integratin Builder objects from Dev to QA correctly

    Hi,
    System : Pi 711 SPS03
    SLD 7.1 with  latest model and content
    We are trying to transport Integration Builder Objects from Dev to QAS, but the SID translation from DEV to QAS is not working.
    The interface is being imported as the source SID.
    We checked the SLD configuration for Transport targets, that is when we realised the below issue.
    Unable to Assign Business Systems in respective Business System Groups
    The expected configuration of the SLD is as below:
    UKD_400  - Integration Server for Dev PI 711 server
    INTEGRATION_SERVER_UKQ - Integration Server for QAS PI 711 server
    XI_QA - Business System Group for all Quality Systems in the landscape
              1) UKD_400
              2) UC1_ECC_60
              3) UED_400
    XI_DEV - Business System Group for all Developement Systems in the landscape
              1) INTEGRATION_SERVER_UKQ
              2) UC2_400
              3) UEQ_400
    We are unable to put the business systems in their respective groups
    All the Business systems are either being assigned in XI_QA or XI_DEV
    Please let us know if this is a product error in SLD 7.1, could not find any relevant notes
    Thanks,
    Govind
    Edited by: Govind Prathi on Feb 12, 2010 10:25 PM
    Edited by: Govind Prathi on Feb 12, 2010 10:27 PM

    We  have already  assinged the Integration server to their respective business system groups while creating the Business system groups.
       BSG: XI_DEV --> UKD_400( Integration Server DEV )
      BSG : XI_QA  ---> INTEGRATION_SERVER_UKQ( Integration Server QA)
    As per documentation, the business systems should be automatically assigned to their respective Groups based on their association with Integration Server.
    But, we are not seeing this behaviour, both the Integration servers are being assigned to the same Business System Group.
    Please help me understand if i am something in the configurations.
    Thanks
    Govind

  • How can i build table with two user name columne  ?

    How can I build view with two columns for user name ( one create and the other
    Can change also ) 
    And to display full name ( the user name is the key but not display  ) ?

    Hi,
    Creating View
    •     From initial screen of data dictionary(T.Code: SE11), enter the name of object i.e. view.
    •     Select view radio button and click on the push button.
    •     Dialog box is displayed for types of views.
    •     Select the view type.
    •     On the next screen, you have to pass following parameters.
    •     Short text
    •     In the table box you need to enter the table names, which are to be related.
    •     In join table box you need to join the two tables.
    •     Click on the TABFIELD. System displays the dialog box for all the table fields and user can select the fields from this screen. These fields are displayed in the view fields box.
    •     Save and Activate: When the view is activated, view is automatically created in the underlying database system. As long as the table exists in the database, the view also exists (Unless you delete it).
    Regards,
    Bhaskar

  • Can't generate setters for array or collection classes with JAXB

    I am trying to use JAXB to generate the required setters for Spring beans. Although according to the book Java & XML Data Binding
    Chapter 3 page 42 by Brett McLaughlin it was possible with DTD's using
    <?xml version="1.0"?>
    <xml-java-binding-schema version="1.0-ea">
    <options package="javajaxb.generated.movies" default-reference-collection-type="array" />
    <element name="movies" type="class" root="true"/>
    </xml-java-binding-schema>
    to generate an array as in
    public Movie[] getMovie( ) {
    // implementation
    public void setMovie(Movie[] _Movie) {
    it doesn't look like that capability exists with JAXB 2.0 and XML Schemas. In their wisdom they just generate getters on Lists and tell you:
    <p>
    * This accessor method returns a reference to the live list,
    * not a snapshot. Therefore any modification you make to the
    * returned list will be present inside the JAXB object.
    * This is why there is not a <CODE>set</CODE> method for the filingForm property.
    * <p>
    * For example, to add a new item, do as follows:
    * <pre>
    * getFilingForm().add(newItem);
    * </pre>
    Of course this doesn't work for Spring injection where setters are needed.
    Does anyone know different or is there a way of getting around this ?
    I've tried constructor injection in Spring but it's not as convenient and involves extensive coding of generated code (not nice).
    Edited by: user3806112 on Mar 15, 2011 11:13 AM

    Oh I found it on this post
    http://cxf.547215.n5.nabble.com/NPE-in-generated-setter-method-when-collectionType-quot-indexed-quot-and-a-null-array-is-used-td3323012.html
    collectionType="indexed" in the globalBindings-tag
    it works in schema internal global bindings as well
    <jaxb:globalBindings collectionType="indexed" >

  • XML (un)marshalling with JAXB and "any" blocks

    I have 2 very simple XSD schema's.
    SchemaA.xsd:
    [request]-------[element_A] is xs:string
    |__(ANY)
    SchemaB.xsd:
    [body]--------[element_B] is xs:string
    The any block says that there can follow any type of xml after the element_a.
    In the xsd it is coded as: <xs:any />
    I compiled both schema's with jaxb, using this command line:
    xjc SchemaA.xsd -p test.request
    xjc SchemaB.xsd -p test.body -use-runtime test.request.impl.runtime
    I created the following code :
    test.request.ObjectFactory of1 = new test.request.ObjectFactory();
    test.body.ObjectFactory of2 = new test.body.ObjectFactory();
    Request r = of1.createRequest();
    r.setElementA("testing, element one");
    Body b = of2.createBody();
    b.setElementB("testing, element two");
    r.setAny(b);
    Marshaller m = of1.createMarshaller();
    m.marshal(r,System.out);
    And the result is what I expected:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <request><element_a>testing, element one</element_a><body><element_b>testing, element two</element_b></body></request>
    JAXB added the xml from the second schema to the first.
    Ok, so far so good. Now I'm trying to do it the other way around, I want to unmarshall that XML to objects again:
    String xml <- contains the outputted xml from the marshall (as pasted a few lines above)
    Unmarshaller um = of1.createUnmarshaller();
    Request r2 = (Request)um.unmarshal(new ByteArrayInputStream(xml.getBytes()));
    System.err.println(r2.getElementA());
    System.err.println(r2.getAny());
    The output:
    testing, element one
    null
    now, the first message is good. The second is not however...why is the "getAny" null ? I can't figure this one out. In the best possible case it should return an object that can be cast to "Body" .
    In the worst case it should just return the "<Body> ...." xml as string. But not null ...
    Any help on this is appreciated !

    JAXB does not support xs:any

  • Serializing objects with the NIO API

    I try to use the new IO API to implement a non-blocking multi-threaded server that communicates with client applications by exchanging serialized objects. I started from the code in the JavaWorld article at http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html .
    With the new features of J2SDK 1.4.0, you don't have to create a separate thread per connected client. That is a big improvement.
    But when I read an object with ObjectInputStream, I get a java.nio.channels.IllegalBlockingModeException.
    Has anybody successfully implemented such a server since the release of the new io API?
    Thanks.
    Jean-Robert

    The ObjectStream code is basically incompatible with non blockin I/O since you must block on the stream until a whole Object is available. You could roll something like this yourself, by reading bytes until there are enough available to build the next object and then getting that Object from the buffer and shipping it to your client thread. All of this is far more trouble than just using the Stream oriented I/O.
    NIO and mutilple threads are a nightmare, the whole idea of non-blocking I/O is to avoid needing multiple threads. If you do use multiple threads you will need queues between them. See the Taming the NIO Circus topic for lots of discussion of NIO and its problems. The system seems more stable in JDK 1.5, but most people haven't even started using 1.4 for production yet.
    Personally I avoid ObjectStreams. They are only useful between Java applications, if I want that I just use RMI and let Java do ALL the hard work. When I write a Socket based app, its probably because the other end is a mainframe of a C program. For that reason I send data as bytes, packaged up in packets, and encode as XML or ASN.1 so the other end can interpret it.

  • Consuming Domino web service with JAXB encounters Method Response element

    I am able to consume a Domino R7 (Axis) web service with JAX-WS using Dispatch<SOAPMessage>. When I try using Dispatch<Object> however, JAXB throws an exception because it encounters an unexpected tag.
    The XML from the web service looks like this:
    <Envelope>
        <Body>
            <WebServiceMethodResponse>
                <WebServiceMethodReturn>
                    The meaning of life
                </WebServiceMethodReturn>
            </WebServiceMethodResponse>
        </Body>
    </Envelope>With Dispatch<SOAPMessage>, I can get to the meaning of life quickly using SOAPBody.getElementsByTagName( "WebServiceMethodReturn" ) but with Dispatch<Object>, it appears I must also create a class for the WebServiceMethodResponse element to make JAXB happy. I don't see this happening in other people's examples. Has the Return-element-within-Response-element design been eliminated in pure JAX-WS web services, or is this something that only IBM does?

    In case anyone's search leads them here, I've posted the solution at:
    *[http://www.pby.com/general.nsf/webarticles/dominowebservice01]*
    It is an exhaustive article (not "Hello World"!) that goes through several versions of the web service and client - hopefully explaining all+ pieces of the puzzle:
    ~ web service code,
    ~ WSDLs
    ~ schema
    ~ thoroughly-documented clients that do and do not use JAXB
    ~ ... that use generated artifacts
    ~ ... that customize existing POJOs
    ~ the SOAP messages generated in each direction
    ~ the necessary JAXB annotations
    ~ explanations of how the code works
    ~ explanations of how namespaces affect the code
    ~ on and on and on...
    My constant goal was to write an uncomplicated solution that uses as few artifacts (two) and annotations as possible. The end result is a small, fast JAX-WS 2.0 client that uses JAXB to invoke and consume a secured Domino 7 (1.4.2 JVM + AXIS) web service, using RPC/literal SOAP messages.

  • Implenting webdynpro as a Calable Object with GP Interface

    Hi People,
    I have created a webdynpro application, and want to implement it as a callable object with GP interface,
    I have added all the required DC's.
    There is no error in Build,
    There in no error in Deployment,
    But when I try to create the Callable object of the application deployed,
    on selection of the application it says,
    <b>
    Cannot read callable object description from component: Failed to create delegate for custom controller lti.com.testwd1.TestWDComp1Interface. (Hint: Is the corresponding DC deployed correctly? Does the DC contain the component?)</b> 
    and does not allow me to go next,
    Please Suggest, I am not even able to find the error or cause of this behaviour,
    Thanks in advance,
    Deepak

    Hi Deepak,
    When you try to create a callable object of type webdynpro with GP interface, GP will call the getDescription method of the webdynpro interface controller.
    I guess you are getting some problem with this method. Check your code written in this method.
    Also check whether your application has been deployed successfully on the server from the visual administrator.
    Regards,
    Bhavik

  • Problem building GTK with jbuild on Mac OS X

    Hi everyone,
    I don't know if this is the right place to ask my question...
    I cannot build GTK with jbuild on my Leopard 10.5.8 system.
    I have deleted the Leopard built-in Python 2.5 folder (At that time I didn't know that deleting the default system Python is not good....) and I have installed Python 2.7 (from the .dmg file).
    I also Installed Apple Developer Tools, which I guess should be XCode 3.0.
    On the terminal I verified my Python version:
    $ which python
    /Library/Frameworks/Python.framework/Versions/2.7/bin/python
    Then I followed this guide to build GTK:
    http://sidhosting.co.uk/josh_fradley/getting-emesene-2-up-and-running-on-os-x/
    which is basically the same as the one in Gnome site:
    http://live.gnome.org/GTK%2B/OSX/Building#Procedure
    I followed the first guide, but it gives me some errors:
    macbook-pro-di-zhu-francesco-yangfan:~ francesco$ curl -o gtk-osx-build-setup.sh https://raw.github.com/jralls/gtk-osx-build/master/gtk-osx-build-setup.sh
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3716  100  3716    0     0   1612      0  0:00:02  0:00:02 --:--:-- 1814k
    macbook-pro-di-zhu-francesco-yangfan:~ francesco$ sh gtk-osx-build-setup.sh
    Checking out jhbuild (2.32.4) from git...
    From git://git.gnome.org/jhbuild
    * tag               2.32.4     -> FETCH_HEAD
    Installing jhbuild...
    Installing jhbuild configuration...
    Installing gtk-osx moduleset files...
    PATH does not contain /Users/francesco/.local/bin, it is recommended that you add that.
    Done.
    macbook-pro-di-zhu-francesco-yangfan:~ francesco$ PATH=$HOME/.local/bin:$PATH
    macbook-pro-di-zhu-francesco-yangfan:~ francesco$ export PATH
    macbook-pro-di-zhu-francesco-yangfan:~ francesco$ jhbuild bootstrap
    Traceback (most recent call last):
      File "/Users/francesco/Source/jhbuild/jhbuild/config.py", line 212, in load
        execfile(self.filename, config)
      File "/Users/francesco/.jhbuildrc", line 90, in <module>
        _xcodeversion = xcode_ver()
      File "/Users/francesco/.jhbuildrc", line 89, in xcode_ver
        return float(exp.match(_ver).group(1))
    AttributeError: 'NoneType' object has no attribute 'group'
    jhbuild: could not load config file
    Anyone can tell me why I got this error?
    It seems that jbuild doesn't see my xcode version? But I did install it!
    It's very strange because I succeeded to do 'jbuild bootstrap' before when I used to have Python 2.5, although I got stuck for other commands more forward.
    Thanks everyone.

    You may want to also post over in the Developer forums...
    https://discussions.apple.com/community/developer_forums

  • Parsing (skipping) unknown tags with JAXB...

    Does anybody know how can I skip unrecognised tags, during unmarshalling an XML document with JAXB?
    For example : the schema-compliant document is :
    <document>
    <Version>3.20</Version>
    <Account>Account</Account>
    <Password>Password</Password>
    </document>
    and a possible modification would be :
    <document>
    <Version>3.21</Version>
    <unknowntag>aaaabbbb</unknowntag>
    <Account>Account</Account>
    <Password>Password</Password>
    </document>
    (a new unknown tag was introduced).
    so : the document is well-formed anyway (not strictly valid), but the second time a new unknown tag was introduced. I couldn't map it to a Java object (of course, because my data model could not foresee it), but I would like JAXB to skip it and have the program flow behaving exactly as the first case... ignoring this new unknown tag.
    Thanks for any answer anybody could ever give me...
    Emilio.

    Finally I found a workaround to this problem :
    I used an XSL transformation from the incoming document into itself, according to the pattern matching provided by an xsl stylesheet, before giving it to JAXB. Definitely an XSL specular preprocessor (wow! sound cool!).
    That is :
    having an incoming XML document, I write an XSL stylesheet that transforms the original XML document into another XML having the same tags (that is... itself).
    In this way, I can then give to JAXB a resulting XML document that contains ONLY those tags that I was expecting it to elaborate, since all the others (the unknown ones) were discarded by the xsl preprocessor.
    And... that's it.
    In this way I finally wrote an application able to skip unrecognized tags and elaborating by JAXB only the know ones. And that's what I was looking for :-)
    Hope it could help you.
    Bye,
    emils.

  • Why does Livecycle Designer need to lock scripting on objects with children that are fragments??

    Can someone tell me why Livecycle need to lock scripting on objects with children that are fragments??
    I mean, just because I have a fragment (which you can't edit the script for), why does Livecycle need me to NOT edit say the initialise event on the Main form.
    Yes, I can remove my fragments, edit and reinsert.  Also if the event already has a script, I can edit the xml.  But neither of these are terribly convenient.
    Couldn't there be a better way?

    The purpose of the fragment is to create re-usable or standard components. In most cases the fragment is not created by the same person designing the form and they do not want the from designer to modify any part of the fragment (it is a separate XDP file). There may be code in that fragment that relies on the structure that exists. If you have the rights you can always edit the fragment and when your PDF is created the changes will be picked up.
    If you want to be able to modify the fragment while it is in Design mode sounds to me like you want to add a component to the object library. This will allow you to have a reusable piece of a form that you can modify on a form by form basis. To do this simply build the piece that you want. Lasso the entire form and drag it onto the Custom library. When you release it a dialog will pop up allowing you to name your component. Now on any form design you can drag your new component onto the canvas and all methods/properties and code will come with that component (allowing you to modify it for that form as you see fit).
    Note that you can create your own libraries to hold your components if you see fit. Also if you put your libraries on a shared drive, you can share components between Designers.
    Paul

Maybe you are looking for