4 Replies Latest reply on Feb 27, 2010 6:34 AM by BKBK

    Simple Web Service fails

    Al Baker

      This one is clearly me doing something stupid.

       

      in c:\inetpub\wwwroot I have these two files:

       

      DropShip.cfc

      ------------------

      <cfcomponent>
        <cffunction name="NewOrder" returnType="string" access="remote" output="false">
          <cfargument name="Version" type="string" required="yes">
          <cfreturn "Ack">
        </cffunction>
      </cfcomponent>

      TestShip.cfm

      ------------------

      <cfinvoke 
        webservice = "http://localhost/DropShip.cfc?WSDL"
        method = "NewOrder"
        timeout="10"
        returnVariable = "request.WebOrder">
        <cfinvokeargument name="Version" value="1.0" />
        </cfinvoke>
      <cfoutput>[#request.WebOrder#]</cfoutput>

       

      and the result I get back is:

       

      Web service operation NewOrder with parameters {Version={1.0}} cannot be found.

       

      If I remove the <cfargument> and <cfinvokeargument> it works.

       

      So what silly thing am I doing wrong?  Pile on, I can take it!

        • 1. Re: Simple Web Service fails
          insuractive Level 3

          2 things to check -

           

          1) Pull up the WSDL in the browser that make sure the methods and arguments listed there are what you expect.

           

          2) If you make changes to your web service, you need to open up the CF administrator, navigate to the Web Services section and hit the refresh icon next to your DropShop.cfc?wsdl entry.  CF server doesn't automatically detect when a web service's interface has changed. I suspect that may be what's going on with your problem here.

          • 2. Re: Simple Web Service fails
            Al Baker Level 1

            Refreshing the Web Service in Admin worked perfectly.

             

            That leads to another problem-- the developers do not have access to CF Admin, so they cannot do a refresh when they make changes.

             

            I suspect that this is a problem that I will have to learn to live with.  Too bad the invokation of a web service is tied to CFAdmin.  Seems like a bad idea, but then I probably don't understand all the ramifications.  Wouldn't be the first time!

             

            Thanks!

            • 3. Re: Simple Web Service fails
              GrandNagel Level 1

              Not sure where I found this but I think its designed to accomplish what you're after...

               

              hth,

               

              D.

               

              <cfcomponent displayname="BaseWebService" output="false" hint="This handles core web service features.">

               

                  <cffunction name="Init" access="public" returntype="any" output="false" hint="Returns an initialized web service instance.">

                      <cfreturn THIS />

                  </cffunction>

               

                  <cffunction name="RebuildStubFile" access="remote" returntype="void" output="false" hint="Rebuilds the WSDL file at the given url.">

                      <cfargument name="Password" type="string" required="true" />

                      <cfif NOT Compare( ARGUMENTS.Password, "sweetlegs!" )>

                          <cfset CreateObject

                                  (

                                      "java",

                                      "coldfusion.server.ServiceFactory"

                                  ).XmlRpcService.RefreshWebService

                                      (

                                          GetPageContext().GetRequest().GetRequestUrl().Append( "?wsdl" ).ToString()

                                      )

                          />

                      </cfif>

                      <cfreturn />

                  </cffunction>

               

              </cfcomponent>

               

               

               

              AND then to use it ...

               

               

              <cfcomponent displayname="Essence_WebServices" output="false" hint="Interactivity is handled exclusively in this CFC." extends="BaseWebService">

                  <cffunction name="RebuildStubFile" access="remote" returntype="void" output="false" hint="Returns an initialized web service instance.">

                      <CFSet super.RebuildStubFile('sweetlegs!') />

                  </cffunction>

              </CFComponent>

               

              Message was edited by: GrandNagel

              • 4. Re: Simple Web Service fails
                BKBK Adobe Community Professional & MVP

                Al Baker wrote:

                 

                Refreshing the Web Service in Admin worked perfectly.

                 

                That leads to another problem-- the developers do not have access to CF Admin, so they cannot do a refresh when they make changes.

                 

                I suspect that this is a problem that I will have to learn to live with.  Too bad the invokation of a web service is tied to CFAdmin.  Seems like a bad idea, but then I probably don't understand all the ramifications.  Wouldn't be the first time!

                 

                 

                Nil desperandum. This will refresh the web service programmatically:

                 

                <cfobject action="create" type="java" name="serviceFactory" class="coldfusion.server.ServiceFactory"> 
                <cfset rpcService = serviceFactory.XmlRpcService>
                <cfset rpcService.refreshWebService("http://localhost/DropShip.cfc?wsdl")>

                ws refreshed!