hi,
Recently I have added the soap encoded support to ADB. Now people can use
soap encoding with the Axis2 as well.

To support the soap encoding, there are a set of special classes in the
org.apache.axis2.databinding.types.soapencoding pacakge.
The org.apache.axis2.databinding.types.soapencoding.Array class is used to
support the SOAP-ENC:Array type.

Lets take this schema fragment
<s:element name="TestSoapElement2">
        <s:complexType>
            <s:sequence>
                <s:element name="param1" type="s:string"/>
                <s:element name="param2" type="soapenc:Array"/>
            </s:sequence>
        </s:complexType>
    </s:element>

The generated TestSoapElement2 class has a reference to this soap array
class. This Array class
then can be used to add elements and send the array

for an example objects can be added using the addObject method.
(please see the SoapEncodingTest class under adb-codegen module)
       Array array = new Array();
        _double testDouble;
        for (int i = 0; i < 2; i++) {
            testDouble = new _double();
            testDouble.set_double(23.45);
            array.addObject(testDouble);
        }
to add soap encoding types,  classes under
org.apache.axis2.databinding.types.soapencoding can be used
and to add the Standard Schema types, classes under
org.apache.axis2.databinding.types.xsd can be used. To add any other complex
type those classes can be used.

this array would serialize as follows
<ns1:TestSoapElement2 xmlns:ns1="http://tempuri.org/soapencoding";>
    <ns1:param1>test param</ns1:param1>
    <ns1:param2 xmlns:s2="http://www.w3.org/2001/XMLSchema"; xmlns:SOAP-ENC="
http://schemas.xmlsoap.org/soap/encoding/";
                SOAP-ENC:arrayType="s2:ur-type[2]">
        <item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="SOAP-ENC:double">23.45</item>
        <item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="SOAP-ENC:double">23.45</item>
    </ns1:param2>
</ns1:TestSoapElement2>

since there is no special array type declaration it adds xsi:type for all
the items. the array type can be set
as follows using the setArrayTypeQName method.
        Array array = new Array();
        array.setArrayTypeQName(new QName("
http://schemas.xmlsoap.org/soap/encoding/";, "double"));
        _double testDouble;
        for (int i = 0; i < 2; i++) {
            testDouble = new _double();
            testDouble.set_double(23.45);
            array.addObject(testDouble);
        }

this would serialize like this
<ns1:TestSoapElement2 xmlns:ns1="http://tempuri.org/soapencoding";>
    <ns1:param1>test param</ns1:param1>
    <ns1:param2 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
SOAP-ENC:arrayType="SOAP-ENC:double[2]">
        <item>23.45</item>
        <item>23.45</item>
    </ns1:param2>
</ns1:TestSoapElement2>

Complex types can also be supported in the same way.

Limitations.
href attribute is not supported.
i.e it can not parse xmls like
<greeting id="String-0">Hello</greeting>
<salutation href="#String-0"/>
ADB creates the java object structure using the direct parsing of the input
xml stream without creating any intermediate structure. Therefore it can not
move the pointer to arbitrary locations.

However it is worth to note that the basic profile discourages usage of soap
encoding
http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html#SOAP_encodingStyle_Attribute.
Therefore this feature is for the users who have to deal with the old wsdls
having soap encoding.

Please help us using this feature and reporting any issues so that I can fix
those issue for Axis2 1.4 release.

Thanks,
Amila.

-- 
Amila Suriarachchi,
WSO2 Inc.

Reply via email to