Hi
Thank you for reading my post.
here i have web service with a method named hello, this method need an
String as parameter.
Service source code:
package servletws;
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;
@WebService
public class HelloServlet {
@Resource WebServiceContext wsContext;
public String hello(String msg) {
return "Servlet WS: " + wsContext.getUserPrincipal()
+ ": " + msg;
}
}
and now I want to invoke that service, here is my code that i want to
use to invoke that service along with my questions regarding it.
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.ServiceFactory;
.....
String wsdlURL = "
https://server8181/ws_ssl_del/HelloServletService?wsdl";
String namespace = "
http://servletws/";
String serviceName = "HelloServletService";
QName serviceQN = new QName(namespace, serviceName);
ServiceFactory serviceFactory = null;
try {
serviceFactory = ServiceFactory.newInstance();
} catch (ServiceException ex) {
ex.printStackTrace();
}
try {
/* The "new URL(wsdlURL)" parameter is optional */
Service service = serviceFactory.createService(new
URL(wsdlURL), serviceQN);
//what should i do now?
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (ServiceException ex) {
ex.printStackTrace();
}
.....
questions :
- Is that mechanism of calling web service is correct? As you can see I
have some jax-rpc import and some jax-ws import, I want just to use
jax-ws, is it do-able to use only jax-ws?
- As you see my web service method (hello) need an String parameter,
how i can pass its parameter when i want to have DDI ?
Thanks, pleas reply with some sample code snippet if you can.