You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Daniel Kulp (JIRA)" <ji...@apache.org> on 2017/03/22 17:44:41 UTC
[jira] [Resolved] (CXF-7062) wsdl2java generates incorrect @XmlElement(namespace=“…”)
[ https://issues.apache.org/jira/browse/CXF-7062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp resolved CXF-7062.
------------------------------
Resolution: Not A Problem
> 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>
> * <complexType>
> * <complexContent>
> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
> * <sequence>
> * <element name="status" type="{http://v1_0_0.datatypes.provider.soap.foundation.rps.com}Status"/>
> * <element name="channels" type="{http://v1_0_0.datatypes.provider.soap.common.masterdata.rps.com}ConsumerChannel"
> maxOccurs="unbounded" minOccurs="0"/>
> * </sequence>
> * </restriction>
> * </complexContent>
> * </complexType>
> * </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.15#6346)