Creating client for web service

2019-01-29 12:23发布

问题:

I have deployed a simple hello service in jboss server. I can view the wsdl file. Can someone help me with the client side. I mean how to access this service? Is there any way to access from web browser? Method deployed is

@WebMethod
public String greet( @WebParam(name = "name")
String name )
    {
   return "Hello" + name;
    }

回答1:

Try to know what is the wsdl url to access the service which you have just exposed. It might most probably be something like "http://localhost: < port-number >/ems-ejb/?wsdl"

If you type the same in the browser, you should be able to see the wsdl file (page with full of xml tags).

Once done, follow the steps provided here

Example on how to call the method once client stub is generated

String endpoint = "your wsdl url";
GreetImplServiceLocator objGreetImplServiceLocator = new GreetImplServiceLocator();
java.net.URL url = new java.net.URL(endpoint);
GreetIntf objGreetIntf = objGreetImplServiceLocator.getFaultImplPort(url);
 String greetings=objFaultIntf.greet("stackoverflow");