Detailed issue
While Accessing a webservice using axis 1.2, we are sending the input as arrayofComplex Data Type.
ComplexData Type - a Class KeyValuePair.
public class KeyValuePair implements java.io.Serializable {
private java.lang.String key;
private java.lang.String value;
public KeyValuePair() { }
public KeyValuePair(java.lang.String key, java.lang.String value) {
this.key = key;
this.value = value;
}
}
Input to the webservice is array of the above mentioned data Type.
We are expecting the following request.
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1

rocessEvent soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.epiphany.com/RP">
<package xsi:type="xsd:string">THREE</package>
<event xsi:type="xsd:string">OfferRequest</event>
<fields soapenc:arrayType="ns1:ArrayOfKeyValuePair[10]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<item href="#id0"/>
<item href="#id1"/>
</fields>
</ns1

rocessEvent>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:KeyValuePair" xmlns:ns7="http://www.epiphany.com/RP" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<key xsi:type="xsd:string">
SessionId
</key>
<value xsi:type="xsd:string">
1234567890
</value>
</multiRef>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:KeyValuePair" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://www.epiphany.com/RP">
<key xsi:type="xsd:string">
Customer_ID
</key>
<value xsi:type="xsd:string">
</value>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
Instead we are getting the following
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1

rocessEvent soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.epiphany.com/RP">
<package xsi:type="xsd:string">THREE</package>
<event xsi:type="xsd:string">OfferRequest</event>
<fields soapenc:arrayType="ns1:ArrayOfKeyValuePair[10]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<fields href="#id0"/>
<fields href="#id1"/>
</fields>
</ns1

rocessEvent>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:KeyValuePair" xmlns:ns7="http://www.epiphany.com/RP" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<key xsi:type="xsd:string">
SessionId
</key>
<value xsi:type="xsd:string">
1234567890
</value>
</multiRef>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:KeyValuePair" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://www.epiphany.com/RP">
<key xsi:type="xsd:string">
Customer_ID
</key>
<value xsi:type="xsd:string">
</value>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
Note the ArrayOfKeyValuePair should have tag named <item> as per soap standards, but we get the parent array tag name in its
element name too. i.e fields tag is replaced for <item tag
HOw to solve this issue and get expected response.
Fyi
We have given the Serializer and Deserializer as below
QName arrayOfKeyValuePairQname = new javax.xml.namespace.QName("http://www.epiphany.com/RP", "ArrayOfKeyValuePair");
QName arrayOfReturnedOffersQname = new javax.xml.namespace.QName("http://www.epiphany.com/RP", "ArrayOfReturnedOffer");
QName keyValuePairQName = new javax.xml.namespace.QName("http://www.epiphany.com/RP", "KeyValuePair");
QName returnedOfferQName = new javax.xml.namespace.QName("http://www.epiphany.com/RP", "ReturnedOffer");
TypeMappingRegistry typeMappingRegistry = service.getTypeMappingRegistry();
TypeMapping map = typeMappingRegistry.getDefaultTypeMapping();
map.register(KeyValuePair[].class, arrayOfKeyValuePairQname,
new ArraySerializerFactory(KeyValuePair[].class, arrayOfKeyValuePairQname),
new ArrayDeserializerFactory());
map.register(KeyValuePair.class, keyValuePairQName,
new BeanSerializerFactory(KeyValuePair.class,
keyValuePairQName), new BeanDeserializerFactory(
KeyValuePair.class, keyValuePairQName));
map.register(ReturnedOffer.class, returnedOfferQName,
new BeanSerializerFactory(ReturnedOffer.class,
returnedOfferQName), new BeanDeserializerFactory (
ReturnedOffer.class, returnedOfferQName));
Still we are not able to get the expected result. Kindly help us ASAP.
WSDL Entry is as follows.
<xsd:complexType name="KeyValuePair">
<xsd:sequence>
<xsd:element name="key" type="xsd:string"/>
<xsd:element name="value" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfKeyValuePair">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:sequence>
<xsd:element name="item" type="rp:KeyValuePair" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="rp:KeyValuePair[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<message name="ProcessEventRequest">
<part name="package" type="xsd:string"/>
<part name="event" type="xsd:string"/>
<part name="fields" type="rp:ArrayOfKeyValuePair"/>
</message>