You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by priya j <ja...@gmail.com> on 2007/12/11 11:57:37 UTC

issue in HTTP Binding - Output xml

Hi all,

I am using the CXF HTTP binding for my application. I have an issue with the
xml output, can anyone help me on this. Im new to web services.

Here is my query: - example from CXF samples
the output is:

- <Customers xmlns="http://sphsearch.webservice.com">
- <customer>
  <id>123</id> 
  <name>Dan Diephouse</name> 
  </customer>
  </Customers>

Why is the xml tag missing? <?xml version="1.0" encoding="UTF-8" ?> 
If i am wrong anywhere let me know? 

One more query is, can we change the order of the sub elements.(ie) the name
first and then the id

Please do help me.
Thanks inadvance
-- 
View this message in context: http://www.nabble.com/issue-in-HTTP-Binding---Output-xml-tp14271233p14271233.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: issue in HTTP Binding - Output xml

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 11 December 2007, priya j wrote:
> Hi all,
>
> I am using the CXF HTTP binding for my application. I have an issue
> with the xml output, can anyone help me on this. Im new to web
> services.
>
> Here is my query: - example from CXF samples
> the output is:
>
> - <Customers xmlns="http://sphsearch.webservice.com">
> - <customer>
>   <id>123</id>
>   <name>Dan Diephouse</name>
>   </customer>
>   </Customers>
>
> Why is the xml tag missing? <?xml version="1.0" encoding="UTF-8" ?>
> If i am wrong anywhere let me know?

The xml tag is optional, especially over HTTP.  For the most part, the 
content type and charset are both encoded in the HTTP headers, so the 
xml tag is just wasted bandwith so we exclude it.   You could easily 
create an interceptor that could add it.  Configuration could then be 
used to add that interceptor.  

> One more query is, can we change the order of the sub elements.(ie)
> the name first and then the id

Well, the easy way is to just reorder the fields and methods in the 
Customer.java object.   However, with JAXB, you can add an annotation to 
set the order.  Something like:

@XmlType(name = "Customer", propOrder = {
    "name",
    "id"
})


-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog