Complex object arrays in published soap webservice


#1

I have a SOAP webservice in coldfusion that I had to build in SOAP because the partner we wanted to work with could only consume SOAP. I built it using complex objects which took a bit of messing with in CF, but ended up working fine. Right now I’m seeing if I can port this to Lucee, but ran into an issue when trying to get it produce an array of objects. IE… I have an OrderResponse CFC that has an array of Order cfc’s as the response.

<cfcomponent displayname="OrderResponse">

    <cfproperty name="orderCount" type="string" remotingfetch="true">
    <cfproperty name="orders" type="Order[]" remotingfetch="true">
    <cfscript>
		public string function getOrderCount()		{
			return this.OrderCount;
		}

		public void function setOrderCount(required string orderCount)	{
			 this.OrderCount = arguments.OrderCount;
		}

		public Order[] function getOrders()		{
			return this.Orders;
		}
               public void function addOrder(required Order order)		{
			if ( not structKeyExists(this,"orders") or not isArray(this.orders)  )	{
				 this.orders = [arguments.order];
			} else	{
				 arrayAppend(this.Orders,arguments.Order);
			}
		}
    </cfscript>
</cfcomponent>

The orders array is basically an array of Objects/cfcs.

<cfcomponent displayname="Order" output="false" accessors="true" serializable="true">
	<cfproperty name="orderId" type="string" remotingfetch="true" default="0">
         <!---- bunch of other stuff in this component/cfc/object removed for simplicity ----> 
</cfcomponent>

This works in CF 10. (in CF11 it will work as well, but you have to change the accessor methods to private instead of public)

Anyhoo, in CF 10, this will get output in the WSDL as:

<complexType name="OrderResponse">
  <sequence>
    <element name="orderCount" nillable="true" type="xsd:string"/>
    <element name="orders" nillable="true" type="impl:ArrayOf_tns1_Order"/>
  </sequence>
</complexType>

If I try to run the same thing in Lucee, it won’t even compile because it complains about the type=“Order” part in the tag. IF I swap the Order in the cfproperty to a simple array, then that’s breaks the SOAP response/agreement because then I’m returning a complex object in what would otherwise be an untyped simple array.
ie…

<complexType name="OrderResponse">
  <sequence>
    <element name="orderCount" nillable="true" type="xsd:string"/>
    <element name="orders" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
</sequence>
</complexType>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://localhost/webservices/csininhandler.cfc">
    <import namespace="http://rpc.xml.coldfusion"/>
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
    <complexType name="ArrayOf_xsd_anyType">
        <complexContent>
            <restriction base="soapenc:Array">
                <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:anyType[]"/>
            </restriction>
        </complexContent>
    </complexType>
</schema>

Any idea about how to get Lucee to publish an array of complex objects in a SOAP webservice?

thanks!


#2

Is this problem solved? It would be helpful if you can post the entire file, so we can replicate your environment?