cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Kulp (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-7062) wsdl2java generates incorrect @XmlElement(namespace=“…”)
Date Fri, 23 Sep 2016 07:46:20 GMT

    [ https://issues.apache.org/jira/browse/CXF-7062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15515705#comment-15515705
] 

Daniel Kulp commented on CXF-7062:
----------------------------------

The "type" parameter has no relevance to the namespace used on the element.   If the element
was:
{code:xml}
<element name="status" type="xsd:string"/>
{code}
the namespace for the status element would NOT be the xsd namespace.   It would be namespace
of the schema for which the element is defined in.

In your case, if the FoundationTypes.xsd had a top level element like:
{code:xml}
<xs:element name="status" type="Status" />
{code}

and in the other location it was referenced like:
{code:xml}
<xs:element ref="foundationTypes:status" />
{code}

then that element would be in the foundationTypes namespace.   


> wsdl2java generates incorrect @XmlElement(namespace=“…”)
> --------------------------------------------------------
>
>                 Key: CXF-7062
>                 URL: https://issues.apache.org/jira/browse/CXF-7062
>             Project: CXF
>          Issue Type: Bug
>          Components: Soap Binding
>    Affects Versions: 3.1.7
>         Environment: MacOSX 10.11, Java v1.8
>            Reporter: Randy Leonard
>            Assignee: Daniel Kulp
>            Priority: Blocker
>             Fix For: Invalid
>
>
> I am using Apache CXF 3.1.7, and the wsdl2java command is generating code with missing/incorrect
namespace attributes on the @XMLEment annotation.
> Note I generally use four distinct namespaces within each WSDL document, which are as
follows:
> 	• Shared data types across many WSDL documents (http://v1_0_0.datatypes.provider.soap.foundation.rps.com)
> 	• Domain-specific data types (http://v1_0_0.datatypes.provider.soap.common.masterdata.rps.com)
> 	• Parameter types (http://v1_0_0.parameters.provider.soap.common.masterdata.rps.com)
> 	• Service types (http://v1_0_0.provider.soap.common.masterdata.rps.com)
> This gives a nice separation of data types, and has worked quite well for me with Axis2.
I am having issues, however, when applying this approach to CXF. Below is an example WSDL
document with the namespaces defined above:
> ———————————————
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions targetNamespace="http://v1_0_0.provider.soap.common.masterdata.rps.com"
> xmlns:foundationTypes="http://v1_0_0.datatypes.provider.soap.foundation.rps.com"
> 	xmlns:masterdataCommonTypes="http://v1_0_0.datatypes.provider.soap.common.masterdata.rps.com"
> xmlns:parameter="http://v1_0_0.parameters.provider.soap.common.masterdata.rps.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> 	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://v1_0_0.provider.soap.common.masterdata.rps.com"
> xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
> 	xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
> 	<wsdl:types>
> 		<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://v1_0_0.parameters.provider.soap.common.masterdata.rps.com"
> >
> 			<xs:import namespace="http://v1_0_0.datatypes.provider.soap.foundation.rps.com"
schemaLocation="schemas/FoundationTypes.xsd" />
> 			<xs:import namespace="http://v1_0_0.datatypes.provider.soap.common.masterdata.rps.com"
schemaLocation="schemas/MasterDataCommonTypes.xsd" />
> 			<xs:element name="consumerChannelFetchRequest">
> 				<xs:annotation>
> 				</xs:annotation>
> 				<xs:complexType>
> 					<xs:sequence>
> 						<xs:element name="paymentSchemeId" type="xs:string" minOccurs="0" />
> 						<xs:element name="bin" type="xs:string" minOccurs="0" />
> 					</xs:sequence>
> 				</xs:complexType>
> 			</xs:element>
> 			<xs:element name="consumerChannelFetchResponse">
> 				<xs:annotation>
> 				</xs:annotation>
> 				<xs:complexType>
> 					<xs:sequence>
> 						<xs:element name="status" type="foundationTypes:Status" />
> 						<xs:element name="channels" type="masterdataCommonTypes:ConsumerChannel" minOccurs="0"
> maxOccurs="unbounded" />
> 					</xs:sequence>
> 				</xs:complexType>
> 			</xs:element>
> 			<xs:element name="consumerChannelUpdateRequest">
> 				<xs:annotation>
> 				</xs:annotation>
> 				<xs:complexType>
> 					<xs:sequence>
> 						<xs:element name="paymentSchemeId" type="xs:string" minOccurs="0" />
> 						<xs:element name="bin" type="xs:string" minOccurs="0" />
> 					</xs:sequence>
> 				</xs:complexType>
> 			</xs:element>
> 			<xs:element name="consumerChannelUpdateResponse">
> 				<xs:annotation>
> 				</xs:annotation>
> 				<xs:complexType>
> 					<xs:sequence>
> 						<xs:element name="status" type="foundationTypes:Status" />
> 					</xs:sequence>
> 				</xs:complexType>
> 			</xs:element>
> 		</xs:schema>
> 	</wsdl:types>
> 	<wsdl:message name="consumerChannelFetchMessageRequest">
> 		<wsdl:part element="parameter:consumerChannelFetchRequest" name="request" />
> 	</wsdl:message>
> 	<wsdl:message name="consumerChannelFetchMessageResponse">
> 		<wsdl:part element="parameter:consumerChannelFetchResponse" name="response" />
> 	</wsdl:message>
> 	<wsdl:message name="consumerChannelUpdateMessageRequest">
> 		<wsdl:part element="parameter:consumerChannelUpdateRequest" name="request" />
> 	</wsdl:message>
> 	<wsdl:message name="consumerChannelUpdateMessageResponse">
> 		<wsdl:part element="parameter:consumerChannelUpdateResponse" name="response" />
> 	</wsdl:message>
> 	<wsdl:portType name="ConsumerChannelPortType">
> 		<wsdl:operation name="consumerChannelFetch">
> 			<wsdl:input message="tns:consumerChannelFetchMessageRequest" name="consumerChannelFetchMessageRequest"
/>
> 			<wsdl:output message="tns:consumerChannelFetchMessageResponse" name="consumerChannelFetchMessageResponse"
/>
> 		</wsdl:operation>
> 		<wsdl:operation name="consumerChannelUpdate">
> 			<wsdl:input name="consumerChannelUpdateMessageRequest" message="tns:consumerChannelUpdateMessageRequest"
/>
> 			<wsdl:output name="consumerChannelUpdateMessageResponse" message="tns:consumerChannelUpdateMessageResponse"
/>
> 		</wsdl:operation>
> 	</wsdl:portType>
> 	<wsdl:binding name="ConsumerChannelSoap12Binding" type="tns:ConsumerChannelPortType">
> 		<wsoap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"
/>
> 		<wsdl:operation name="consumerChannelFetch">
> 			<soap:operation soapAction="" style="document" />
> 			<wsdl:input name="consumerChannelFetchMessageRequest">
> 				<wsoap12:body use="literal" />
> 			</wsdl:input>
> 			<wsdl:output name="consumerChannelFetchMessageResponse">
> 				<wsoap12:body use="literal" />
> 			</wsdl:output>
> 		</wsdl:operation>
> 		<wsdl:operation name="consumerChannelUpdate">
> 			<soap:operation soapAction="" style="document" />
> 			<wsdl:input name="consumerChannelUpdateMessageRequest">
> 				<wsoap12:body use="literal" />
> 			</wsdl:input>
> 			<wsdl:output name="consumerChannelUpdateMessageResponse">
> 				<wsoap12:body use="literal" />
> 			</wsdl:output>
> 		</wsdl:operation>
> 	</wsdl:binding>
> 	<wsdl:service name="ConsumerChannelService">
> 		<wsdl:port name="ConsumerChannelSoap12Endpoint" binding="tns:ConsumerChannelSoap12Binding">
> 			<wsoap12:address location="http://localhost:8080/axis2/services/ConsumerChannelService"
/>
> 		</wsdl:port>
> 	</wsdl:service>
> </wsdl:definitions>
> ———————————————
> The following generated ConsumerChannelFetchResponse class contains no namespace attribute
for @XmlElement annotations, unless I include '-xjc-npa' in the wsdl2java command. When including
'-xjc-npa', I then get the incorrect namespaces in the @XmlElement annotation. Both scenarios
result in unmarshaling errors on the client side:
> ———————————————
> /**
>  * <p>Java class for anonymous complex type.
>  * 
>  * <p>The following schema fragment specifies the expected content contained within
> this class.
>  * 
>  * <pre>
>  * &lt;complexType&gt;
>  *   &lt;complexContent&gt;
>  *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
>  *       &lt;sequence&gt;
>  *         &lt;element name="status" type="{http://v1_0_0.datatypes.provider.soap.foundation.rps.com}Status"/&gt;
>  *         &lt;element name="channels" type="{http://v1_0_0.datatypes.provider.soap.common.masterdata.rps.com}ConsumerChannel"
> maxOccurs="unbounded" minOccurs="0"/&gt;
>  *       &lt;/sequence&gt;
>  *     &lt;/restriction&gt;
>  *   &lt;/complexContent&gt;
>  * &lt;/complexType&gt;
>  * </pre>
>  * 
>  * 
>  */
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "", propOrder = {
>     "status",
>     "channels"
> })
> @XmlRootElement(name = "consumerChannelFetchResponse", namespace = "http://v1_0_0.parameters.provider.soap.common.masterdata.rps.com")
> public class ConsumerChannelFetchResponse {
>     @XmlElement(namespace = "http://v1_0_0.parameters.provider.soap.common.masterdata.rps.com",
> required = true)
>     protected Status status;
>     @XmlElement(namespace = "http://v1_0_0.parameters.provider.soap.common.masterdata.rps.com")
>     protected List<ConsumerChannel> channels;
>     ……….
> ———————————————
> Note the namespace in the 'Status' variable @XmlElement annotation for the above code
should be:
> 	• http://v1_0_0.datatypes.provider.soap.foundation.rps.com
> But is the following instead:
> 	• http://v1_0_0.parameters.provider.soap.common.masterdata.rps.com
> A close examination of the comment block prior to the ConsumerChannelFetchResponse class
declaration indicates wsdl2java cleary understands the Status type is from the correct class,
but the namespace attribute in the @XmlElement does not reflect this.
> I've tried generating this class using both the cxf-codegen-plugin plugin, and executing
wsdl2java directly from the command line. Both to no avail.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message