找不到包装器类package.jaxws.methodName。 您是否运行过APT来生成它们?

问题

在JAX-WS开发中,部署以下服务端点时,

文件:HelloWorld.java

package com.mkyong.ws;
//Service Endpoint Interface
@WebService
public interface HelloWorld{
 
	@WebMethod String getHelloWorldAsString();
}

文件:HelloWorldImpl.java

//Service Implementation
package com.mkyong.ws;
@WebService(endpointInterface = "com.mkyong.ws.HelloWorld")
public class HelloWorldImpl implements HelloWorld{
 
	@Override
	public String getHelloWorldAsString() {
		//...
	}
 
}

它立即命中以下错误消息?

Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: 
	runtime modeler error: 

        Wrapper class com.mkyong.ws.jaxws.GetHelloWorldAsString is not found. 
        Have you run APT to generate them?

	at com.sun.xml.internal.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:256)
	//...

服务端点接口未使用任何@SOAPBinding注释,因此,它将使用默认的文档样式进行发布。 为了便于阅读,您可以按以下方式重写它:

//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL)
public interface HelloWorld{
 
	@WebMethod String getHelloWorldAsString();
}

在文档样式中,您需要使用“ wsgen ”工具为服务发布生成所有必需的JAX-WS可移植工件(映射类,wsdl或xsd模式)。

wsgen命令

需要wsgen命令来读取服务端点实现类:

wsgen -keep -cp . com.mkyong.ws.HelloWorldImpl

它在package.jaxws文件夹下为单个getHelloWorldAsString()方法生成两个类。

  1. GetHelloWorldAsString.java
  2. GetHelloWorldAsStringResponse.java

将这些类复制到正确的文件夹,在本例中为“ com.mkyong.ws.jaxws ”。 尝试再次发布。

参考

  1. wsgen工具文档

翻译自: https://mkyong.com/webservices/jax-ws/wrapper-class-package-jaxws-methodname-is-not-found-have-you-run-apt-to-generate-them/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值