23 Replies Latest reply on Apr 9, 2008 11:09 AM by Nick201

    Create Soap webservice

    Nick201
      Is there any example available for soap in coldfusion? So i can invoke soap to cfc webservice.

        • 1. Re: Create Soap webservice
          Level 7
          Nick201 wrote:
          > Is there any example available for soap in coldfusion? So i can invoke soap to cfc webservice.
          >
          >

          Other then creating a CFC method with an 'access="remote"' parameter as
          described in the documentation available on the internet and elsewhere?

          http://livedocs.adobe.com/coldfusion/8/htmldocs/webservices_17.html

          • 2. Re: Create Soap webservice
            Nick201 Level 1
            Then what is soap.. Is it possible to access this test.cfc?wsdl in php or java. Can I call that. What is useful for soap. why people using soap
            • 3. Re: Create Soap webservice
              Level 7
              Nick201 wrote:
              > Then what is soap..

              "Simple Object Access Protocol" originally, but now just "SOAP"
              http://en.wikipedia.org/wiki/SOAP

              > Is it possible to access this test.cfc?wsdl in php or java. C

              Yes. The nice thing about ColdFusion is by simply adding
              "access='remote' to a CFC function (aka method) ColdFusion
              auto-magically builds the required SOAP WSDL interface. Just point
              anybody who wants to consume your web service to uri (i.e.
              'test.cfc?wsdl' and they should be off and running.

              > What is useful for soap. why people using soap

              To exchange data across this new fangled thing called the 'internets'.


              • 4. Re: Create Soap webservice
                Nick201 Level 1
                SO I someone request a DATA using my WSDL query then will get result set back right
                • 5. Re: Create Soap webservice
                  Level 7
                  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.

                  • 6. Re: Create Soap webservice
                    Nick201 Level 1
                    Is there any example of query invoke webservice. Thanks
                    • 7. Re: Create Soap webservice
                      Level 7
                      Nick201 wrote:
                      > Is there any example of query invoke webservice. Thanks


                      I'm not sure what type of an example you want. English seems to be a
                      bit of a barrier here.

                      But a simple method that returns a query.

                      <cfcomponent>
                      <cffunction name="aMethod" returnType="query" access="remote"
                      output="false">
                      <cfset var returnQry = "">

                      <cfquery name="returnQry" dataSource="aDSN">
                      SELECT aField
                      FROM aTable
                      </cfquery>

                      <cfreturn returnqry>
                      </cffunction>
                      </cfcomponent>
                      • 8. Re: Create Soap webservice
                        Nick201 Level 1
                        I am running this issue here. I am getting this error message when I passed argument.

                        Web service operation "aMethod" with parameters {first_name={John}} could not be found.
                        Any idea thanks.

                        <cfcomponent>
                        <cffunction name="aMethod" returnType="query" access="remote" output="false">
                        <cfargument name="first_name" type="string" required="yes">
                        <cfquery name="returnQry" dataSource="abc">
                        SELECT first_name
                        FROM empwhere first_name='#ARGUMENTS.first_name#'
                        </cfquery>
                        <cfreturn returnqry>
                        </cffunction>
                        </cfcomponent>

                        <cfinvoke webservice=" http://catburg/test.cfc?wsdl" method="aMethod"
                        returnvariable="detailinfo">
                        <cfinvokeargument name="first_name" value="John">
                        </cfinvoke>
                        <cfdump var="#detailinfo#">
                        • 9. Re: Create Soap webservice
                          Level 7
                          Nick201 wrote:
                          > I am running this issue here. I am getting this error message when I passed
                          > argument.
                          >
                          > Web service operation "aMethod" with parameters {first_name={John}} could not
                          > be found.
                          > Any idea thanks.


                          You may need to 'refresh' the web service in the ColdFusion
                          Administrator. ColdFusion caches the signature of a web service and it
                          must be refreshed if the signature changes.

                          A signature of a web service is it's URI, the names and return types of
                          the remote methods as well as the names and types of any arguments
                          passed to these methods.

                          If you created the method without the argument, for example; tested the
                          code; then added the argument - you would need to refresh the web
                          service in the Administrator.

                          • 10. Re: Create Soap webservice
                            Nick201 Level 1
                            Thanks. It works internally ok. But if i am calling from other server I am getting this error message. Any idea

                            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.xml.rpc.SkeletonClassLoader$UnresolvedCFCDataTypeException : Could not resolve CFC datatype:
                            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.xml.rpc.SkeletonClassLoader$UnresolvedCFCDataTypeException : Could not resolve CFC datatype:
                            faultActor:
                            faultNode:
                            • 11. Re: Create Soap webservice
                              Level 7
                              Nick201 wrote:
                              > Thanks. It works internally ok. But if i am calling from other server I am
                              > getting this error message. Any idea
                              >

                              What is the other server running?

                              If it is not ColdFusion, you may have trouble with a query return type.
                              Unfortunately a record set is not a universally implemented from
                              language to language. You may have to transfer a more basic complex
                              type such a structure or array.
                              • 12. Re: Create Soap webservice
                                Nick201 Level 1
                                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.


                                • 13. Re: Create Soap webservice
                                  Level 7
                                  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">

                                  • 14. Re: Create Soap webservice
                                    Nick201 Level 1
                                    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.
                                    • 15. Re: Create Soap webservice
                                      Level 7
                                      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.
                                      • 16. Re: Create Soap webservice
                                        Nick201 Level 1
                                        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#">
                                        • 17. Re: Create Soap webservice
                                          Level 7
                                          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>
                                          • 18. Re: Create Soap webservice
                                            Nick201 Level 1
                                            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>

                                            • 19. Re: Create Soap webservice
                                              Level 7
                                              Nick201 wrote:
                                              > 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

                                              Sorry, I don't see any obvious errors. The only advice I can give you
                                              at this moment is to 'var' scope all your internal variables. The 'var'
                                              scope is local to a single method and thus the variables will not clash
                                              with similarly named variables in the in other methods or the global
                                              'variables' scope.

                                              <cffunction name="aMethod" returntype="array" access="remote"
                                              output="false">
                                              <!--- Initialize local function variables. --->
                                              <cfset var returnQry = "">
                                              <cfset var myarray = "">
                                              ...
                                              • 20. Re: Create Soap webservice
                                                Level 7
                                                Nick201 wrote:
                                                > 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

                                                You have confirmed that putting the uri
                                                " http://catburg/qqarray.cfc?wsdl" into a browser return the expected
                                                WSDL file, correct?
                                                • 21. Re: Create Soap webservice
                                                  Nick201 Level 1
                                                  How can I call my simple wsdl in ASP. I would like to test it.

                                                  CFC I have only simple query.

                                                  select firstname from emp

                                                  thanks
                                                  • 22. Re: Create Soap webservice
                                                    BKBK Adobe Community Professional & MVP
                                                    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.



                                                    • 23. Re: Create Soap webservice
                                                      Nick201 Level 1
                                                      how to make this webservice secure.