码迷,mamicode.com
首页 > 移动开发 > 详细

Wrapper class webservice.jaxws.SayHi is not found. Have you run APT to generate them?

时间:2015-03-18 17:29:55      阅读:1623      评论:0      收藏:0      [点我收藏+]

标签:

  最近在研究webservice,利用jdk来实现简单的webservice发布,但是运行时却发生了这样的异常,如下:

Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class webservice.jaxws.SayHi is not found. Have you run APT to generate them?
 at com.sun.xml.internal.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:256)
 at com.sun.xml.internal.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:567)
 at com.sun.xml.internal.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:514)
 at com.sun.xml.internal.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:341)
 at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:227)
 at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:308)
 at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:174)
 at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:420)
 at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:439)
 at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:208)
 at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:138)
 at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:90)
 at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
 at webservice.Test.main(Test.java:8)

最后发现原来是jdk的版本过低,我使用的是jdk1.6.10,而最低要求为1.6.22以上即可,故特此记录下来,谨防再次出错

 

例外,此种发布方法如下:

第一步:定义接口HelloWorld

package webservice;

import javax.jws.WebService;

@WebService public interface HelloWorld {  

  String sayHi(String str);

}

第二步:实现类HelloWorldImpl

package webservice;

import javax.jws.WebService;

import javax.xml.ws.Endpoint;

@WebService(endpointInterface = "webservice.HelloWorld") 

public class HelloWorldImpl implements HelloWorld {

   public String sayHi(String str) {   

    System.out.println("我是webservice");     

    return "Hello ," + str;   

  }  

   public static void main(String[] args) {

       Endpoint.publish("http://localhost:8088/hello", new HelloWorldImpl());

   }

}

第三步:运行HelloWorldImpl.java main方法

第四步:在浏览器地址栏输入:http://localhost:8088/hello?wsdl

第五步:查看响应xml文件:如成功返回如下:

 

 
<?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.2.4-b01. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI‘s version is JAX-WS RI 2.2.4-b01. -->

<definitions name="HelloWorldImplService" targetNamespace="http://webservice/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://webservice/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><types><xsd:schema><xsd:import schemaLocation="http://localhost:8088/hello?xsd=1" namespace="http://webservice/"/></xsd:schema></types><message name="sayHi"><part name="parameters" element="tns:sayHi"/></message><message name="sayHiResponse"><part name="parameters" element="tns:sayHiResponse"/></message><portType name="HelloWorld"><operation name="sayHi">

<input message="tns:sayHi" wsam:Action="http://webservice/HelloWorld/sayHiRequest"/><output message="tns:sayHiResponse" wsam:Action="http://webservice/HelloWorld/sayHiResponse"/>

<input message="tns:sayHi" wsam:Action="http://webservice/HelloWorld/sayHiRequest"/><output message="tns:sayHiResponse" wsam:Action="http://webservice/HelloWorld/sayHiResponse"/></operation></portType><binding name="HelloWorldImplPortBinding" type="tns:HelloWorld"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="sayHi"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation></binding><service name="HelloWorldImplService"><port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding"><soap:address location="http://localhost:8088/hello"/></port></service></definitions> 由于输入框被屏蔽,下面为截图

技术分享

Wrapper class webservice.jaxws.SayHi is not found. Have you run APT to generate them?

标签:

原文地址:http://www.cnblogs.com/iliuyuet/p/4347629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!