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

web service wsdl problem

New Here ,
Mar 23, 2012 Mar 23, 2012

I have a very simple web service cfc file that uses another cfc component in the returntype. Both cfc files are on the same directory in the server. It fails to register (wsdl) on the CF server. If I change the returntype of the web service call to "any" it would work. Anyone has any idea? Below is the code:

----------

authentication_wsapi.cfc

    <cfcomponent>

      <cffunction name="getManagers"

              access="remote"

              returntype="User"

              output="no">

            <cfobject component="User" name="ret">

            <cfreturn ret>

      </cffunction>

    </cfcomponent>

-----------

User.cfc

    <cfcomponent>

      <cfproperty name="loginName" type="string">

    </cfcomponent>

-----------

url to test:

http://wsapi.my.com/authentication_wsapi.cfc?wsdl

-----------

Error I got:

AXIS error

Sorry, something seems to have gone wrong... here are the details:

Exception - java.lang.NoClassDefFoundError: user

java.lang.NoClassDefFoundError: user

    at java.lang.Class.getDeclaredMethods0(Native Method)

    at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)

    at java.lang.Class.getDeclaredMethod(Class.java:1935)

    at org.apache.axis.description.JavaServiceDesc.loadServiceDescByIntrospection(JavaServiceDesc.java:863)

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

If I modify authentication_wsapi.cfc as below (only difference is the returntype) it will work:

        <cfcomponent>

      <cffunction name="getManagers"

              access="remote"

              returntype="any"                        <----- changed from "User" to "any"

              output="no">

            <cfobject component="User" name="ret">

            <cfreturn ret>

      </cffunction>

    </cfcomponent>

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

It seems authentication_wsapi.cfc can not see the User.cfc on the same dir. BUT the "cfobject" call to create the User component is not complaining though. Any help will be apprecriated!

2.1K
Translate
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
Community Expert ,
Mar 23, 2012 Mar 23, 2012

It could be because the function definition doesn't yet know what the type User is (given that this is defined later within the function). Does this do any better:

<cfcomponent>

     <cfobject component="User" name="ret">

      <cffunction name="getManagers"

              access="remote"

              returntype="User"

              output="no">       

            <cfreturn ret>

      </cffunction>

    </cfcomponent>

Translate
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 ,
Mar 23, 2012 Mar 23, 2012

Hi BKBK, I tried it and it didn't work. Same error.

Also I would like it to create the object only when the function is called (there will be many other functions in the file) so I prefer it to be inside the function - if it ever works

Translate
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
Community Expert ,
Mar 23, 2012 Mar 23, 2012

Your CF version?

Added update: I ask because I know for sure that ColdFusion versions since MX 6.1 may use the attribute returntype="component_name" in the cffunction tag.

Translate
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
Community Expert ,
Mar 23, 2012 Mar 23, 2012

guosam wrote:

Hi BKBK, I tried it and it didn't work. Same error.

Also I would like it to create the object only when the function is called (there will be many other functions in the file) so I prefer it to be inside the function - if it ever works

What if you give the dotted path of the CFC from the web root, like this

returntype="wsTest.cfc.User"

This one assumes the path to User.cfc is something like c:\ColdFusion9\wwwroot\wsTest\cfc\User.cfc

Added update: Ignore the above. I got the feeling later I might be searching too far.

The error message suggests that ColdFusion should already have a copy of the class corresponding to the User CFC, but doesn't. I cannot remember such a requirement from the docs (please jog my memory if you do).

Which brings me to a test. Create a CFM page with the following line of code, to get ColdFusion to create the class:

<cfobject component="User" name="testUser">

Done creating.

Then run your original web service test.

Translate
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 ,
Mar 25, 2012 Mar 25, 2012

bkbk,

I tried as you suggested and found some interesting things, but problem still exists...

I created the test.cfm page as you suggested:

test.cfm

<cftry>

<cfobject component="User" name="testUser">

<cfobject component="authentication_wsapi" name="wsapi">

<cfcatch type="any">

   <cfdump var="#cfcatch#">

   <cfabort>

</cfcatch>

</cftry>

Done creating.

and hit it at url:

http://wsapi.my.com/test.cfm

There was no error, it shows "Done creating.".

Just to make sure, I modified my authentication_wsapi.cfc to be:

authentication_wsapi.cfc

    <cfcomponent>

      <cffunction name="getManagers"

              access="remote"

              returntype="User_non_exist"

              output="no">

            <cfobject component="User_non_exist" name="ret">

            <cfreturn ret>

      </cffunction>

    </cfcomponent>

and hit it with the test.cfm url, still no error. Strange!

So I modified test.cfm like this:

test.cfm

<cftry>

<cfobject component="User" name="testUser">

<cfobject component="authentication_wsapi" name="wsapi">

<cfset a = wsapi.getManagers()>

<cfcatch type="any">

   <cfdump var="#cfcatch#">

   <cfabort>

</cfcatch>

</cftry>

Done creating.

Now I see an error complaining the User_non_exist component not exist.

So I changed the authentication_wsapi.cfc back to it's correct form, and with the new test.cfm, and hit the url, there was no error.

Now I hit the wsdl url, it still gave me the original error.

I think the wsdl compiler or some sort in CF server can not see the component inside the authentication_wsapi.cfc.

I am using Coldfusion 9, 64 bit, enterprise version, on a Windows server 2008, with IIS 6.0.

In the IIS web site I defined the "physical path" (is this the web root?) to

   C:\Savvi\Websites\CCD\WSAPI

and both .cfc exist in

   C:\Savvi\Websites\CCD\WSAPI

There are several other web sites co-exist in the same server, with different "physical path". I do not have a "/" mapping defined in the CF server.

Translate
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
Community Expert ,
Mar 25, 2012 Mar 25, 2012
LATEST

That was much too complicated for me. I was thinking of a simpler test, as follows:

test.cfm

<cftry>

<cfobject component="User" name="testUser">

Done creating.

<cfcatch type="any">

   <cfdump var="#cfcatch#">

   <cfabort>

</cfcatch>

</cftry>

authentication_wsapi.cfc

    <cfcomponent>

      <cffunction name="getManagers"

              access="remote"

              returntype="User"

              output="no">

            <cfobject component="User" name="ret">

            <cfreturn ret>

      </cffunction>

    </cfcomponent>

Translate
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