0

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?

1
  • try printing stacktrace in catch block and see. Commented Oct 6, 2014 at 11:55

1 Answer 1

1

Tyr to change your method's public void to public string and return some string at the end of the function. For example, try to return your strMessage at the end.

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

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.