呢,大约在网页上会出现下面的信息,只截取一部分,注意画粗红线的地方,下面我们用的到。
五、客户端类(http://hello.ws.com/,这个就是上面画粗红线的地方) package com.ws.client; import java.net.URL;
import javax.xml.namespace.QName; import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
import com.ws.entity.Users;
import com.ws.hello.HelloWorldImpl; import com.ws.hello.IHelloWorld;
public final class Client {
private static final QName SERVICE_NAME = new QName(\, \); private static final QName PORT_NAME = new QName(\, \);
public static void main(String args[]) throws Exception { Service service = Service.create(SERVICE_NAME);
String endpointAddress = \
private Client() { }
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
IHelloWorld hw = service.getPort(IHelloWorld.class); System.out.println(hw.sayHello(\张述飞\
} }
这样写点击运行的话,不知道为什么会报异常,如果有不报异常的话,请贴出来,谢谢! Exception in thread \javax.xml.ws.WebServiceException: WSDL Metadata not available to create the proxy, either Service instance or ServiceEndpointInterface com.ws.hello.IHelloWorld should have WSDL information
at
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source)
at
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source)
at javax.xml.ws.Service.getPort(Service.java:168) at com.ws.client.Client.main(Client.java:29)
/**
URL url = new URL(\
Service service = Service.create(url,SERVICE_NAME);
IHelloWorld hw = service.getPort(IHelloWorld.class); System.out.println(hw.sayHello(\张述飞\
System.out.println(hw.getUserName(new Users(1,\ for(Users user : hw.getListUser()) { System.out.println(\ }*/
[id:\
将上面紫色代码注释,运行蓝色代码正常!这是小白我学习webservice的第一个程序,不知道为什么都是坑啊,一步一个坑,难道是坑坑更健康?将代码贴出来,希望有用到的或者要学习的小白们能少走一段弯路!本来想把工程给免费发布出来,后来想想还是算了吧,小白们还是手把手的配置一下吧!