学习CXF WebService入门实例一(2)

2019-04-16 21:19

呢,大约在网页上会出现下面的信息,只截取一部分,注意画粗红线的地方,下面我们用的到。

五、客户端类(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的第一个程序,不知道为什么都是坑啊,一步一个坑,难道是坑坑更健康?将代码贴出来,希望有用到的或者要学习的小白们能少走一段弯路!本来想把工程给免费发布出来,后来想想还是算了吧,小白们还是手把手的配置一下吧!


学习CXF WebService入门实例一(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2014年辽宁省普通高中地理学业水平考试测试题及答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: