webservice 初涉

WebService runtime modeler error: Wrapper class XXX is not found. Have you run APT to generate them

环境

  MyEclipse 8.6 + JDK 1.6.31

问题

  启动WebService项目出现如下异常:

  严重: WSSERVLET11: failed to parse runtime descriptor: runtime modelererror: Wrapper class com.axt.service.jaxws.GetTimePoint is not found. Have yourun APT to generate them com.sun.xml.ws.model.RuntimeModelerException:runtime modeler error: Wrapper class com.axt.service.jaxws.GetTimePoint is notfound. Have you run APT to generate them atcom.sun.xml.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:285) atcom.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:596) atcom.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:543) atcom.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:370) atcom.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:256) atcom.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:322) atcom.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:188) atcom.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467) atcom.sun.xml.ws.transport.(DeploymentDescriptorParser.java:253) atcom.sun.xml.ws.transport.(DeploymentDescriptorParser.java:147) atcom.sun.xml.ws.transport.(WSServletContextListener.java:108) atorre.StandardContext.listenerStart(StandardContext.java:3843) atorre.StandardContext.start(StandardContext.java:4342) atorre.ContainerBase.addChildInternal(ContainerBase.java:791) atorre.ContainerBase.addChild(ContainerBase.java:771) atorre.StandardHost.addChild(StandardHost.java:525) atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) atorre.ContainerBase.start(ContainerBase.java:1053 atorre.StandardHost.start(StandardHost.java:719) atorre.ContainerBase.start(ContainerBase.java:1045) atorre.StandardEngine.start(StandardEngine.java:443) atorre.StandardService.start(StandardService.java:516) atorre.StandardServer.start(StandardServer.java:710) atorg.apache.catalina.startup.Catalina.start(Catalina.java:578) atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) atjava.lang.reflect.Method.invoke(Method.java:597) atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 2012-10-25 19:23:13orre.StandardContext listenerStart 严重: Exception sending context initialized event to listener instanceof class com.sun.xml.ws.transport.ptor: runtime modeler error: Wrapperclass com.axt.service.jaxws.GetTimePoint is not found. Have you run APT togenerate them atcom.sun.xml.ws.transport.(WSServletContextListener.java:118) atorre.StandardContext.listenerStart(StandardContext.java:3843) atorre.StandardContext.start(StandardContext.java:4342) atorre.ContainerBase.addChildInternal(ContainerBase.java:791) atorre.ContainerBase.addChild(ContainerBase.java:771) atorre.StandardHost.addChild(StandardHost.java:525) atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) atorre.ContainerBase.start(ContainerBase.java:1053) atorre.StandardHost.start(StandardHost.java:719) atorre.ContainerBase.start(ContainerBase.java:1045) atorre.StandardEngine.start(StandardEngine.java:443) atorre.StandardService.start(StandardService.java:516) atorre.StandardServer.start(StandardServer.java:710) atorg.apache.catalina.startup.Catalina.start(Catalina.java:578) atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) atjava.lang.reflect.Method.invoke(Method.java:597) atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by:com.sun.xml.ws.model.RuntimeModelerException: runtime modeler error: Wrapperclass com.axt.service.jaxws.GetTimePoint is not found. Have you run APT togenerate them atcom.sun.xml.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:285) atcom.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:596) atcom.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:543) atcom.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:370) atcom.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:256) atcom.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:322) atcom.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:188) atcom.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467) atcom.sun.xml.ws.transport.(DeploymentDescriptorParser.java:253) atcom.sun.xml.ws.transport.(DeploymentDescriptorParser.java:147) atcom.sun.xml.ws.transport.(WSServletContextListener.java:108) ...24 more

原因

  cxf需要jaxws-api-2.1.jar及jaxb-api-2.1.jar的支持。

解决办法

  1.  检查项目里是否有上述相关Jar包,如果没有,将cxf所需的2.1的jar复制一份到jdk目录下的jre\lib\endorsed文件夹中。如果endorsed文件夹不存在,可新建。

  2.  项目里是有上述相关Jar包,还需要在public class XXX类上方加入@SOAPBinding(style = SOAPBinding.Style.RPC);

  3.  JDK升级到1.6.0.22版本以上;

接口方法:

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public interface HelloInt {

    @WebMethod
    public String sayHello(String name );

}

实现:

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class HelloImpl implements HelloInt {

    @Override
    public String sayHello(String name) {
        return "hello,"+name;
    }

}

测试方法:

import javax.xml.ws.Endpoint;

public class ServerTest {

    public static void main(String[] args) {
        String address = "http://192.168.1.110:8989/d01ws/hello";
        Endpoint.publish(address,new HelloImpl());
        System.out.println("webservice发布成功");
    }

}

浏览器中输入发布的地址:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI‘s version is JAX-WS RI 2.1.1 in JDK 6. -->

<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI‘s version is JAX-WS RI 2.1.1 in JDK 6. -->
-<definitions name="HelloImplService" targetNamespace="http://wa.com/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://wa.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <types/> -<message name="sayHello"> <part name="arg0" type="xsd:string"/> </message> -<message name="sayHelloResponse"> <part name="return" type="xsd:string"/> </message> -<portType name="HelloImpl"> -<operation name="sayHello" parameterOrder="arg0"> <input message="tns:sayHello"/> <output message="tns:sayHelloResponse"/> </operation> </portType> -<binding name="HelloImplPortBinding" type="tns:HelloImpl"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> -<operation name="sayHello"> <soap:operation soapAction=""/> -<input> <soap:body namespace="http://wa.com/" use="literal"/> </input> +<output> </operation> </binding> -<service name="HelloImplService"> -<port name="HelloImplPort" binding="tns:HelloImplPortBinding"> <soap:address location="http://192.168.1.110:8989/d01ws/hello"/> </port> </service> </definitions>

在客户端调用:

新建一个java工程:

在命令窗口中编译 发布的地址,wsimport -keep http://192.168.1.110:8989/d01ws/hello?wsdl  生成的代码如下:

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.1 in JDK 6
 * Generated source version: 2.1
 *
 */
@WebService(name = "HelloImpl", targetNamespace = "http://wa.com/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface HelloImpl {

    /**
     *
     * @param arg0
     * @return
     *     returns java.lang.String
     */
    @WebMethod
    @WebResult(partName = "return")
    public String sayHello(
        @WebParam(name = "arg0", partName = "arg0")
        String arg0);

}

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;

/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.1 in JDK 6
 * Generated source version: 2.1
 *
 */
