I can't tell you why CF does what it does, but I can say that it is definitely 
possible to have optional arguments in the Web Services (WSDL/SOAP) specs themselves, 
regardless of how CF implements them.

I've done some further testing on this today and gotten strange results. Here's a 
simple CF service:

<cfcomponent>
        <cffunction name="saySomeShite" access="remote" returntype="string">
                <cfargument name="dummyArg" type="string" required="false">
                <cfreturn "Some shite!">
        </cffunction>
</cfcomponent>

You can consume this in Flash and Java/JSP with or without passing the arg in by my 
testing on 6.1. However, you can consume this in CF itself only by passing a null 
string to the argument (""). Not exactly optional, but it does work. (Of course, it 
only works for string and "any" types - trying to pass the arg in the same way for 
anything else just throws errors.) This is actually similar to a SOAP request that is 
not passing an optional arg - sort of. Notice the last element "projectDescription" is 
present but empty (which does not pass a value, unlike the way CF has you do it):

<SOAP-ENV:Body>
  <firstName xsi:type="xsd:string">John</firstName> 
  <lastName xsi:type="xsd:string">Yossarian</lastName> 
  <emailAddress xsi:type="xsd:string">[EMAIL PROTECTED]</emailAddress> 
  <status xsi:type="cc1:AcademicStatus">UNDERGRADUATE</status> 
  <projectDescription xsi:type="xsd:string" /> 
</SOAP-ENV:Body>

This SOAP request is calling a service that is a J2EE service with optional args - you 
can take a look at it here: 
http://www.capescience.com/webservices/academiclicenseservice/index.shtml

This is what the SOAP request for our service would look like:

<SOAP-ENV:Body>
    <ns0:saySomeShite>
         <dummyArg xsi:type="xsd:string"/>
    </ns0:saySomeShite>
</SOAP-ENV:Body>

But this also works:

<SOAP-ENV:Body>
    <ns0:saySomeShite/>
</SOAP-ENV:Body>

I've sent both of these SOAP packets in raw form to CF (from the JSP and from a WS 
Testing utility) and CF will accept the call and return the proper values. I haven't 
been able to sniff on the line while Flash is sending SOAP requests yet, though, so I 
have no idea how Flash is handling this. 

The discrepancy seems to be in the way that CF sends SOAP requests(?). I haven't been 
able to sniff that yet either, but I'll keep poking at it. If anyone has any insight 
into all of this or can confirm any of this behavior, feel free to jump right in...

Scott

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Brad Howerter
Sent: Monday, August 11, 2003 3:20 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [CFCDev] CFC as a service doesn't allow optional arguments?

Does anyone know why required="false" is ignored?  Are all web services that
way (no optional arguments), or just those created with Cold Fusion?
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to