报错一:属性 "Any" 已定义。请使用 <jaxb:property> 解决此冲突。
java.lang.RuntimeException: Error compiling schema from WSDL at {http://103.227.81.118/ttknoaws/sms.asmx?wsdl}:
属性 "Any" 已定义。请使用 <jaxb:property> 解决此冲突。
at line 42 column 19 of schema http://103.227.81.118/ttknoaws/sms.asmx?wsdl
以下位置与上一错误有关
at line 43 column 19 of schema http://103.227.81.118/ttknoaws/sms.asmx?wsdl
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory$InnerErrorListener.throwException(DynamicClientFactory.java:751)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:341)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:243)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:236)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:191)
at com.cnki.TestMain.SendMessageToMobilePhone(TestMain.java:119)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: com.sun.istack.internal.SAXParseException2publicId: http://103.227.81.118/ttknoaws/sms.asmx?wsdl; systemId: http://103.227.81.118/ttknoaws/sms.asmx?wsdl; lineNumber: 42; columnNumber: 19; 属性 "Any" 已定义。请使用 <jaxb:property> 解决此冲突。
at com.sun.tools.internal.xjc.ErrorReceiver.error(ErrorReceiver.java:71)
at com.sun.tools.internal.xjc.reader.ModelChecker.checkPropertyCollision(ModelChecker.java:97)
at com.sun.tools.internal.xjc.reader.ModelChecker.check(ModelChecker.java:83)
at com.sun.tools.internal.xjc.reader.ModelChecker.check(ModelChecker.java:56)
at com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder._build(BGMBuilder.java:168)
at com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:104)
at com.sun.tools.internal.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:410)
at com.sun.tools.internal.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:262)
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 org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:89)
at com.sun.proxy.$Proxy18.bind(Unknown Source)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:339)
... 26 more
解决办法:
https://www.cnblogs.com/cheng2015/p/12971436.html
1.创建xsd.xjb文件
<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
version="2.0">
<globalBindings>
<xjc:simple />
</globalBindings>
<bindings scd="~xsd:complexType">
<class name="ComplexTypeType"/>
</bindings>
<bindings scd="~xsd:simpleType">
<class name="SimpleTypeType"/>
</bindings>
<bindings scd="~xsd:group">
<class name="GroupType"/>
</bindings>
<bindings scd="~xsd:attributeGroup">
<class name="AttributeGroupType"/>
</bindings>
<bindings scd="~xsd:element">
<class name="ElementType"/>
</bindings>
<bindings scd="~xsd:attribute">
<class name="attributeType"/>
</bindings>
</bindings>
2.使用命令:
wsimport -encoding utf-8 -s D:\Temp\TempCode -p com.wcf.proxy -b http://www.w3.org/2001/XMLSchema.xsd -b D:\Temp\xsd.xjb E:\ljw\sms.xml
修改下面你自己的参数路径:
D:\Temp\TempCode 准备生成代码的路径
D:\Temp\xsd.xjb 刚创建的文件
E:\ljw\sms.xml 自己的wsdl文件
运行命令后出现
报错二:[ERROR] 外部 DTD: 无法读取外部 DTD 'XMLSchema.dtd', 因为 accessExternalDTD 属性设置的限制导致不允许 'http' 访问。
解决办法:
https://blog.csdn.net/u013077984/article/details/103760465
在你的%JAVA_HOEE%\jre\lib\ 目录下,新建一个文件jaxp.properties,内容:
javax.xml.accessExternalSchema=all
javax.xml.accessExternalDTD=all
再次运行命令后成功生成代码: