mardi 25 décembre 2018

Java web service example doesn't work to provide service?

I've this code snippet:

@WebService(targetNamespace = "MyWebService")
public class MyWebService {
    public String transWords(String words) {
        String res = "";
        for (char ch : words.toCharArray()) {
            res += ch + ",";
        }
        return res;
    }

    public static void main(String[] args) {
        Endpoint.publish("http://localhost:8099/service/function", new MyWebService());
        System.out.println("OK");
    }
}

Yes, it runs and print "OK", and then use "chrome" browser and "http://localhost:8099/service/function" gives web page error.

So where did I get wrong and how to fix it? Thanks a lot.




Aucun commentaire:

Enregistrer un commentaire