Enum Enter WSDL View

The WSDL view as shown below:

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

cited the code as shown below, cxf-codegen-plugin:

 public enum CustomerType { PRIVATE, BUSINESS } 

It can be represented in WSDL as:

As we can imagine the enumeration in WSDL so that cxf-codegen-plugin can generate code, as shown 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 cannot create cxf-codegen, this is the best way to handle this case in java. I really appreciate your help.

+4
source share
1 answer

This is not a representation of the same thing.

You did not indicate which programming language you are using, but it looks like you intend to associate PRIVATE with a value of 1, and BUSINESS with a value of 2. This is not represented in the WSDL.

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

+5
source

Source: https://habr.com/ru/post/1483386/


All Articles