2011-05-25 53 views
1

有人可以幫助我解決WSDL文件的問題。java wsimport wsdl問題(jax-ws)

wsimport -d test uri_to_my_wsdl 
parsing WSDL... 


[WARNING] src-resolve: Cannot resolve the name 'ns1:HeaderType' to a(n) 'type definition' component. 
    line 27 of uri_to_my_wsdl=anotherWS.wsdl#types?schema2 

[ERROR] A class/interface with the same name "some_pkg.ObjectFactory" is already in use. Use a class customization to resolve this conflict. 


[ERROR] (Relevant to above error) another "ObjectFactory" is generated from here. 
    line 72 of uri_to_my_wsdl=anotherWS.wsdl 

Exception in thread "main" java.lang.NullPointerException 
    at com.sun.tools.internal.xjc.util.Util.equals(Util.java:56) 
    at com.sun.tools.internal.xjc.util.CodeModelClassFactory.createClass(CodeModelClassFactory.java:119) 
    at com.sun.tools.internal.xjc.util.CodeModelClassFactory.createClass(CodeModelClassFactory.java:66) 
    at com.sun.tools.internal.xjc.generator.bean.ImplStructureStrategy$1.createClasses(ImplStructureStrategy.java:67) 
    at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generateClassDef(BeanGenerator.java:392) 
    at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.getClazz(BeanGenerator.java:424) 
    at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:191) 
    at com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:164) 
    at com.sun.tools.internal.xjc.model.Model.generateCode(Model.java:275) 
    at com.sun.tools.internal.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:240) 
    at com.sun.tools.internal.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:74) 
    at com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:123) 
    at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2234) 
    at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:176) 
    at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:122) 
    at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:172) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:111) 
    at com.sun.tools.internal.ws.WsImport.main(WsImport.java:41) 

因爲WS不公開,所以我不能在這裏發佈真正的WSDL路徑。 我可以通過電子郵件或其他私人信息發送給您。

回答

3

您可以放心地忽略警告。我正在爲我的WSDL做同樣的事情,因爲生成的存根包含我需要的東西。

關於錯誤,它清楚地表明WSDL中存在重複的ObjectFactory。 請使用與下圖類似的方案自定義方案。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<bindings 
xmlns="http://java.sun.com/xml/ns/jaxb" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" 
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
version="2.0">  
    <bindings schemaLocation="my.xsd" node="/xsd:schema"> 
    <bindings node="xsd:complexType[@name='MyObject']"> 
      <jaxb:property name="MyObjectNewName"/> 
    </bindings> 
    </bindings> 
</bindings> 
+0

我不能忽視,因爲它是一個錯誤不是警告。 – zmeda 2011-07-05 06:52:47

+0

我在第一篇文章中提到了「[警告] src-resolve:」。對於我提到的錯誤,您已經定義了多次「ObjectFactory」。 – kiri 2011-07-06 08:52:38

+0

好的。同意。但我能做些什麼關於「ObjectFactory」?我知道有某種jaxb映射文件,但我還沒有發現如何編寫它。一些例子? – zmeda 2011-07-06 12:50:14