• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing a matrix

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to pass a matrix to my web service, perform some computation there and receive a solution. What would you suggest to pass the matrix? XML format?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
of course. what your option?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I pass a serialized object to a web service's method?
 
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!
With web services, data is commonly passed in XML or JSON (http://en.wikipedia.org/wiki/Json) format in order to facilitate interoperability.
When using JAX-WS or JAX-RS tools, objects that are to be passed between clients and server are marshaled to XML, using for instance JAXB, or to JSON, using for instance Jackson, and later unmarshaled to Java objects. Commonly, marshaling and unmarshaling are hidden from the developer (but it depends on the development environment etc).
Interoperability is one of the main arguments for using web services. If you do not have any requirements in that area, you may also consider using, for instance, RMI, which will allow you to use plain serialization to pass data between client(s) and server.
Best wishes!
 
Lucas Smith
Ranch Hand
Posts: 808
1
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. I have the matrix in txt file in that format:

value value ...
.
.
value...

Could you give me an example how to pack it into XML format? And then, how can I invoke web service's method with that matrix as an argument? I will be really grateful for help.

PS what do you mean by interoperability?
 
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!
First of all, interoperability is the ability for, for instance, a web service implemented in Java is able to communicate with a client written in another language, like .NET.
Despite using XML (for SOAP web services), interoperability is not guaranteed.

Second, here is how to represent a map using XML; first the XML schema:

The XML schema includes an uniqueness constraint on the key in a key-value list.
Finally, an example of what an XML document adhering to the above schema may look like:

Hope this helps!
 
Lucas Smith
Ranch Hand
Posts: 808
1
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.
How can I pass that XML file to Webservice (JAX-WS)?
I would like to invoke webservice's method using that XML file as an argument.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone help?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nobody knows? I do not believe
 
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!
If you are doing WSDl-first development, then you just paste the XML schema from my posting into your WSDL and use the data type appropriately.
If you are doing Java-first development, then you can use the JAXB schema compiler XJC to generate Java classes corresponding to the schema.
When generating Java classes with XJC, you will loose the uniqueness constraint specified in the XML schema.
Best wishes!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic