6 Replies Latest reply on Mar 13, 2008 2:55 AM by MyNickSG

    error while invoking webservice

    MyNickSG
      i am trying to use webservice (by using data->import wsdl). I am sending request (invoking web method by using classes generated after imporing wsdl).

      Here is the code i m trying.

      public function getCompanyInfoById(companyId:String):void
      {
      var wsNML:CampaignSettings =new CampaignSettings();
      wsNML.addgetCompanyInfoByIdEventListener(getCompanyInfo);
      //wsNML.addCampaignSettingsFaultEventListener(faultHandler);
      wsNML.getCompanyInfoById(companyId);

      }

      private function getCompanyInfo(e:GetCompanyInfoByIdResultEvent):void
      {
      var companyInfo:ArrayOfCampaignSettingsCDO=new ArrayOfCampaignSettingsCDO();
      companyInfo=e.result;
      companyInfo.removeItemAt(0);
      //logic continues....
      }


      the same code is working fine for my other web methods(for my another web services). Also the same is working fine when i use the same web service in some other project. but when i use this webservice in my original project, its not working. its throwing the following error:


      "ReferenceError: Error #1065: Variable ArrayOfCampaignSettingsCDO is not defined.
      at global/flash.utils::getDefinitionByName()
      at mx.rpc.xml::SchemaTypeRegistry/getCollectionClass()[E:\dev\flex_3_beta3\sdk\frameworks\pr ojects\rpc\src\mx\rpc\xml\SchemaTypeRegistry.as:106]
      at mx.rpc.xml::XMLDecoder/createContent()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc\sr c\mx\rpc\xml\XMLDecoder.as:1830]
      at mx.rpc.xml::XMLDecoder/decode()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc\src\mx\rp c\xml\XMLDecoder.as:168]
      at mx.rpc.soap::SOAPDecoder/decodeBody()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc\src \mx\rpc\soap\SOAPDecoder.as:439]
      at mx.rpc.soap::SOAPDecoder/decodeEnvelope()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc \src\mx\rpc\soap\SOAPDecoder.as:291]
      at mx.rpc.soap::SOAPDecoder/decodeResponse()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc \src\mx\rpc\soap\SOAPDecoder.as:223]
      at generated.webservices::BaseCampaignSettings/processResult()[D:\Projects\NML2008\wsdl\gene rated\webservices\BaseCampaignSettings.as:411]
      at mx.rpc::AsyncResponder/result()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc\src\mx\rp c\AsyncResponder.as:73]
      at mx.rpc::AsyncRequest/acknowledge()[E:\dev\flex_3_beta3\sdk\frameworks\projects\rpc\src\mx \rpc\AsyncRequest.as:81]
      at DirectHTTPMessageResponder/completeHandler()[E:\dev\flex_3_beta3\sdk\frameworks\projects\ rpc\src\mx\messaging\channels\DirectHTTPChannel.as:387]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/onComplete()"

      Please help me out.
        • 1. Re: error while invoking webservice
          kcell Level 2
          Hi,

          The error occure in decoder, which means the XMLDecoder can not find any definitions for "ArrayOfCampaignSettingsCDO". The questions is why. From your post I can't even guess where "ArrayOfCampaignSettingsCDO" is defined.

          What you can do:
          - Check "ArrayOfCampaignSettingsCDO"definition in the used wsdl and all child variable defintions from "ArrayOfCampaignSettingsCDO" (or post the wsdl definition if you have problems with it )

          Some other suggestions:
          - Try to use the released flex 3 sdk (and not the beta 3 )
          - The result handler can look like this:
          private function getCompanyInfo(e:GetCompanyInfoByIdResultEvent):void
          {
          if ( e.result is ArrayOfCampaignSettingsCDO)
          {
          var companyInfo:ArrayOfCampaignSettingsCDO= e.result as ArrayOfCampaignSettingsCDO;
          companyInfo.removeItemAt(0);
          //logic continues....
          }
          }
          - Another question: why you use a temp CampaignSettings variable in the getCompanyInfoById function?
          Doesn´t it make sense to have the CampaignSettings variable as member variable of the class (or as global member of the app if you didn't use classes )


          best regards,
          kcell
          • 2. Re: error while invoking webservice
            MyNickSG Level 1
            hi kcell, thanks 4 ur help.

            here is the wsdl:

            <?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/" xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s=" http://www.w3.org/2001/XMLSchema" xmlns:soap=" http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12=" http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm=" http://microsoft.com/wsdl/mime/textMatching/" xmlns:tns=" http://tempuri.org/" targetNamespace=""> http://tempuri.org/">
            <wsdl:types>
            <s:schema elementFormDefault="qualified" targetNamespace=""> http://tempuri.org/">
            <s:element name="GetCompanyInfoById">
            <s:complexType>
            <s:sequence>
            <s:element maxOccurs="1" minOccurs="0" name="companyId" type="s:string"/>
            </s:sequence>
            </s:complexType>
            </s:element>
            <s:element name="GetCompanyInfoByIdResponse">
            <s:complexType>
            <s:sequence>
            <s:element maxOccurs="1" minOccurs="0" name="GetCompanyInfoByIdResult" type="tns:ArrayOfCampaignSettingsCDO"/>
            </s:sequence>
            </s:complexType>
            </s:element>
            <s:complexType name="ArrayOfCampaignSettingsCDO">
            <s:sequence>
            <s:element maxOccurs="unbounded" minOccurs="0" name="CampaignSettingsCDO" nillable="true" type="tns:CampaignSettingsCDO"/>
            </s:sequence>
            </s:complexType>
            <s:complexType name="CampaignSettingsCDO">
            <s:sequence>
            <s:element maxOccurs="1" minOccurs="0" name="companyId" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="companyName" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="companyAddress1" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="companyAddress2" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="companyCity" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="companyState" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="companyZip" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="companyWebAddress" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="userId" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="salutation" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="firstName" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="lastName" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="title" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="workPhone" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="email" type="s:string"/>
            <s:element maxOccurs="1" minOccurs="0" name="password" type="s:string"/>
            </s:sequence>
            </s:complexType>
            </wsdl:types>
            <wsdl:message name="GetCompanyInfoByIdSoapIn">
            <wsdl:part element="tns:GetCompanyInfoById" name="parameters">
            </wsdl:part>
            </wsdl:message>
            <wsdl:message name="GetCompanyInfoByIdSoapOut">
            <wsdl:part element="tns:GetCompanyInfoByIdResponse" name="parameters">
            </wsdl:part>
            </wsdl:message>
            <wsdl:operation name="GetCompanyInfoById">
            <wsdl:input message="tns:GetCompanyInfoByIdSoapIn">
            </wsdl:input>
            <wsdl:output message="tns:GetCompanyInfoByIdSoapOut">
            </wsdl:output>
            </wsdl:operation>
            </wsdl:portType>
            <wsdl:binding name="CampaignSettingsSoap12" type="tns:CampaignSettingsSoap">
            <soap12:binding transport=""> http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="GetCompanyInfoById">
            <soap12:operation soapAction=" http://tempuri.org/GetCompanyInfoById" style="document"/>
            <wsdl:input>
            <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
            <soap12:body use="literal"/>
            </wsdl:output>
            </wsdl:operation>
            <wsdl:operation name="GetCompanyInfoById">
            <soap:operation soapAction=" http://tempuri.org/GetCompanyInfoById" style="document"/>
            <wsdl:input>
            <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
            <soap:body use="literal"/>
            </wsdl:output>
            </wsdl:operation>
            </wsdl:binding>
            <wsdl:service name="CampaignSettings">
            <wsdl:port binding="tns:CampaignSettingsSoap12" name="CampaignSettingsSoap12">
            <soap12:address location=""> http://localhost/NML/CampaignSettings.asmx"/>
            </wsdl:port>
            <wsdl:port binding="tns:CampaignSettingsSoap" name="CampaignSettingsSoap">
            <soap:address location=""> http://localhost/NML/CampaignSettings.asmx"/>
            </wsdl:port>
            </wsdl:service>
            </wsdl:definitions>

            regarding "Another question: why you use a temp CampaignSettings variable in the getCompanyInfoById function?
            Doesn´t it make sense to have the CampaignSettings variable as member variable of the class (or as global member of the app if you didn't use classes )" :

            i am using the object of my webservice (object of the class generated after importing WSDL) to invoke the webmethod.
            Is there any other way for calling the webmethods.??

            Also, the same code is working fine if i import the same webservice in some other project, while its throwing the error in this project.

            Regards,
            Shaveta
            • 3. Re: error while invoking webservice
              kcell Level 2
              Hi Shaveta,

              first to my question ;)

              I think its just another approach if you would use something like:

              var m_wsNML:CampaignSettings ;

              // this function is called only once on client startup (after creation complete event )
              public function initWebService():void
              {
              m_wsNML=new CampaignSettings();
              }

              public function getCompanyInfoById(companyId:String):void
              {
              m_wsNML.addgetCompanyInfoByIdEventListener(getCompanyInfo);
              //wsNML.addCampaignSettingsFaultEventListener(faultHandler);
              m_wsNML.getCompanyInfoById(companyId);
              }

              This code didn't instantiate everytime a webservice class object.

              But back to your problem:

              The WSDL look fine so far.

              Its very strange that the same call have worked before in another app.
              ( might the returned data be the problem ?)

              Have you use <tracetarget> to get more infos about the returned data? I think the returned soap message is placed in the output window when u use <tracetarget> and start the app in the debugger.

              best regards,
              kcell
              • 4. Re: error while invoking webservice
                MyNickSG Level 1
                yes i got that way..thanks..

                n regarding d problem...yes its working fine in another app. problem in returned data? (i have checked the result, result is fine when i invoke the same my another app.)

                i hav used debugger, its showing the same error. Please help me out.

                Regards,
                shaveta
                • 5. Re: error while invoking webservice
                  kcell Level 2
                  Hi,

                  googelt error# 1065:

                  compiler removed include
                  -> It would be interesting to know if the described solution fixed your problem

                  public class definition is missing ?
                  -> This solution would be strange, because it would mean that the class ArrayOfCampaignSettingsCDO is missing the public definition.

                  I don´t know how I can help you, the information you have posted looks fine.


                  kcell
                  • 6. Re: error while invoking webservice
                    MyNickSG Level 1
                    ohh..yeah i hav already googled it..but didn get any solution :(


                    Regards,
                    Shaveta