CXF "@ XmlType. name and @ XmlType. namespace assign different names to classes" error, cxf@xmltype.name
The code generated by the wsdl2java. bat of CXF is copied to the directory. When investigating the web service interface, an error is thrown:
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: 119)
At com. hemr. hl7.ws. client2.HL7MessageReveiverImplService. getHL7MessageReveiverImplPort (HL7MessageReveiverImplService. java: 72)
At com. hemr. hl7.ws. client2.ClientTest. main (ClientTest. java: 7)
Caused by: org. apache. cxf. service. factory. ServiceConstructionException
At org. apache. cxf. jaxb. JAXBDataBinding. initialize (JAXBDataBinding. java: 350)
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: 2 counts of IllegalAnnotationExceptions
The two classes have the same XML type name "{http://ws.hl7.hemr.com/?receivemessage ". Use @ XmlType. name and @ XmlType. namespace to assign different names to the class.
This problem is related to the following location:
At com. hemr. hl7.ws. client2.jaxws _ asm. ReceiveMessage
This problem is related to the following location:
At com. hemr. hl7.ws. client2.ReceiveMessage
At public javax. xml. bind. JAXBElement com. hemr. hl7.ws. client2.ObjectFactory. createReceiveMessage (com. hemr. hl7.ws. client2.ReceiveMessage)
At com. hemr. hl7.ws. client2.ObjectFactory
The two classes have the same XML type name "{http://ws.hl7.hemr.com/?receivemessageresponse ". Use @ XmlType. name and @ XmlType. namespace to assign different names to the class.
This problem is related to the following location:
At com. hemr. hl7.ws. client2.jaxws _ asm. ReceiveMessageResponse
This problem is related to the following location:
At com. hemr. hl7.ws. client2.w.emessageresponse
At public javax. xml. bind. JAXBElement com. hemr. hl7.ws. client2.ObjectFactory. createReceiveMessageResponse (com. hemr. hl7.ws. client2.ReceiveMessageResponse)
At com. hemr. hl7.ws. client2.ObjectFactory
At com. sun. xml. internal. bind. v2.runtime. IllegalAnnotationsException $ Builder. check (IllegalAnnotationsException. java: 91)
At com. sun. xml. internal. bind. v2.runtime. JAXBContextImpl. getTypeInfoSet (JAXBContextImpl. java: 445)
At com. sun. xml. internal. bind. v2.runtime. JAXBContextImpl. <init> (JAXBContextImpl. java: 277)
At com. sun. xml. internal. bind. v2.runtime. JAXBContextImpl. <init> (JAXBContextImpl. java: 124)
At com. sun. xml. internal. bind. v2.runtime. JAXBContextImpl $ JAXBContextBuilder. build (JAXBContextImpl. java: 1123)
At com. sun. xml. internal. bind. v2.ContextFactory. createContext (ContextFactory. java: 147)
At sun. reflect. NativeMethodAccessorImpl. invoke0 (Native Method)
At sun. reflect. NativeMethodAccessorImpl. invoke (NativeMethodAccessorImpl. java: 62)
At sun. reflect. DelegatingMethodAccessorImpl. invoke (DelegatingMethodAccessorImpl. java: 43)
At java. lang. reflect. Method. invoke (Method. java: 498)
At javax. xml. bind. ContextFinder. newInstance (ContextFinder. java: 247)
At javax. xml. bind. ContextFinder. newInstance (ContextFinder. java: 234)
At javax. xml. bind. ContextFinder. find (ContextFinder. java: 462)
At javax. xml. bind. JAXBContext. newInstance (JAXBContext. java: 641)
At org. apache. cxf. common. jaxb. JAXBContextCache. createContext (JAXBContextCache. java: 356)
At org. apache. cxf. common. jaxb. JAXBContextCache. getCachedContextAndSchemas (JAXBContextCache. java: 244)
At org. apache. cxf. jaxb. JAXBDataBinding. createJAXBContextAndSchemas (JAXBDataBinding. java: 493)
At org. apache. cxf. jaxb. JAXBDataBinding. initialize (JAXBDataBinding. java: 348)
... 15 more
The reason is:The package path specified during code generation is inconsistent with the package path copied in the past.For example:
G: \ cxf \ apache-cxf-3.1.6 \ bin> wsdl2java-p
Com. hemr. hl7.ws. client-D G:/cxf-verbose http: // localhost: 8080/webservice/hL7MessageReveiver? Wsdl
For example, the Code produced in this way is copied to the package path:Com. hemr. hl7.ws. client. testNext, the above error will be thrown,
The solution is to copy the production codeCom. hemr. hl7.ws. client. testTo execute the command, you need to re-develop the package path and re-generate the Code:
G: \ cxf \ apache-cxf-3.1.6 \ bin> wsdl2java-p com. hemr. hl7.ws. client. test-d G:/cxf-verbose http: // localhost: 8080/webservice/hL7MessageReveiver? Wsdl
In this way, no errors will be thrown.