CXF: различия между версиями
Перейти к навигации
Перейти к поиску
FireWolf (обсуждение | вклад) |
FireWolf (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
[[:Категория:Работа]] | [[:Категория:Работа]] | ||
Создание сервиса с использованием CXF: | = Gradle = | ||
https://stackoverflow.com/questions/34955895/cxf-codegen-plugin-port-to-gradle | |||
<syntaxhighlight lang="groovy"> | |||
buildscript { | |||
ext { | |||
xjcVersion= '3.0.5' | |||
jaxbOutputDir = "$buildDir/generated/cxf" | |||
jaxb2BasicsVersion = '0.11.0' | |||
} | |||
} | |||
configurations { | |||
cxf | |||
} | |||
apply plugin: 'java' | |||
apply plugin: 'eclipse' | |||
sourceSets { | |||
main { | |||
java { | |||
srcDirs += "$jaxbOutputDir" | |||
} | |||
} | |||
} | |||
task wsdl2java(type: JavaExec) { | |||
ext { | |||
outputDir = file("$jaxbOutputDir") | |||
} | |||
systemProperties = ['javax.xml.accessExternalSchema': 'file' , 'file.encoding':'UTF8'] | |||
outputs.upToDateWhen { false } | |||
outputs.dir outputDir | |||
main = 'org.apache.cxf.tools.wsdlto.WSDLToJava' | |||
classpath = project.configurations.cxf | |||
args '-d', outputDir | |||
args '-fe', 'jaxws21' | |||
args '-client' | |||
args '-verbose' | |||
args '-validate' | |||
args '-mark-generated' | |||
// args '-xjc-X' | |||
args '-xjc-Xfluent-api' | |||
args '-xjc-Xts' | |||
args '-xjc-XhashCode' | |||
args '-xjc-Xequals' | |||
args '-b',"$projectDir/src/main/resources/jaxws-custom-bindings.xjb" | |||
args "$projectDir/src/main/resources/wsdl/myWsdl.wsdl" | |||
doLast { | |||
println "----- cxf jaxb2 files generated -----" | |||
} | |||
} | |||
dependencies { | |||
cxf "org.apache.cxf:cxf-tools-wsdlto-core:$cxfVersion" | |||
cxf "org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:$cxfVersion" | |||
cxf "org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:$cxfVersion" | |||
cxf "org.jvnet.jaxb2_commons:jaxb2-fluent-api:3.0" | |||
cxf "org.apache.cxf.xjcplugins:cxf-xjc-ts:$xjcVersion" | |||
cxf "org.jvnet.jaxb2_commons:jaxb2-basics:$jaxb2BasicsVersion" | |||
compile "org.apache.cxf.xjc-utils:cxf-xjc-runtime:$xjcVersion" | |||
compile "org.jvnet.jaxb2_commons:jaxb2-basics-runtime:$jaxb2BasicsVersion" | |||
compile 'commons-lang:commons-lang:2.6' | |||
} | |||
compileJava.dependsOn wsdl2java | |||
</syntaxhighlight> | |||
= Примеры = | |||
Создание сервиса на Spring с использованием CXF: | |||
[http://cxf.apache.org/docs/writing-a-service-with-spring.html CXF with Spring] | [http://cxf.apache.org/docs/writing-a-service-with-spring.html CXF with Spring] |
Версия 14:57, 23 января 2019
Gradle
https://stackoverflow.com/questions/34955895/cxf-codegen-plugin-port-to-gradle
buildscript {
ext {
xjcVersion= '3.0.5'
jaxbOutputDir = "$buildDir/generated/cxf"
jaxb2BasicsVersion = '0.11.0'
}
}
configurations {
cxf
}
apply plugin: 'java'
apply plugin: 'eclipse'
sourceSets {
main {
java {
srcDirs += "$jaxbOutputDir"
}
}
}
task wsdl2java(type: JavaExec) {
ext {
outputDir = file("$jaxbOutputDir")
}
systemProperties = ['javax.xml.accessExternalSchema': 'file' , 'file.encoding':'UTF8']
outputs.upToDateWhen { false }
outputs.dir outputDir
main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
classpath = project.configurations.cxf
args '-d', outputDir
args '-fe', 'jaxws21'
args '-client'
args '-verbose'
args '-validate'
args '-mark-generated'
// args '-xjc-X'
args '-xjc-Xfluent-api'
args '-xjc-Xts'
args '-xjc-XhashCode'
args '-xjc-Xequals'
args '-b',"$projectDir/src/main/resources/jaxws-custom-bindings.xjb"
args "$projectDir/src/main/resources/wsdl/myWsdl.wsdl"
doLast {
println "----- cxf jaxb2 files generated -----"
}
}
dependencies {
cxf "org.apache.cxf:cxf-tools-wsdlto-core:$cxfVersion"
cxf "org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:$cxfVersion"
cxf "org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:$cxfVersion"
cxf "org.jvnet.jaxb2_commons:jaxb2-fluent-api:3.0"
cxf "org.apache.cxf.xjcplugins:cxf-xjc-ts:$xjcVersion"
cxf "org.jvnet.jaxb2_commons:jaxb2-basics:$jaxb2BasicsVersion"
compile "org.apache.cxf.xjc-utils:cxf-xjc-runtime:$xjcVersion"
compile "org.jvnet.jaxb2_commons:jaxb2-basics-runtime:$jaxb2BasicsVersion"
compile 'commons-lang:commons-lang:2.6'
}
compileJava.dependsOn wsdl2java
Примеры
Создание сервиса на Spring с использованием CXF: