The WSIT Tutorial

Primitives and Wrappers

Guideline: Java primitive and wrapper classes map to slightly different XML schema representations. Therefore, .NET bindings will vary accordingly.

Example: A Java primitive type and its corresponding wrapper class

//-- Java code fragment
public class StockItem{
    public Double wholeSalePrice;
    public double retailPrice;

//--Schema fragment
<xs:complexType name="stockItem">
        <xs:element name="wholeSalePrice" type="xs:double" minOccurs="0"/>
        <xs:element name="retailPrice" type="xs:double"/>

//-- .NET C# auto generated code from schema
public partial class stockItem
    private double wholeSalePrice;
    private bool wholeSalePriceFieldSpecified;
    private double retailPrice;

    public double wholeSalePrice
        get{ return this.wholeSalePrice;}

    public bool wholeSalePriceSpecified
        get{ return this.wholeSalePriceFieldSpecified;}

    public double retailPrice
        get{ return this.retailPrice;}

//-- C# code fragment
stockItem s = new stockItem();
s.wholeSalePrice = Double.parse("198.92");
s.wholeSalePriceSpecified = true;
s.retailPrice = Double.parse("300.25");