I am a Beginner in Java and I am trying to build a Web Service that needs to read Data from XML file. I am using this example XML:
<message>Customer Name</message>
This is my Web Method to read the inner XML text:
@WebMethod(operationName = "ProcessMessage")
public void ProcessMessage(@WebParam(name = "name") String strXML){
String strMessage="";
try {
String xmlString = strXML;
JAXBContext jc = JAXBContext.newInstance(String.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
StreamSource xmlSource = new StreamSource(new StringReader(xmlString));
JAXBElement<String> je = unmarshaller.unmarshal(xmlSource, String.class);
strMessage = je.getValue();
Response response = Response.status(200).build();
} catch (JAXBException ex) {
Logger.getLogger(service.class.getName()).log(Level.SEVERE, null, ex);
}
}
When I run Web Service, input XML example from above and click the button it throws an Exception:
WS00041: Service invocation threw an exception with message : null;
What is wrong with my Web Method?