Open silverwind85 opened 1 year ago
I am using gradle plugin wsdl2java to generated java classes by file wsdl. I need change name packages
"<xs:extension xmlns:java="java:com.test.example.mw" base="java:MiddlewareException">"
for
"com.test.example.mw"
so I am using for it file binding.xml
gradle.build
plugins { id "java" id "io.spring.dependency-management" version "1.1.0" id "com.yupzip.wsdl2java" version "3.0.0" } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '17' repositories { mavenCentral() } compileJava { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 options.compilerArgs << '-parameters' } dependencies { implementation 'org.springframework.ws:spring-ws-support:4.0.0' // your project dependencies implementation 'com.sun.xml.bind:jaxb-impl:4.0.1' implementation 'com.sun.xml.messaging.saaj:saaj-impl:3.0.0' implementation 'com.sun.xml.ws:jaxws-ri:4.0.0' implementation 'io.swagger.core.v3:swagger-jaxrs2-jakarta:2.2.7' implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0' implementation 'jakarta.xml.soap:jakarta.xml.soap-api:3.0.0' implementation 'jakarta.xml.ws:jakarta.xml.ws-api:4.0.0' implementation 'org.jvnet.jaxb2_commons:jaxb2-namespace-prefix:2.0' implementation 'codes.rafael.jaxb2_commons:jaxb2-basics:3.0.0' implementation 'codes.rafael.jaxb2_commons:jaxb2-basics-runtime:3.0.0' implementation 'org.apache.cxf.xjc-utils:cxf-xjc-runtime:4.0.0' implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.1' } sourceSets.main.java.srcDirs "src/generated-sources/java" configurations { wsdl2java } dependencies { wsdl2java ( 'com.sun.xml.bind:jaxb-impl:4.0.1', 'org.apache.cxf.xjc-utils:cxf-xjc-runtime:4.0.0', 'jakarta.xml.ws:jakarta.xml.ws-api:4.0.0', 'com.sun.xml.ws:rt:4.0.0', 'org.jvnet.jaxb2_commons:jaxb2-namespace-prefix:2.0', 'codes.rafael.jaxb2_commons:jaxb2-basics-runtime:3.0.0', 'codes.rafael.jaxb2_commons:jaxb2-basics:3.0.0' ) } wsdl2java { wsdlDir = file("$projectDir/src/main/resources/test") stabilizeAndMergeObjectFactory = true includeJava8XmlDependencies = false cxfVersion = "4.0.0" cxfPluginVersion = "4.0.0" wsdlsToGenerate = [ ['-xjc', '-xjc-Xnamespace-prefix', '-b',"$wsdlDir/binding.xml", '-autoNameResolution', '-verbose', "$wsdlDir/example.wsdl", ], ] generatedWsdlDir = file("src/generated/wsdl2java") }
example.wsdl
<s0:definitions xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s2="java:com.test.example.mw" xmlns:s1="http://com/test/example/security/service" xmlns:s3="http://schemas.xmlsoap.org/wsdl/soap/" name="CommonSecurityConfidentialServiceDefinitions" targetNamespace="http://com/test/example/security/service"> <s0:types> <xs:schema xmlns:s1="java:com.test.example.mw" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="java:com.test.example.mw" > <xs:complexType name="MWException"> <xs:annotation> <xs:documentation/> </xs:annotation> <xs:complexContent> <xs:extension xmlns:java="java:com.test.example.mw" base="java:MiddlewareExceptionEx"> <xs:sequence> <xs:element minOccurs="0" name="ErrorCode" type="xs:string"/> <xs:element minOccurs="0" name="ErrorCategory" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="MiddlewareExceptionEx"> <xs:annotation> <xs:documentation/> </xs:annotation> <xs:complexContent> <xs:extension xmlns:java="java:com.test.example.mw" base="java:MiddlewareException"> <xs:sequence> <xs:element minOccurs="0" name="Subsystem" type="xs:string"/> <xs:element minOccurs="0" name="EdifactRequest" type="xs:string"/> <xs:element minOccurs="0" name="EdifactResponse" type="xs:string"/> <xs:element minOccurs="0" name="AdditionalInfo" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="MiddlewareException"> <xs:annotation> <xs:documentation/> </xs:annotation> <xs:sequence> <xs:element minOccurs="0" name="OriginalExceptionName" type="xs:string"/> <xs:element minOccurs="0" name="LocalizedMessage" type="xs:string"/> <xs:element minOccurs="0" name="ErrorType" type="xs:string"/> <xs:element minOccurs="0" name="ErrorDescription" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="MWExceptionControl"> <xs:complexContent> <xs:extension xmlns:java="java:com.test.example.mw" base="java:MWException"> <xs:sequence> <xs:element minOccurs="1" name="UciAction" type="xs:int"/> <xs:element minOccurs="1" name="UcmAction" type="xs:int"/> <xs:element minOccurs="1" name="SyntaxError" type="xs:int"/> <xs:element minOccurs="0" name="UciInterChangeCtrlRef" type="xs:string"/> <xs:element minOccurs="0" name="UciSenderIdentification" type="xs:string"/> <xs:element minOccurs="0" name="UciRecipientIdentification" type="xs:string"/> <xs:element minOccurs="1" name="Origin" type="xs:int"/> <xs:element minOccurs="1" name="OpenFailed" type="xs:boolean"/> <xs:element minOccurs="1" name="Inactive" type="xs:boolean"/> <xs:element minOccurs="1" name="Duplicate" type="xs:boolean"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:element xmlns:java="java:com.test.example.mw" name="MWExceptionControl" type="java:MWExceptionControl"/> <xs:element xmlns:java="java:com.test.example.mw" name="MWException" type="java:MWException"/> </xs:schema> </s0:types> </s0:definitions>
binding.xml
<?xml version="1.0"?> <jaxws:bindings wsdlLocation="CSC.wsdl" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- https://stackoverflow.com/a/43560882/49489 --> <jaxws:enableAsyncMapping>true</jaxws:enableAsyncMapping> <jaxws:bindings node="xs:schema[@targetNamespace='java:com.test.example.mw']"> <jaxb:schemaBindings> <jaxb:package name="com.test.example.mw" /> </jaxb:schemaBindings> </jaxws:bindings> </jaxws:bindings>
Maybe someone know what is wrong in my configuration enter image description here
It should generated packages like that enter image description here
I am using gradle plugin wsdl2java to generated java classes by file wsdl. I need change name packages
for
so I am using for it file binding.xml
gradle.build
example.wsdl
binding.xml
Maybe someone know what is wrong in my configuration enter image description here
It should generated packages like that enter image description here