Search code examples
javajavascriptjqueryweb-servicesjax-ws

"Hello World" application on Java JAX-WS


I have a question ... I have an implementation of a simple "Hello World" application on Java JAX-WS:

I did not get access to the methods, specifically "getHelloWorldAsString". I tried jquery and plugin "jquery.soap". How can I call a method from JavaScript? Can you give me an example? Or what do I change in Java code?

ITest.java File:

package ru.ntcsiz.searcher.search.test;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

//Service Endpoint Interface
@SOAPBinding(style = Style.RPC)
public interface ITest {

    @WebMethod String getHelloWorldAsString(String name);

}

TestClass.java:

package ru.ntcsiz.searcher.search.test;

import javax.jws.WebService;

//Service Implementation
@WebService(endpointInterface = "ru.ntcsiz.searcher.search.test.ITest")
public class TestClass implements ITest {

    @Override
    public String getHelloWorldAsString(String name) {
    return "Hello World! It's works! " + name;
    }
}

TestClassPublisher.java:

package ru.ntcsiz.searcher.search.test;

import javax.xml.ws.Endpoint;

public class TestClassPublisher {

    public static void main(String[] args) {
       Endpoint.publish("http://localhost:9999/ws/test", new TestClass());
    }
}

Solution

  • You can use your WSDL and generate a javascript client using apache cxf framework. Details are mentioned in below link

    http://cxf.apache.org/docs/wsdl-to-javascript.html