我们正在使用来自第三方 WSDL 的 wsdl2java 生成 java(意味着我们无法修改他)。WSDL 包含:
<wsdl:import namespace="http://somenamespace" location="xsdschema.xsd" />
Run Code Online (Sandbox Code Playgroud)
在此 xsdschema 中,元素带有 nillable="true",生成器报告 ObjectFactory 中的冲突(重复)。我们尝试使用绑定generateElementProperty =“false”。但是在为 WSDL 定义的绑定定义中,生成器会忽略它,并且在为 xsd WSDL2Java 定义绑定时,XSD 不是编译的一部分。怎么解决呢?
WSDL 的 XJB(generateElementProperty 被忽略 - ObjectFactory 中仍然出现重复错误):
<jaxws:bindings version="2.0"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
wsdlLocation="wsdl3rd.wsdl">
<jaxb:bindings>
<jaxb:globalBindings generateElementProperty="false"/>
</jaxb:bindings>
</jaxws:bindings>
Run Code Online (Sandbox Code Playgroud)
XJB for XSD(错误:XSD 不是编译的一部分):
<jxb:bindings version="2.1" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="xsdschema.xsd">
<jxb:bindings>
<jxb:globalBindings generateElementProperty="false"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
Run Code Online (Sandbox Code Playgroud)
行家:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<wsdlRoot>src/main/resources/wsdl</wsdlRoot>
<defaultOptions>
<bindingFiles>bindingFile>bindingFile.xjb</bindingFile>
</bindingFiles>
</defaultOptions>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud) 是否可以通过 JNDI 访问 Wildfly 属性(在 standalone.xml 中定义)?喜欢:
<system-properties>
<property name="MY_PROPERTY" value="some value"/>
...
</system-properties>
Run Code Online (Sandbox Code Playgroud)
并在java中阅读它:
@Resource(lookup = "java:comp/env/MY_PROPERTY")
private String property;
Run Code Online (Sandbox Code Playgroud)