简体   繁体   中英

“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());
    }
}

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

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