标签:
最近在研究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文件:如成功返回如下:
<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