Ich habe ein Problem Abbilden eines Web-Service zu Java POJO ist, weil es zwei Elemente enthält:Wie Karte Wsdl mit Maven-jaxb2-Plugin mit dem Namen Kollision
label1
label_1
Wenn das Plugin es in Java-POJOs umwandelt, werden die Unterstriche in den Namen entfernt, was zu doppelten Feldern in der erzeugten Klasse führt.
[ERROR] Fehler beim Erzeugen code.Location [ file:/C: /PrivateWS/test-project/sources/target/wsdl/test.wsdl {12,94}]. com.sun.istack.SAXParseException2; systemId: Datei:/C: /PrivateWS/test-project/sources/target/wsdl/test.wsdl; Zeilennummer: 12; Spaltennummer: 94; Zwei Deklarationen verursachen eine Kollision in der ObjectFactory-Klasse.
Ich habe versucht, eine externe Bindungsdatei zu verwenden, um eines der Elemente in einen anderen Namen umzubenennen, aber dies schlägt fehl. Ich habe mir viele verschiedene Foren angesehen, aber ich kann keine Lösung finden, die zu funktionieren scheint. Soweit ich sehen kann, ist die Eigenschaft nicht bekannt und dies verursacht einen Fehler.
[ERROR] Fehler beim Parsen-Schema (s) .Standort [ file:/C: /PrivateWS/test-project/sources/target/classes/bindings.xjb {9,46}]. com.sun.istack.SAXParseException2; systemId: Datei:/C: /PrivateWS/test-project/sources/target/classes/bindings.xjb; Zeilennummer: 9; Spaltennummer: 46; Compiler konnte diese Eigenschaftsanpassung nicht berücksichtigen. Es ist an einem falschen Ort angebracht, oder seine inkonsistent mit anderen Bindungen.
Was mache ich falsch, um die Umbenennung des Feldes zu machen?
Das Ändern der WSDL ist keine Option, da es eine Drittanbieter-WSDL ist.
pom.xml
<?xml version="1.0"?><project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testproject</groupId>
<artifactId>testproject</artifactId>
<version>0.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-binding-file</id>
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>bindings.xjb</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-wsdl-file</id>
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/wsdl</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources/wsdl</directory>
<includes>
<include>test.wsdl</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<id>TestProject</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>com.testproject</generatePackage>
<schemaIncludes>
<schemaInclude>wsdl/test.wsdl</schemaInclude>
</schemaIncludes>
</configuration>
</execution>
</executions>
<configuration>
<bindingDirectory>${project.build.outputDirectory}</bindingDirectory>
<bindingIncludes>
<include>bindings.xjb</include>
</bindingIncludes>
<forceRegenerate>true</forceRegenerate>
<schemaDirectory>${project.build.directory}</schemaDirectory>
</configuration>
</plugin>
</plugins>
</build>
test.wsdl
<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl" elementFormDefault="unqualified" targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl" version="1.0">
<xsd:element name="requestType" type="tns:requestType"/>
<xsd:complexType final="extension restriction" name="requestType">
<xsd:sequence>
<xsd:element form="qualified" minOccurs="0" name="label1" type="xsd:string"/>
<xsd:element form="qualified" minOccurs="0" name="label_1" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<message name="SayHelloRequest">
<part element="tns:requestType" name="parameters"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</message>
<portType name="Hello_PortType">
<operation name="sayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>
<binding name="Hello_Binding" type="tns:Hello_PortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sayHello">
<soap:operation soapAction="sayHello"/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</output>
</operation>
</binding>
<service name="Hello_Service">
<documentation>WSDL File for HelloService</documentation>
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address
location="http://www.examples.com/SayHello/"/>
</port>
</service>
binding.xjb
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
version="2.1">
<jxb:bindings schemaLocation="*">
<jxb:bindings node="//xs:complexType[@name='requestType']" required="false">
<jxb:bindings node=".//xs:element[@name='label_1']" required="false">
<jxb:property name="label2"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>