From 7568d32e9422874b2a02a89cdf907e12dd457ecd Mon Sep 17 00:00:00 2001 From: Sergiy Sevastyanov Date: Thu, 28 Mar 2019 17:44:56 +1300 Subject: [PATCH] Fixed wsdl first initialization --- README.md | 9 +++------ .../grails/cxf/utils/EndpointRegistrationUtil.groovy | 12 ++++++------ .../org/grails/cxf/utils/GrailsCxfEndpoint.groovy | 1 + 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 929835f..5cbea13 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,7 @@ When using the annotation, the property values will only be used if the correspo EndpointType expose() default EndpointType.JAX_WS boolean soap12() default false String wsdl() default '' + String namespace() default '' //Interceptors String[] inInterceptors() default [] String[] outInterceptors() default [] @@ -283,14 +284,10 @@ class CarService { **WSDL** -To expose as a wsdl first jax web service endpoint add the wsdl property and classpath to the wsdl as well as setting the endpoint type to `EndpointType.JAX_WS_WSDL`. +To expose as a wsdl first jax web service endpoint add the wsdl property. ```groovy -@WebService(name = 'CustomerServiceWsdlEndpoint', -targetNamespace = 'http://test.cxf.grails.org/', -serviceName = 'CustomerServiceWsdlEndpoint', -portName = 'CustomerServiceWsdlPort') -@GrailsCxfEndpoint(wsdl = 'org/grails/cxf/test/soap/CustomerService.wsdl', expose = EndpointType.JAX_WS_WSDL) +@GrailsCxfEndpoint(wsdl = 'org/grails/cxf/test/soap/CustomerService.wsdl', address='/customerServiceWsdlEndpoint') class AnnotatedCustomerServiceWsdlEndpoint { CustomerServiceEndpoint customerServiceEndpoint diff --git a/src/main/groovy/org/grails/cxf/utils/EndpointRegistrationUtil.groovy b/src/main/groovy/org/grails/cxf/utils/EndpointRegistrationUtil.groovy index 227c9d2..d00fc94 100644 --- a/src/main/groovy/org/grails/cxf/utils/EndpointRegistrationUtil.groovy +++ b/src/main/groovy/org/grails/cxf/utils/EndpointRegistrationUtil.groovy @@ -1,4 +1,4 @@ -package org.grails.cxf.utils +package org.grails.cxf.utils; import groovy.transform.CompileStatic import groovy.util.logging.Slf4j @@ -31,6 +31,7 @@ class EndpointRegistrationUtil { GrailsCxfEndpoint annotation = getAnnotation(implementor) //needs to happen first setServiceAndPortName(endpoint, implementor, annotation) + addWsdl(annotation, endpoint) publishEndpointUrl(endpoint, implementor, annotation) //needs to happen last due to changing factory service stuff addConfiguredProperties(endpoint, implementor, annotation, context) @@ -59,7 +60,6 @@ class EndpointRegistrationUtil { assert implementor != null if (annotation != null) { addSoap12(annotation, endpoint) - addWsdl(annotation, endpoint) addProperties(annotation, implementor, endpoint) addInInterceptors(annotation, endpoint, context) addInFaultInterceptors(annotation, endpoint, context) @@ -85,7 +85,7 @@ class EndpointRegistrationUtil { private static void addServiceName(GrailsCxfEndpoint annotation, Object implementor, EndpointImpl endpoint) { if (annotation?.name()) { endpoint.serviceName = - new QName(getNamespaceURI(implementor), + new QName(getNamespaceURI(annotation, implementor), annotation.name(), XMLConstants.DEFAULT_NS_PREFIX) } @@ -94,14 +94,14 @@ class EndpointRegistrationUtil { private static void addPortName(GrailsCxfEndpoint annotation, Object implementor, EndpointImpl endpoint) { if (annotation?.port()) { endpoint.endpointName = - new QName(getNamespaceURI(implementor), + new QName(getNamespaceURI(annotation, implementor), annotation.port(), XMLConstants.DEFAULT_NS_PREFIX) } } - private static String getNamespaceURI(implementor) { - 'http://' + implementor.getClass().package.name.split('\\.').reverse().join(".") + private static String getNamespaceURI(GrailsCxfEndpoint annotation, Object implementor) { + return annotation?.namespace() ?: ( 'http://' + implementor.getClass().package.name.split('\\.').reverse().join(".") ) } private static void addWsdl(GrailsCxfEndpoint annotation, EndpointImpl endpoint) { diff --git a/src/main/groovy/org/grails/cxf/utils/GrailsCxfEndpoint.groovy b/src/main/groovy/org/grails/cxf/utils/GrailsCxfEndpoint.groovy index d5413c6..33b7587 100644 --- a/src/main/groovy/org/grails/cxf/utils/GrailsCxfEndpoint.groovy +++ b/src/main/groovy/org/grails/cxf/utils/GrailsCxfEndpoint.groovy @@ -19,6 +19,7 @@ import java.lang.annotation.Target EndpointType expose() default EndpointType.JAX_WS boolean soap12() default false String wsdl() default '' + String namespace() default '' //Interceptors String[] inInterceptors() default [] String[] outInterceptors() default []