We are trying to get Microsoft .Net and Apache SOAP to interoperate. To do this 
we have focused on limiting the behavior of each platform to the current w3c 
SOAP draft ( http://www.w3.org/TR/2001/WD-soap12-part2-20011002/#arrays ). One 
problem we have seen is that Apache SOAP does not seem to correctly handle 
array encoding as defined in this model; the array is not correctly decoded 
because it appears that Apache SOAP wants to see a type attribute defined, such 
as xsi:type="ns3:Array".

Below is an example of a response that is not correctly decoded by Apache SOAP 
(although it does work with the .NET tools):

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; 
  xmlns:tns="http://www.tms.com/arrayTest"; 
  xmlns:types="http://www.tms.com/arrayTest/encodedTypes"; 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>

 <soap:Body 
  soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
   <tns:synchRequestResponse>
   <synchRequestResult href="#id1"/>
   </tns:synchRequestResponse>
  
   <types:RFCReplyAA id="id1" xsi:type="types:RFCReplyAA">
     <m_originatingRequestId xsi:type="xsd:long">6789</m_originatingRequestId>
     <m_items href="#id2"/>
   </types:RFCReplyAA>
   <soapenc:Array id="id2" soapenc:arrayType="types:RFCitemAA[2]">   <== HERE
        <Item href="#id3"/>
        <Item href="#id4"/>
   </soapenc:Array>
   <types:Sub1RFCitemAA id="id3" xsi:type="types:Sub1RFCitemAA"> 
        <m_item_num xsi:type="xsd:long">1234</m_item_num>
        <m_item_desc xsi:type="xsd:string">Left Door</m_item_desc>
        <m_item_sub1 xsi:type="xsd:long">4321</m_item_sub1>
   </types:Sub1RFCitemAA>
   <types:Sub2RFCitemAA id="id4" xsi:type="types:Sub2RFCitemAA">
        <m_item_num xsi:type="xsd:long">1234</m_item_num>
        <m_item_desc xsi:type="xsd:string">RightDoor</m_item_desc>
        <m_item_sub2 xsi:type="xsd:long">4321</m_item_sub2>
   </types:Sub2RFCitemAA>
  </soap:Body>
</soap:Envelope>

In order to get the code to work I hacked the Apache SOAP source and added the 
following to SoapEncUtils.java

  public static QName getTypeQName(Element el)
    throws IllegalArgumentException
  {
    // Try 1999
    QName typeQName = getAttributeValue(el, Constants.NS_URI_1999_SCHEMA_XSI,
                                        Constants.ATTR_TYPE, null, false);
    if (typeQName != null)
      return typeQName;
    
    // Try 2000
    typeQName = getAttributeValue(el, Constants.NS_URI_2000_SCHEMA_XSI,
                                  Constants.ATTR_TYPE, null, false);
    if (typeQName != null)
      return typeQName;
    
    // Try 2001
    typeQName = getAttributeValue(el, Constants.NS_URI_2001_SCHEMA_XSI,
                                  Constants.ATTR_TYPE, null, false);

    if (typeQName != null)
      return typeQName;

    //
    // hack
    //
    if(el.getTagName().endsWith(":Array") == true)
    {
        typeQName = new QName(Constants.NS_URI_SOAP_ENC , "Array");
    }
    //
   // end hack
   //

    return typeQName;
  }

Obviously this fix is not a production quality solution, but i think that it 
does point out where the problem lays in general. Has anyone else come across 
this? 

Andy Fyke                
[EMAIL PROTECTED]

Reply via email to