具有ws-addressing功能的jaxws客户端上的javax.xml.ws.WebServiceException

时间:2012-05-11 17:10:13

标签: tomcat client jax-ws dispatch ws-addressing

我在使用jaxws客户端调用Web服务时遇到了问题,在Tomcat中运行

代码如下:

    javax.xml.namespace.QName portQname = new javax.xml.namespace.QName("urn:hl7-org:v3","PRPA_AR201302UV02_Service");
    javax.xml.ws.Service service = javax.xml.ws.Service.create(new javax.xml.namespace.QName("urn:hl7-org:v3","PRPA_AR201302UV02_Service"));
    service.addPort(portQname,javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING,wsaddress);


    Dispatch<Object> dispatch =service.createDispatch(portQname,jaxbContext,javax.xml.ws.Service.Mode.PAYLOAD,new javax.xml.ws.soap.AddressingFeature());


    dispatch.getRequestContext().put(javax.xml.ws.BindingProvider.SOAPACTION_USE_PROPERTY,true);
    dispatch.getRequestContext().put(javax.xml.ws.BindingProvider.SOAPACTION_URI_PROPERTY,"urn:hl7-org:v3:PRPA_IN201301UV02");

当我从Eclipse运行工具运行它时,代码与ws-addressing功能一起正常工作,而不提供axis2.xml文件

当我在Tomcat实例中运行它时,它会给我以下异常

javax.xml.ws.WebServiceException:获取客户端配置错误上下文:系统正在尝试使用不可用的模块:寻址     at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:173)     at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)     at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:118)     在org.apache.axis2.jaxws.ClientConfigurationFactory.getClientConfigurationContext(ClientConfigurationFactory.java:119)     at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:92)     at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:79)     at org.apache.axis2.jaxws.description.DescriptionFactory.createServiceDescription(DescriptionFactory.java:78)     在org.apache.axis2.jaxws.spi.ServiceDelegate。(ServiceDelegate.java:218)     at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:83)     at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:79)     在javax.xml.ws.Service。(Service.java:92)     在javax.xml.ws.Service.create(Service.java:756)     在wgs.v3.client.impl.V3ClientNoWsdl.callMethod(V3ClientNoWsdl.java:128)     在wgs.v3.client.impl.V3ClientNoWsdl.invoke(V3ClientNoWsdl.java:89)     在wgs.tx.dispatcher.Sender.elab(Sender.java:204)     在wgs.tx.dispatcher.Sender.elab(Sender.java:158)     在wgs.tx.system.MessageDispatcherSender.processRequest(MessageDispatcherSender.java:159)     在wgs.tx.system.MessageDispatcherSender.run(MessageDispatcherSender.java:99)     在java.lang.Thread.run(Thread.java:595)

有没有人发出同样的问题?我无法摆脱这个

1 个答案:

答案 0 :(得分:0)

问题解决了。

Eclipse运行工具不是基于jax-ws标准的axis2实现,而是基于独立分发。

要在具有axis2的Tomcat上正确运行相同的类,我必须添加以下行 在创建服务实例之前

System.setProperty(org.apache.axis2.Constants.AXIS2_REPO, getServletContext().getRealPath(FILE_SEPARATOR) + FILE_SEPARATOR + "WEB-INF");

因此,axis2实现可以正确访问模块和配置目录。