From: blastbeat on
All,

I'm stuck on this one - any help would be much apperciated.

I'm trying to expose a CFC which uses a DAO/Bean pattern and am receiving the
following error.


Could not perform web service invocation "getQuote".
Here is the fault returned when invoking the web service operation:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: coldfusion.xml.rpc.CFCInvocationException:
[coldfusion.runtime.UndefinedElementException : Element QUOTEDAO is undefined
in a Java object of type class [Ljava.lang.String; referenced as ]

Here are my files to give you an idea of what I am working with.

/webservices/application.cfm
/webservices/quote/quote.cfc (bean)
/webservices/quote/quoteDAO.cfc (my data access object, has crud methods)
/webservices/quote/quoteService.cfc (service layer, i generate my wsdl from
this)

I have unit tested the CFC's by running a test.cfm file within the
/webservices directory which calls all methods. Works fine. Additionally, the
WSDL generates fine.

The problem is when I invoke the service, here is how I am invoking it.

<cfinvoke
webservice="http://localhost/apps/webservices/quote/quoteService.cfc?wsdl"
method="getQuote"
returnvariable="Quote">
<cfinvokeargument name="Quote_ID" value="200"/>
</cfinvoke>

It's important to note that within my application.cfm I am setting up my
quoteDAO and quoteGateway objects within my variables scope. I am then setting
my quoteService in my application scope, like so:


<cfset variables.quoteDAO =
createObject("component","apps.webservices.quote.quoteDAO").init(variables.dsn)
/>
<cfset variables.quoteGateway =
createObject("component","apps.webservices.quote.quoteGateway").init(variables.d
sn) />

<cfset application.quoteService =
createObject("component","apps.webservices.quote.quoteService").init(variables.q
uoteDAO, variables.quoteGateway) />


I'm not sure what exactly the error I am receiving is, but part of me cringes
thinking it might have to do with pathing.

Any advice?


From: Stressed_Simon on
Your CFC is instantiated in application scope however when you call it via a
web service it actually creates a new instance on every request so none of your
internal variables initialised in your init() function will not exist. To get
round this you need to create a wrapper cfc that accesses your cfc in
application scope

eg cfreturn application.quoteService.getQuote(arguments.quoteID)

I hope that makes sense?

From: blastbeat on
Simon,

Thanks for your reply - I modified the code to manually setup those objects in
my init like so.

<cfset variables.dsn = "mydsn" />
<cfset variables.quoteDAO =
createObject("component","apps.webservices.quote.quoteDAO").init(variables.dsn)
/>
<cfset variables.quoteGateway =
createObject("component","apps.webservices.quote.quoteGateway").init(variables.d
sn) />

It solved that initial error but now I am getting:

Could not perform web service invocation "getQuote".
Here is the fault returned when invoking the web service operation:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Premature end of file.
faultActor:
faultNode:

Any ideas?


From: blastbeat on
I began recoding my entire service and was graced by the god which is Sean
Corfield and he immediately pointed out that webservices cannot return null
values.

One of my queries is returning null columns, which it is supposed to given the
way the database is setup.

Sure enough when I return the entire bean with values in each element it
works, but if one is null it gives me the premature end of file error. Ugg. So
now I am faced with how to handle this. I thought I would follow up just incase
anyone else is battling the premature end of file problem.