简体   繁体   中英

can i pass the xml object with return type of object in web services

I am new in Web Service Development. I have one concept. please let give me answer. Any one Java web services, xml object is set as parameter and with their return type. example

public object find(Object object){
    ...........
    return object;
}

please any one give me how to do this Concept? advanced Thanks...

Yes you can use jaxb marshelling and pass the xml element as object

      public String asString(
                    JAXBContext pContext, 
                    Object pObject)
                        throws 
                            JAXBException {

java.io.StringWriter sw = new StringWriter();

Marshaller marshaller = pContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
marshaller.marshal(pObject, sw);

return sw.toString();
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM