Skip to main content
March 14, 2008
Question

Create Soap webservice

  • March 14, 2008
  • 11 replies
  • 2185 views
Is there any example available for soap in coldfusion? So i can invoke soap to cfc webservice.

This topic has been closed for replies.

11 replies

April 9, 2008
how to make this webservice secure.
BKBK
Community Expert
Community Expert
March 21, 2008
Nick201 wrote:
How can I call my simple wsdl in ASP. I would like to test it.

I think it's at this point that I would thank Ian Skinner for his help, his patience and the skillful way in which he has explained the web service concepts. I would then end there.



Inspiring
March 17, 2008
Nick201 wrote:
> could you please give me one working example of array or struc with query. I
> also would like to know how to output.
>
> here is my code.
>
> Since this function declare as array so this cfc should work with other
> programs. such as Java, . Net etc right?

That's the idea. An array is a more universally implemented variable
type, thus it is supposedly more portable across disparate environments.

You have the right idea on how to loop over a query and create it as a
two-dimension array. To output you just have to go old school and write
your own iteration loops to handle it. Something along these lines:

<cfoutput>
<cfloop from="1" to="#arrayLen(detailInfo)#" index="foo">
<cfloop from="1" to="#arrayLen(detailInfo[foo])#" index="bar">
#detailInfo[foo][bar]#<br/>
</cfloop>
<hr/>
</cfloop>
March 17, 2008
I am getting this error with webservice.. If i used componets i am not seeing any problems. Any idea thanks.


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

java.lang.NullPointerException


The error occurred in /var/www/html/tarang/qarray1.cfm: line 3

1 :
2 : <cfinvoke webservice=" http://catburg/qqarray.cfc?wsdl" method="aMethod"
3 : returnvariable="detailInfo">
4 : </cfinvoke>
5 :


<cfcomponent>
<cffunction name="aMethod" returntype="array" access="remote" output="false">

<cfquery name="returnQry" dataSource="test">
SELECT first_name,last_name
FROM emp where first_name='Danny'
</cfquery>

<cfset myarray=arraynew(2)>


<cfloop query="returnQry">
<cfset myarray[CurrentRow][1]=first_name>
<cfset myarray[CurrentRow][2]=last_name>
</cfloop>
<cfreturn myarray>
</cffunction>
</cfcomponent>

Call webservice
-------------------------------------------------

<cfinvoke webservice=" http://catburg/qqarray.cfc?wsdl" method="aMethod"
returnvariable="detailInfo">
</cfinvoke>


<cfoutput>
<cfloop from="1" to="#arrayLen(detailInfo)#" index="foo">
<cfloop from="1" to="#arrayLen(detailInfo[foo])#" index="bar">
#detailInfo[foo][bar]#<br/>
</cfloop>
<hr/>
</cfloop>
</cfoutput>

March 17, 2008
could you please give me one working example of array or struc with query. I also would like to know how to output.

here is my code.

Since this function declare as array so this cfc should work with other programs. such as Java, . Net etc right?

<cfcomponent>
<cffunction name="aMethod" returntype="array" access="remote" output="false">
<cfargument name="first_name" type="string" required="yes">

<cfquery name="returnQry" dataSource="test">
SELECT top 10 first_name,last_name
FROM emp where first_name='#ARGUMENTS.first_name#'
</cfquery>

<cfset myarray=arraynew(2)>

<!--- Populate the array row by row --->
<cfloop query="returnQry">
<cfset myarray[CurrentRow][1]=first_name>
<cfset myarray[CurrentRow][2]=last_name>
</cfloop>


<cfreturn myarray>
</cffunction>
</cfcomponent>



<cfinvoke webservice=" http://catburg/array.cfc?wsdl" method="aMethod"
returnvariable="detailinfo">
<cfinvokeargument name="first_name" value="viki"/>
</cfinvoke>

<cfdump var="#detailinfo#">
Inspiring
March 17, 2008
Nick201 wrote:
> Thanks,
>
> You mean function return type query will cause problem. If I call this WSDL in .NET.

It might. I do not know for sure from personal experience. But I
understand that 'query' means somewhat different things to different
languages.

>
> Coluld you please give me example of basic complex type such a structure or array in webservice.
>


<cffunction name="anArray" returnType="array" access="remote"
output="false">

<cfset var returnVal = arrayNew(1)>

<cfset returnVal[1] = "something">

<cfreturn returnVal>
</cffuntion>


<cffunction name="aStruct" returnType="struct" access="remote"
output="false">

<cfset var returnVal = structNew()>

<cfset returnVal["aKey"] = "something">

<cfreturn returnVal>
</cffuntion>

If this is required, it is fairly easy to loop over a query and rebuild
it as either a set of nested arrays and|or structures.
March 17, 2008
Thanks,

You mean function return type query will cause problem. If I call this WSDL in .NET.

Coluld you please give me example of basic complex type such a structure or array in webservice.
Inspiring
March 17, 2008
Nick201 wrote:
> I have created cfc in my test server and I am calling cfc from my local machine (coldfusion server)

What do you get if you put the URI " http://catburg/test.cfc?wsdl" into
browser? Do you get the WSDL file? Or perhaps some connection error?
There maybe permissions problems and this should show it up.

> Also Do you have any example of basic complex type such a structure or array.

<cfset basicAry = arrayNew(1)>
<cfset basicAry[1] = "something">

<cfset basicStruct = structNew()>
<cfset basicStruct["aKey"] = "something else">

March 17, 2008
I have created cfc in my test server and I am calling cfc from my local machine (coldfusion server)

Also Do you have any example of basic complex type such a structure or array.


Inspiring
March 14, 2008
Nick201 wrote:
> SO I someone request a DATA using my WSDL query then will get result set back right


That's the idea, sort of, more or less.

They request data using the 'web service' you build. Which ColdFusion
make rather painless --- usually. But when it is not painless it can be
quite frustrating.

The WSDL "Web Service Definition Language" is what tells anybody trying
to use your web service what is its API. I.E. What are the methods,
what arguments do these methods need and what do they return.
ColdFusion generates this file automatically when you designate at least
one method in a CFC as "access='remote'" and thus a web service.

So "WSDL query" is not a phrase that makes much sense.

March 14, 2008
Is there any example of query invoke webservice. Thanks
March 14, 2008
SO I someone request a DATA using my WSDL query then will get result set back right