You know the word caveat, right? Well, today I learned that there are a few caveats when setting up ColdSpring remote proxy beans.

  • When invoking a webservice that has logically optional arguments, you still have to pass all defined arguments with the omit attribute set to yes on the <cfinvokeargument> tag (see Listing 1.1 below). Otherwise you’ll get the result of a Java method exception. It will look something like this – ” Web service operation “someMethod” with parameters {ARGUMENT={1}} could not be found”
  • When you have optional arguments in a component method that you want to access as a webservice, you have to provide a default value for each one. Otherwise, you’ll get premature end of file Axis errors (see Listing 1.2 below)
  • You must define the (somewhat) undocumented beanFactoryName property of ColdSpring’s RemoteFactoryBean. This will be the package name of where your ColdSpring definitions are located in the application namespace. For those using Model-Glue, this will be {app name}.framework (see Listing 1.3 below)

Listing 1.1

<cfscript>
billGroupService = createObject("webservice", "http://localhost/webapps/charm/remote/BillingGroup.cfc?wsdl");
</cfscript>
<cfinvoke method="getGroups" webservice="#billGroupService#">
	<cfinvokeargument name="BILLING_RULE_GRP_CD" value="1">
	<cfinvokeargument name="DESCR" omit="yes">
	<cfinvokeargument name="ACTIVE_IND" omit="yes">
	<cfinvokeargument name="DEFAULT_FLAG" omit="yes">
</cfinvoke>

Listing 1.2

<cffunction name="getGroups" access="public" output="false" returntype="array">
	<cfargument name="BILLING_RULE_GRP_CD" default="" type="string" required="false" />
	<cfargument name="DESCR" default="" type="string" required="false" />
	<cfargument name="ACTIVE_IND" default="" type="string" required="false" />
	<cfargument name="DEFAULT_FLAG" default="" type="string" required="false" />

	<cfreturn variables.GroupGateway.getByAttributes(argumentCollection=arguments) />
</cffunction>

Listing 1.3

<bean id="RemoteBillingRuleGroup" class="coldspring.aop.framework.RemoteFactoryBean">
	<property name="interceptorNames">
		<list>
			<value>exceptionLoggingAdvisor</value>
			<value>metricsAdvisor</value>
		</list>
	</property>
	<property name="target">
		<ref bean="BillingRuleGroupTarget" />
	</property>
	<property name="serviceName">
		<value>BillingGroup</value>
	</property>
	<property name="relativePath">
		<value>/webapps/charm/remote/</value>
	</property>
	<property name="beanFactoryName">
		<value>charm.framework</value>
	</property>
	<property name="remoteMethodNames">
		<value>*</value>
	</property>
</bean>