Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Where do I put a cfc file that describes a complex structure for a web service?

Guest
Mar 25, 2011 Mar 25, 2011

Hi!

I'm trying to create a web service in ColdFusion 9 that returns a complex structure or has a complex argument.  I am placing the .cfc file that describes the structure in the same directory as the .cfc that is using the structure.  RIght now I'm just trying to get a wsdl.

I currently have two functions in my .cfc,  The first one returns a string.  The second one ideally returns an array of strings.  Saying returntype="string[]"  gives an error that ColdFusion could not parse string

So I tried making a defined type with the individual element being a string:

<cfcomponent>
    <cfproperty name="InfoSource" type="string">
<cfcomponent>

------------------------------------
My code that uses this cfc is:

<cfcomponent>
    <cffunction name="getzips" access="remote" returntype="string">
       <cfset #resultsCommaDelimtedZips# = "this is the result">
      <cfreturn CommaDelimitedZips>
    </cffunction>

    <cffunction name="getInfoSources" access="remote" returntype="InfoSources[]">
    </cffunction>
</cfcomponent>

The error that I get is:

AXIS error

Sorry, something seems to have gone wrong... here are the details:

Fault - Error attempting to create Java skeleton for CFC web service.; nested exception is:
      coldfusion.xml.rpc.CFCInvocationException: [coldfusion.compiler.ParseException : Invalid CFML construct found on line 3 at column 1.ColdFusion was looking at the following text:<p>&lt;</p><p>The CFML compiler was processing:<ul>&lt; marks the beginning of a ColdFusion tag.Did you mean LT or LTE?</ul>]

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: Error attempting to create Java skeleton for CFC web service.; nested exception is:
      coldfusion.xml.rpc.CFCInvocationException: [coldfusion.compiler.ParseException : Invalid CFML construct found on line 3 at column 1.ColdFusion was looking at the following text:<p>&lt;</p><p>The CFML compiler was processing:<ul>&lt; marks the beginning of a ColdFusion tag.Did you mean LT or LTE?</ul>]
faultActor:
faultNode:
faultDetail:
      {http://xml.apache.org/axis/}hostname:ntc15

----------------------------
I have a similar problem if I use cfproperty:

<cfcomponent>
    <cfproperty name="approved" type="string">
    <cfproperty name="total_charged" type="string">
    <cfproperty name="charge_error" type="string">
    <cfproperty name="renewed_until" type="string">
    <cfproperty name="reason" type="string">
<cfcomponent>

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=webservices_20.html says
Note: If the component files are not in a directory under your web root, you must create a web server mapping to the directory that contains them. You cannot use ColdFusion mappings to access web services.

So I tried putting the .cfc file in a directory beneath my wwwroot folder rather than in it.  That didn't help.

Any suggestions?  I feel like I've done exactly what all the documentation I can find tells me to do!

Thanks!

-- Mabel 🙂

2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 28, 2011 Mar 28, 2011

We're working with another company that  is doing the front end and using the web service, so I have to have the  wsdl show the actual data type, not just "any", which is what using "array" does.

If I use your code (adding a name for the echoStatus argument), I get

<wsdl:part name="getInfoSourcesReturn" type="impl:ArrayOf_xsd_anyType"/>

How do I tell it an array of _strings_ specifically?

ColdFusion is weakly-typed, so I wonder whether one can be so specific in the data type, without resorting t

...
Translate
LEGEND ,
Mar 26, 2011 Mar 26, 2011

Looking at this:

<cfcomponent>
    <cffunction name="getzips" access="remote" returntype="string">
       <cfset #resultsCommaDelimtedZips# = "this is the result">
      <cfreturn CommaDelimitedZips>
    </cffunction>

Right off the bat I see what are probably undefined variables in your cfset and cfreturn tags.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 28, 2011 Mar 28, 2011

Hi Dan,

Yes that's true.  However, ColdFusion is pretty happy dealing with undefined variables in terms of not throwing errors when it encounters one.  (You may get a really crazy _result_!  So I don't think that has anything to do with why I could get a WSDL.  BKBK's code basically works and produces a WSDL, so I'm on the right track now.

Thanks!

-- Mabel 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 27, 2011 Mar 27, 2011

1) Store the component

<cfcomponent>
    <cfproperty name="approved" type="string">
    <cfproperty name="total_charged" type="string">
    <cfproperty name="charge_error" type="string">
    <cfproperty name="renewed_until" type="string">
    <cfproperty name="reason" type="string">
</cfcomponent>

as Status.cfc

2) Use returntype="array" instead of returntype="InfoSources[]"

3) Define your webservice, say, TestService.cfc, like this:

<cfcomponent>
    <cffunction name="getzips" access="remote" returntype="string">
       <cfset resultsCommaDelimtedZips = "this is the result">
       <cfreturn resultsCommaDelimtedZips>
    </cffunction>

    <cffunction name="getInfoSources" access="remote" returntype="array">
        <cfset var infoSources = arraynew(1)>
    <cfset infoSources[1] = "a">
    <cfset infoSources[2] = "b">
    <cfset infoSources[3] = "c">
    <cfreturn infoSources>
    </cffunction>

    <cffunction name="echoStatus" access="remote" returnType="status" >
        <cfargument name="" type="status">
        <cfreturn arguments.inputStatus>
    </cffunction>
</cfcomponent>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 28, 2011 Mar 28, 2011

Hi BKBK,

Thanks for that input.  We're working with another company that  is doing the front end and using the web service, so I have to have the  wsdl show the actual data type, not just "any", which is what using "array" does.

If I use your code (adding a name for the echoStatus argument), I get

<wsdl:part name="getInfoSourcesReturn" type="impl:ArrayOf_xsd_anyType"/>

How do I tell it an array of _strings_ specifically?

One other question - was that missing name supposed to be inputStatus?  (I was trying to figure out why returning an unnamed variable would work, and I think I just figured it out.)

Thanks!

-- Mabel 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 28, 2011 Mar 28, 2011
One other question - was that missing name supposed to be inputStatus?

Yes, that was a typing mistake.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 28, 2011 Mar 28, 2011

We're working with another company that  is doing the front end and using the web service, so I have to have the  wsdl show the actual data type, not just "any", which is what using "array" does.

If I use your code (adding a name for the echoStatus argument), I get

<wsdl:part name="getInfoSourcesReturn" type="impl:ArrayOf_xsd_anyType"/>

How do I tell it an array of _strings_ specifically?

ColdFusion is weakly-typed, so I wonder whether one can be so specific in the data type, without resorting to Java for example. But then again, you will soon run into all kinds of complications. A ColdFusion array and a java array are 2 entirely different things. Run the following code and you will see why

<cfset testArray = arrayNew(1)>
<cfoutput>#testArray.getClass().getName()#</cfoutput>

in any case, since strings are is a subset of the 'any' type, your service also covers the case where an array of strings is returned.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 29, 2011 Mar 29, 2011
LATEST

Hi BKBK,

Thanks for your answers!  I think I'm set for now.

-- Mabel 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources