Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enum Type in WSDL representation

Tags:

java

wsdl

A WSDL representation as below :

<xs:simpleType name="customerType">
    <xs:restriction base="xs:string">
        <xs:enumeration value="PRIVATE"/>
        <xs:enumeration value="BUSINESS"/>
    </xs:restriction>
</xs:simpleType>

resulted in the code as below by cxf-codegen-plugin:

public enum CustomerType { 
    PRIVATE, BUSINESS 
} 

Can be represented in WSDL as:

How can we represent enum in WSDL so that the cxf-codegen-plugin can generate code as below:

public enum CustomerType { 
        PRIVATE{public BigInteger getNcid() { 
                return new BigInteger("1"); 
}, 
BUSINESS{public BigInteger getNcid() { 
                return new BigInteger("2"); 
} 

public abstract BigInteger getNcid(); 
    }

If we can't have cxf-codegen generate this what is the best way we can handle this case in java. I really appreciate your help.

like image 378
remo Avatar asked May 29 '13 15:05

remo


People also ask

What is a WSDL element?

WSDL Elements. Definition − It is the root element of all WSDL documents. It defines the name of the web service, declares multiple namespaces used throughout the remainder of the document, and contains all the service elements described here. Data types − The data types to be used in the messages are in the form of XML schemas.

What are the constant values of enum members?

By default, the associated constant values of enum members are of type int; they start with zero and increase by one following the definition text order. You can explicitly specify any other integral numeric type as an underlying type of an enumeration type.

How to define data types in WSDL?

WSDL uses the W3C XML Schema specification as its default choice to define data types. If the service uses only XML Schema built-in simple types, such as strings and integers, then types element is not required. WSDL allows the types to be defined in separate elements so that the types are reusable with multiple web services.

What is an enum type in C++?

An enumeration type (or enum type) is a value type defined by a set of named constants of the underlying integral numeric type. To define an enumeration type, use the enum keyword and specify the names of enum members: C#. enum Season { Spring, Summer, Autumn, Winter }.


1 Answers

That is not a representation of the same thing.

You haven't said which programming language you're using, but it looks like you intend for PRIVATE to be associated with the value 1, and BUSINESS to be associated with the value 2. That is not represented in the WSDL.

WSDL uses XML Schema to describe the shape of data. XML Schema has no concept equivalent to an enum in a programming language. In most programming languages I know, an enum is a named constant. The enumeration facet in XML Schema does not describe named values. It simply says that the value at that point can be one of the listed (string) values.

like image 108
John Saunders Avatar answered Sep 20 '22 11:09

John Saunders