2 Replies Latest reply on May 7, 2009 6:41 AM by golgot666

    1067: Implicit coercion of a value of type String to an unrelated type

    golgot666

      Hi,

       

      I created a webservice based on sql server 2005 with several methods successfully.

       

      I am having headach now just trying to do some simple tests with Flex :-(

       

      I used the "Import WebService", it created some code "generated webservices".

       

      My test method p_SEARCH_NAME_SOUNDEX is based on a sql procedure wich take a varchar (128) as a parameter => NAL_NOM.

       

      I am just trying to debug this function (error at line in red)

       

             public function searchEntry(name:String):void
              {
                  // Register the event listener for the findEntry operation.
                  //agenda.addfindEntryEventListener(handleSearchResult);
                  myWS.addp_SEARCH_NAME_SOUNDEXEventListener(handleSearchResult);
                 
                 
                  // Call the operation if we have a valid name.
                  if(name!= null && name.length > 0)

                     myWS.p_SEARCH_NAME_SOUNDEX(name);

              }

       

      I got this error message:

       

      067: Implicit coercion of a value of type String to an unrelated type generated.webservices:NAL_NOM_type1.

       

      FLEX has creaetd a type called NAL_NOM_type1 for my class:

       

      /**
      * NAL_NOM_type1.as
      * This file was auto-generated from WSDL by the Apache Axis2 generator modified by Adobe
      * Any change made to this file will be overwritten when the code is re-generated.
      */


      package generated.webservices
      {
          import mx.utils.ObjectProxy;
          import flash.utils.ByteArray;
          import mx.rpc.soap.types.*;
          /**
           * Wrapper class for a operation required type
           */
         
          public class NAL_NOM_type1
          {
              /**
               * Constructor, initializes the type class
               */
              public function NAL_NOM_type1() {}
                 
              public var varchar:String;public function toString():String
              {
                  return varchar.toString();
              }
                        
          }
      }

       

      I tried to do myWS.p_SEARCH_NAME_SOUNDEX(NAL_NOM_type1(name));

       

      and also declared "name" as NAL_NOM_type1... but i still get this error.

       

      This is how it declared my webservice method:

       

              public function p_SEARCH_NAME_SOUNDEX(nAL_NOM:NAL_NOM_type1):AsyncToken
              {
                   var _internal_token:AsyncToken = _baseService.p_SEARCH_NAME_SOUNDEX(nAL_NOM);
                  _internal_token.addEventListener("result",_P_SEARCH_NAME_SOUNDEX_populate_results);
                  _internal_token.addEventListener("fault",throwFault);
                  return _internal_token;
              }

       

      I am even not on the level of assigning the data to my grid... i just want to see how it gets the data first in debug.

       

      Thanks in advance for you help.

      kr,

      Meta

        • 1. Re: 1067: Implicit coercion of a value of type String to an unrelated type
          _Natasha_ Level 4

          Hi Meta,

          function p_SEARCH_NAME_SOUNDEX(nAL_NOM:NAL_NOM_type1) need one parameter with type NAL_NOM_type1.

          you call

          myWS.p_SEARCH_NAME_SOUNDEX(name); // where name is string

           

          You can change constuctor to get String parameter

          public function NAL_NOM_type1(str:String = "") {

               varchar = str;

          }

           

          After that call myWS.p_SEARCH_NAME_SOUNDEX(new NAL_NOM_type1(name));

           

          The second variant is to create variable NAL_NOM_type1, save name to varchar.

           

          var t = new NAL_NOM_type1();

          t.varchar = name;

          myWS.p_SEARCH_NAME_SOUNDEX(t);

          • 2. Re: 1067: Implicit coercion of a value of type String to an unrelated type
            golgot666 Level 1

            Thanks _Natasha_

             

            I tried this:

             

            var t = new NAL_NOM_type1();

            t.varchar = name;

            myWS.p_SEARCH_NAME_SOUNDEX(t);

             

            It passes the 1st step :-) but I get another error now :-/

             

            I think it try to get back NAL_NOM_type1 from the server of course on the WSDL side it know only NAL_NOM

             

            Error: Cannot find definition for type 'http://NABSQL64DEV/::NAL_NOM_type1'
                at mx.rpc.xml::XMLEncoder/encodeType()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc \xml\XMLEncoder.as:1426]

            ...

             

            I guess I have to change my constructor type... i am not used to these stuff :-s

             

            is this generating method the best way to access your data with webservices?

             

            the turorials I saw are xml file or array based... is there any link similar to my issue so I can learn better?