3

Can we generate an xml file using webservices in Java, and if so how?

2
  • How are you describing the format of the XML file? Via a schema or via generation from some Java classes? Commented Sep 16, 2010 at 13:47
  • 1
    As Blaise explained, you could use JAXB to annotate java class so that it can generate XML file automatically. Commented Sep 16, 2010 at 13:49

3 Answers 3

2

Generating XML files has nothing to do with webservices. The common SOAP based webservices communicate with messages written in XML. So to call a webservice, you'll have to create a XML document that implements some xml schema and send the xml document to the servers address. And you won't need files, usually the XML documents are created in memory and not written to files.

Apache Axis2 is a quite powerful library that takes care of most of the marshalling/unmarshalling and communication stuff.

Sign up to request clarification or add additional context in comments.

Comments

2

There are two Java Web Service Standards:

  • Java API for XML Web Services (JAX-WS)
  • Java API for RESTful Web Services (JAX-RS)

Each spec has multiple implementations. GlassFish is the reference implementation for both these standards.

You can either interact directly with XML, or with POJOs that are converted to XML via an XML binding layer. The standard binding layer for JAX-WS and JAX-RS is Java Architecture for XML binding (JAXB).

For an example of a JAX-RS Webservice check out:

Comments

1

Create a web service (e.g. using Java 6 annotations) and let the annotated method return a DOM tree transformed to a string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.