Cxf重用已经生成了jaxb类

时间:2014-05-07 07:05:55

标签: java jaxb cxf

我有一个wsdl文件已经使用了我们项目中的现有xsd(因此生成的Jaxb类也在这个项目中)。

我已经查找了如何重用jaxb类并找到以下内容:http://blog.bdoughan.com/2011/12/reusing-generated-jaxb-classes.html

所以我做了以下事情:

  1. xjc -d out -episode My.xsd -p
  2. wsdl2java -p -client-xjc -b -fe jaxws21 My.wsdl
  3. 现在我想用JaxWsProxyFactoryBean测试这个服务:

        JaxWsProxyFactoryBean factory = new org.apache.cxf.jaxws.JaxWsProxyFactoryBean();
        factory.setServiceClass(servicClass);
        factory.setAddress(url);
        factory.setUsername(user);
        factory.setPassword(password);
        Object messageHandler = factory.create();
        Client client = ClientProxy.getClient(messageHandler);    
    

    创建客户端时,我得到了这个我不明白的例外:

       java.lang.IllegalArgumentException: can't parse argument number ''{0}''
    at java.text.MessageFormat.makeFormat(MessageFormat.java:1339)[:1.6.0_25]
    at java.text.MessageFormat.applyPattern(MessageFormat.java:458)[:1.6.0_25]
    at java.text.MessageFormat.<init>(MessageFormat.java:350)[:1.6.0_25]
    at java.text.MessageFormat.format(MessageFormat.java:811)[:1.6.0_25]
    at com.sun.xml.bind.v2.model.impl.Messages.format(Messages.java:133)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.model.impl.TypeInfoSetImpl.add(TypeInfoSetImpl.java:306)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:121)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.model.impl.ModelBuilder.addRegistry(ModelBuilder.java:362)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:332)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:460)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1163)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)[jaxb-impl-2.2.5-2.jar:2.2.5-2]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_25]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_25]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_25]
    at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_25]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)[:1.6.0_25]
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)[:1.6.0_25]
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)[:1.6.0_25]
    at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:267)[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:265)[cxf-api-2.7.4.jar:2.7.4]
    at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_25]
    at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:265)[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:172)[cxf-api-2.7.4.jar:2.7.4]
    at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:464)[cxf-rt-databinding-jaxb-2.7.4.jar:2.7.4]
    at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:330)[cxf-rt-databinding-jaxb-2.7.4.jar:2.7.4]
    at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)[cxf-rt-core-2.7.4.jar:2.7.4]
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:478)[cxf-rt-core-2.7.4.jar:2.7.4]
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:690)[cxf-rt-frontend-jaxws-2.7.4.jar:2.7.4]
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:540)[cxf-rt-core-2.7.4.jar:2.7.4]
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:252)[cxf-rt-core-2.7.4.jar:2.7.4]
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:205)[cxf-rt-frontend-jaxws-2.7.4.jar:2.7.4]
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)[cxf-rt-frontend-simple-2.7.4.jar:2.7.4]
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)[cxf-rt-frontend-simple-2.7.4.jar:2.7.4]
    at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:156)[cxf-rt-frontend-simple-2.7.4.jar:2.7.4]
    at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:156)[cxf-rt-frontend-jaxws-2.7.4.jar:2.7.4]
    

    我注意到JaxbContext是用新存根的所有类和现有的存根创建的,我不知道这是否真的正确。 我也尝试指定一个不同的JaxbDataBinding,我不使用所有类,但后来我得到了不同的错误。

    这里有什么问题吗?

0 个答案:

没有答案