@WebServiceClient(name = "HelloImplService", targetNamespace = "http://wa.com/", wsdlLocation = "http://192.168.1.110:8989/d01ws/hello?wsdl")
public class HelloImplService
    extends Service
{

    private final static URL HELLOIMPLSERVICE_WSDL_LOCATION;

    static {
        URL url = null;
        try {
            url = new URL("http://192.168.1.110:8989/d01ws/hello?wsdl");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        HELLOIMPLSERVICE_WSDL_LOCATION = url;
    }

    public HelloImplService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public HelloImplService() {
        super(HELLOIMPLSERVICE_WSDL_LOCATION, new QName("http://wa.com/", "HelloImplService"));
    }

    /**
     *
     * @return
     *     returns HelloImpl
     */
    @WebEndpoint(name = "HelloImplPort")
    public HelloImpl getHelloImplPort() {
        return (HelloImpl)super.getPort(new QName("http://wa.com/", "HelloImplPort"), HelloImpl.class);
    }

    /**
     *
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns HelloImpl
     */
    @WebEndpoint(name = "HelloImplPort")
    public HelloImpl getHelloImplPort(WebServiceFeature... features) {
        return (HelloImpl)super.getPort(new QName("http://wa.com/", "HelloImplPort"), HelloImpl.class, features);
    }

}

客户端测试:

import com.wa.HelloImpl;
import com.wa.HelloImplService;

public class ClientTest {

    public static void main(String[] args) {
        HelloImplService service = new HelloImplService();
        HelloImpl hello =service.getHelloImplPort();
        System.out.println(hello.sayHello("good"));
    }

}

控制台输出:

hello,good.

至此,测试成功。

时间: 2024-10-11 17:58:42

webservice 初涉的相关文章

webservice(一) 初涉

Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class com.wa.jaxws.SayHello is not found. Have you run APT to generate them?  at com.sun.xml.internal.ws.model.RuntimeModeler.getCla

自定义及发布一个webservice服务

自定义及发布一个webservice服务    - 声明 某个业务服务为webservice服务       通过@webservice 注解来声明    - 发布webservice服务       Endpoint.publish()发布 (默认对public修饰的方法进行发布)    - 通过wsimport生成本地代理来访问自己发布的webservice       wsimport 1.发布自定义webservice phone.java package ws.myWebService

调用已发布的WebService

WebService服务演示 登录http://www.webxml.com.cn 单击手机查询服务 3.         选择要调用的方法 例如: getMobileCodeInfo. 4. 输入要查询的手机号单击”调用” 截图如下, 免费用户 UserID为null a)   可以看到返回如下结果: <?xml version="1.0" encoding="utf-8" ?> <string xmlns="http://WebXml

webservice实验一

实验目的:安装jdk1.6_21以后的版本,利用JAX-WS API自己发布webservice并调用,以及用wsimport生成webservice客户端代码调用一个免费的web服务(如webxml.com.cn上的获取手机归属地的服务). 一.webservice原理了解 webservice是一种通用的跨语言跨平台的数据交互方式,之所以能够做到这一点,是因为它的底层实现机制是依赖于HTTP协议以及XML格式这些开发的标准.webservice使用SOAP(simple object acc

C# 动态生成WebService,无需添加引用

C#项目调用WebService是很常见的现象,但一旦修改链接地址就需要重新更新引用很是麻烦,这里跟大家分享一个通过地址,无需添加引用动态生成Webservice的小方法 方法类: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.ServiceModel; 6 using System.ServiceModel.Channels

一个简单的WebService服务

现在,网上提供的免费的webservice服务的网站: http://www.webxml.com.cn/ 从扩展名上看,是 .net构建的网站. 看看功能的实现效果: 需求:我们要远程调用手机号归属地的查询: 开发步骤: 1.建立工程:ws01_firstws 2.用jdk自带的工具读取wsdl地址 新建 结果输出: 根据远程的服务生成的这些内容称之为stub-桩,将生成的桩复制到项目的目录中去: 下一步:要编写客户端调用. public class FirstClient { public

Java调用WebService 接口 实例

这里给大家介绍一下,Java调用webservice的一个实例的过程. 本项目不能运行,因为接口地址不可用. 这里只是给大家介绍一个过程,同时留作自己的笔记.如果要学习,可以参照别人的实例.比较好. ①选择项目根目录的src ,右键,new --> webservice client 然后输入地址: http://172.18.100.52:456/hello?wsdl 必须要加wsdl结尾,这样才是一个webservice的接口. finlish.这时候刷新项目.可以看到项目下/src/com

WebService -- Java 实现之 CXF (初体验)

1. 认识WebService 简而言之,她就是:一种跨编程语言以及操作系统的远程调用技术. 大家都可以根据定义好的规范和接口进行开发,尽管各自的使用的开发语言和操作系统有所不同,但是由于都遵循统一的规范还有接口,因而可以做到透明和正常交互. 2. CXF 官方主页:http://cxf.apache.org/ 定义: Apache CXF is an open source services framework. CXF helps you build and develop services

.net实现webservice简单实例分享

原理:WebService是一个SOA(面向服务的编程)的架构,它是不依赖于语言,不依赖于平台,可以实现不同的语言间的相互调用,通过Internet进行基于Http协议的网络应用间的交互.作用:主要用于数据交换.提供服务接口优点:可跨平台.部署简单调用方便.无需额外客户端支持 一.创建一个WebService服务1.创建一个普通的Asp.Net Web应用程序,名称为WebServiceDemo 2.在刚创建的web程序里添加一个WebService服务文件,名称为TestService.asm