RuntimeModelerException:类上没有WebService注释:clientpackage.IClientPortClass

时间:2015-07-07 13:16:54

标签: java web-services jax-ws webservice-client weblogic-10.x

我使用JDK 1.6.0_45创建了一个JAX-WS客户端。我在战争项目中使用生产的罐子,它也包装在耳朵里。 在Tomcat中,我可以使用webservice客户端调用并获得响应没有问题。但是在 Weblogic 10.3.6服务器中,我得到了这个例外:

ClientPortClass service = new ClientPortClass();
IClientPortClass port = service.getPortXML(); ---> this line produces below error:

com.sun.xml.ws.model.RuntimeModelerException: A WebService annotation is not present on class: clientpackage.IClientPortClass
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:237)
    at com.sun.xml.ws.client.WSServiceDelegate.buildRuntimeModel(WSServiceDelegate.java:762)
    at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.buildRuntimeModel(WLSProvider.java:1026)
    at com.sun.xml.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:746)
    at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:737)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:361)
    at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.internalGetPort(WLSProvider.java:978)
    at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate$PortClientInstanceFactory.createClientInstance(WLSProvider.java:1083)
    at weblogic.wsee.jaxws.spi.ClientInstancePool.takeSimpleClientInstance(ClientInstancePool.java:376)
    at weblogic.wsee.jaxws.spi.ClientInstancePool.take(ClientInstancePool.java:232)
    at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.getPort(WLSProvider.java:896)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:344)
    at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.getPort(WLSProvider.java:836)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:326)
    at javax.xml.ws.Service.getPort(Service.java:92)
    at clientpackage.ClientPortClass.getPortXML(ClientPortClass.java:58)
    ...

我检查了jax ws生成的ClientPortClass类,它有这样的结构:

/**
 * Web Service
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.2.8
 * Generated source version: 2.1
 */
@WebServiceClient(name = "ClientPortClass", targetNamespace = "transactionData:ClientPortClass", wsdlLocation = "wsdlURL...")
public class ClientPortClass extends Service{
...
 @WebEndpoint(name = "portXML")
    public IClientPortClass getPortXML(WebServiceFeature... features) {
    ...}
}

IClientPortClass:

/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.2.8
 * Generated source version: 2.1
 */
@WebService(name = "IClientPortClass", targetNamespace = "transactionData:ClientPortClass")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
    ObjectFactory.class
})
public interface IClientPortClass {

    @WebMethod(action = "trigger")
    @WebResult(name = "message", targetNamespace = "transactionData:data", partName = "result")
    public Message trigger(
        @WebParam(name = "requestMessage", targetNamespace = "transactionData:data", partName = "input")
        RequestMessage input);
}

我观察到weblogic使用了glassfish.jaxws.rt_1.3.0.0_2-1-5.jar。 com.sun.xml.ws.model.RuntimeModelerException来自那个jar。我不知道,但也许它有关系。

您对RuntimeModelerException有什么建议:类上没有WebService注释:clientpackage.IClientPortClass?

2 个答案:

答案 0 :(得分:0)

例如,您需要将@WebService批注添加到实现类 @WebService(endpointInterface =“com ...”,targetNamespace =“http://abc ...”)

答案 1 :(得分:0)

我为这个错误苦苦挣扎了好几天。这是在weblogic 10.3.6下适用于我的解决方案。 不要使用apache cxf或其他工具。 使用wsimport创建客户端,该客户端从1.6开始由jdk提供。

wsimport -p com.sample -keep -verbose http://yourservice?wsdl

使用位于用于编译项目的jdk下的wsimport工具。 检查您的weblogic-application.xml,如果存在javax.jws。*,则将其注释掉。

<wls:prefer-application-packages>
    <wls:package-name>antlr.*</wls:package-name>
    <wls:package-name>javax.persistence.*</wls:package-name>
    <!-- 
    <wls:package-name>javax.jws.*</wls:package-name>
     -->
</wls:prefer-application-packages>