java 访问 webservice

使用java方式访问之一:

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;

public class HelloWorldClient {

private final static QName SERVICE_NAME
  =new QName("http://server.ws.demo/", "HelloWorld");
private final static QName PORT_NAME
  =new QName("http://server.ws.demo/", "HelloWorldPort");

/**
* @param args
*/
public static void main(String[] args) {
Service service = Service.create(SERVICE_NAME);
String endpointAddress = "http://localhost:8080/HelloWorld"; //wsdl地址
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
HelloWorld hw = service.getPort(HelloWorld.class); //发布服务的接口
System.out.println(hw.sayHi("  cvicse!")); //接口方法调用
}

}

你可能感兴趣的:(java,xml,webservice,SOAP)