CXF生成客户端注意事项

    1. 在使用wsdl2java命令生成客户端文件时在Service的Java文件里面出现super构造错误,这是由于jax-ws2.2规约与java6冲突  故需要降低jax-ws规约版本。

     解决方法:wsdl2java -frontend jaxws21  http://localhost:8080/MyWebService?WSDL    生成客户端文件


   2.  在使用wsdl2java生成的客户端文件  ,如果我们修改了包的名称就会出现

      Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:347)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:336)
at javax.xml.ws.Service.getPort(Service.java:92)
at test3.MyWebService.getWebServiceTestImplPort(MyWebService.java:58)
at test3.Test.main(Test.java:12)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:341)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:446)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:548)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:478)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:345)
... 4 more
Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 4 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://test2/}sayGoodby". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at test3.jaxws_asm.SayGoodby
this problem is related to the following location:
at test3.SayGoodby
at public javax.xml.bind.JAXBElement test3.ObjectFactory.createSayGoodby(test3.SayGoodby)
at test3.ObjectFactory
Two classes have the same XML type name "{http://test2/}sayGoodbyResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at test3.jaxws_asm.SayGoodbyResponse
this problem is related to the following location:
at test3.SayGoodbyResponse
at public javax.xml.bind.JAXBElement test3.ObjectFactory.createSayGoodbyResponse(test3.SayGoodbyResponse)
at test3.ObjectFactory
Two classes have the same XML type name "{http://test2/}sayHiResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at test3.jaxws_asm.SayHiResponse
this problem is related to the following location:
at test3.SayHiResponse
at public test3.SayHiResponse test3.ObjectFactory.createSayHiResponse()
at test3.ObjectFactory
Two classes have the same XML type name "{http://test2/}sayHi". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at test3.jaxws_asm.SayHi
this problem is related to the following location:
at test3.SayHi
at public test3.SayHi test3.ObjectFactory.createSayHi()
at test3.ObjectFactory

   因此,在使用wsdl2java生成客户端文件时,不要修改文件夹的名称。



     

你可能感兴趣的:(WebService)