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

Accesing Form and Request variables in cfc

New Here ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Hi,
I have a cfc published as a webservice. I have insert statements in the cfcs
which uses form and request variables. When I invoke the component, I get an error form
variable is not defined. Am I missing something?.

Thanks all for your time.

TOPICS
Advanced techniques

Views

1.2K

Translate

Translate

Report

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
Explorer ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Did you put access="remote"? Please put your code of cfc and calling page to review for variable name and other things to better help you.

Votes

Translate

Translate

Report

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
LEGEND ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Your are submitting your form to the page that invokes that cfc. The cfc knows of no such form. Anything it needs, you must pass to it as an argument.

Votes

Translate

Translate

Report

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
LEGEND ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Dan Bracuk wrote:
> Your are submitting your form to the page that invokes that cfc. The cfc knows of no such form. Anything it needs, you must pass to it as an argument.

And if you use a cfc method as the action of a form, that is done
automatically. All the form fields become arguments of the method and
you would access them as such.

I.E. form.myField becomes arguments.myField inside the CFC method.

Votes

Translate

Translate

Report

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
New Here ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

Hi,
Thank you for the response, I guess I can't use form or request variables. I think I have to parse and return response back as a return value and do my inserts. Below is my code, the variables are defined in the page where I am invoking the webservice.

<!---Function Invoked--->
<cfinvoke
webservice="ws_ReviewSheet"
method="ReviewWS"
returnvariable="response">
</cfinvoke>

<!---cfc Code--->
<cfcomponent>
<cffunction name="ReviewWS" returnType="Struct" output="false" access="remote">
<cfset response_XML = XmlParse("\\ServerName\XMLDocuments\Review10.xml")>

<cfset NoOfPeople = ArrayLen(XmlSearch(response_XML,"/p1:ReviewReport/p3:Person"))>

<cftransaction action="BEGIN">
<cftry>

<cfloop from="1" to="#ListLen(NoOfPeople)#" index="i">
<cfmodule template="#Form.FileLoc#/review_ins.cfm"
review_no="#Form.review_no#"
user_add="#Request.user_add#"
source_add="#Request.source_add#"
seq_no="#i#">
<cfset response.count = i>
</cfloop>
<cfcatch>
<cftransaction action="ROLLBACK"/>
<cfrethrow>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>


Message : Could not perform web service invocation "ReviewWS".

Detail : 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 user_add is undefined in REQUEST.]
faultActor:
faultNode:
faultDetail:
{ http://xml.apache.org/axis/}stackTrace:coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.UndefinedElementException : Element user_add is undefined in REQUEST.]
at coldfusion.xml.rpc.CFComponentSkeleton.__createCFCInvocationException(CFComponentSkeleton.java:717)
at coldfusion.xml.rpc.CFComponentSkeleton.__invoke(CFComponentSkeleton.java:663)
at ReviewWs.ReviewWS(C:\Inetpub\wwwroot\ReviewWs.cfc)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method....

Votes

Translate

Translate

Report

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
LEGEND ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

No, you need to uses arguments and pass in the form values you want to use.

Something like this.

<cfinvoke webservice="ws_ReviewSheet"
method="ReviewWS"
argumentCollection="#form#"
returnVariable="response">
</cfinvoke>

<!--- CFC Code --->
<cfcomponent>
<cffunction name="ReviwWS"...>
...
<cfmodule template="#arguments.FileLoc#"/review_ins.cfm"...
...
</cfcomponent>

cfchick12 wrote:
> Hi,
> Thank you for the response, I guess I can't use form or request variables. I
> think I have to parse and return response back as a return value and do my
> inserts. Below is my code, the variables are defined in the page where I am
> invoking the webservice.
>
> <!---Function Invoked--->
> <cfinvoke
> webservice="ws_ReviewSheet"
> method="ReviewWS"
> returnvariable="response">
> </cfinvoke>
>
> <!---cfc Code--->
> <cfcomponent>
> <cffunction name="ReviewWS" returnType="Struct" output="false"
> access="remote">
> <cfset response_XML = XmlParse("\\ServerName\XMLDocuments\Review10.xml")>
>
> <cfset NoOfPeople =
> ArrayLen(XmlSearch(response_XML,"/p1:ReviewReport/p3:Person"))>
>
> <cftransaction action="BEGIN">
> <cftry>
>
> <cfloop from="1" to="#ListLen(NoOfPeople)#" index="i">
> <cfmodule template="#Form.FileLoc#/review_ins.cfm"
> review_no="#Form.review_no#"
> user_add="#Request.user_add#"
> source_add="#Request.source_add#"
> seq_no="#i#">
> <cfset response.count = i>
> </cfloop>
> <cfcatch>
> <cftransaction action="ROLLBACK"/>
> <cfrethrow>
> </cfcatch>
> </cftry>
> </cffunction>
> </cfcomponent>
>
>
> Message : Could not perform web service invocation "ReviewWS".
>
> Detail : 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 user_add is undefined
> in REQUEST.]
> faultActor:
> faultNode:
> faultDetail:
>
> { http://xml.apache.org/axis/}stackTrace:coldfusion.xml.rpc.CFCInvocationExcepti
> on: [coldfusion.runtime.UndefinedElementException : Element user_add is
> undefined in REQUEST.]
> at
> coldfusion.xml.rpc.CFComponentSkeleton.__createCFCInvocationException(CFComponen
> tSkeleton.java:717)
> at
> coldfusion.xml.rpc.CFComponentSkeleton.__invoke(CFComponentSkeleton.java:663)
> at ReviewWs.ReviewWS(C:\Inetpub\wwwroot\ReviewWs.cfc)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
> a:25)
> at java.lang.reflect.Method.invoke(Method....
>
>
>

Votes

Translate

Translate

Report

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
New Here ,
Feb 21, 2008 Feb 21, 2008

Copy link to clipboard

Copied

LATEST
I think, I need Form, Request and Session variables. The tags which I am using are all common tags, which are used through out the application. So changing it to "Arguments." just for this scenario is a pain. I have pasted only a tiny bit of the code. I have lots of cfmodules and cfincludes which again uses the form and request variables. Thanks for your valuable suggestions/comments.

Votes

Translate

Translate

Report

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
Documentation