• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

how to convert one string to JAXBElement

 
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I want to set one String to one method in webservices.
But the provider method is accepting JAXBElement.
But I do have the String Value foe that parameter.
So can anybody say how I could convert the string to JAXBElement ??

Please help.
Thanking you,

zeetu
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
If you are developing a client that is to use JAXB, then the first step is to generate JAXB bean classes using XJC (the JAXB XML schema compiler).
With these classes in your project, you can then create a Source object from which the XML data of the request is read along these lines:

Best wishes!
 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ivan
 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I am totally new to this.So could not understand your point. Could you send some sample code so that I can utilize that.

I have used this codes.



and also tried with some other code.



Still I am not able to solve this.


Please help.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
When using JAXB, you start with an XML schema.
From this XML schema, you then generate a number of Java classes using XJC (http://java.sun.com/webservices/docs/2.0/jaxb/xjc.html).
Not until you have completed the above two steps can you start generating XML from instances of JAXB bean classes and/or convert XML to instances of JAXB bean classes.

Check out this JAXB tutorial: https://jaxb.dev.java.net/tutorial/
Make sure you understand what JAXB is and what it is supposed to help you with BEFORE you start writing programs of your own!
Best wishes!
 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ivan,

Thanks a lot.

Yeah I will go through those tutorials.
In fact I solved those issues. My client has given the object factory class . So there are so many methods to convert these things.

Any way thanks a lot .

zeet.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Satchidananda Mohanty wrote:Hi Ivan,

Thanks a lot.

Yeah I will go through those tutorials.
In fact I solved those issues. My client has given the object factory class . So there are so many methods to convert these things.

Any way thanks a lot .

zeet.




Zeet,

can you please let me know how you solve this issue, I have a similar issue, Appreciate you could send the code for this

Demi
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
How to convert object to JAXBElement<myClass> ?

I tried this code and show ClassCastException. Could you tell me how to cast this?

JAXBElement<PricePlanInfo00> aa = theObjFactory.createProductInfoPricePlanInfo((PricePlanInfo00) parameter[1]);


In ObjectFactory.java

private final static QName __ProductInfoPricePlanInfo_QNAME = new QName("", "pricePlanInfo");
@XmlElementDecl(namespace = "", name = "pricePlanInfo", scope = ProductInfo .class)
   public JAXBElement<PricePlanInfo00> createProductInfoPricePlanInfo(PricePlanInfo00 value) {
       return new JAXBElement<PricePlanInfo00>(_ProductInfoPricePlanInfo_QNAME, PricePlanInfo00 .class, ProductInfo .class, value);
   }
 
Onion rings are vegetable donuts. Taste this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic