9 Replies Latest reply on Oct 3, 2007 9:40 AM by BitPail

    Can't get web service to work

    BitPail Level 1
      I'm getting the following error when trying to invoke an ASP.NET web service on the same host...

      TypeError: Error #1034: Type Coercion failed: cannot convert Function-2010 to Namespace.
      at mx.rpc.wsdl::WSDL/::processNamespaces()
      at mx.rpc.wsdl::WSDL$iinit()
      at mx.rpc.wsdl::WSDLLoader/mx.rpc.wsdl:WSDLLoader::resultHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
      at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()
      at mx.rpc::Responder/result()
      at mx.rpc::AsyncRequest/acknowledge()
      at ::DirectHTTPMessageResponder/completeHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/flash.net:URLLoader::onComplete()

      I'm using http://localhost/Hello/Service1.asmx?WSDL as the wsdl and it works when I navigate to it with the browser.

      Any help would be very appreciated.
      Thanks
        • 1. Re: Can't get web service to work
          BitPail Level 1
          Anyone here?
          • 2. Re: Can't get web service to work
            batmitra Level 1
            hi
            are you using .net 1 or 2?

            i ask this because flex can't handle .net 1 webservices easily , you must have your webservices returning objects , i think, although i haven't try it yet , flex doesn't have problems with asp.net 2
            • 3. Re: Can't get web service to work
              ntsiii Level 3
              Are you committed to WebService? I use HTTPService with ASP.NET and it is very simple, fast and reliable.

              You really only need SOAP -based web service if you plan to make your service available to anonymous third parties and need the method discovery functionality provided by the wsdl.

              Tracy
              • 4. Re: Can't get web service to work
                kcell Level 2
                Hi,

                We are using a flex client who connects to a asp.net 2 webservice.

                Please post an example how you have tried to invoke the webservice function and also post the wsdl.

                Does the error "TypeError: Error #1034: Type Coercion failed: cannot convert Function-2010 to Namespace."
                match to something in your wsdl.

                Have you already tried to call a webservice function from Flex with a helloworld example (Its up to some minutes to build a helloworld webservice in asp.net 2).

                best regards,
                kcell
                • 5. Re: Can't get web service to work
                  BitPail Level 1
                  Sorry for the late response, I wasn't able to access the forums for awhile there.

                  I'm using .NET 2.0

                  Yes I have tried a hello world example. I have a very basic ASP webservice:

                  using System;
                  using System.Data;
                  using System.Web;
                  using System.Collections;
                  using System.Web.Services;
                  using System.Web.Services.Protocols;
                  using System.ComponentModel;

                  namespace Hello
                  {
                  /// <summary>
                  /// Summary description for Service1
                  /// </summary>
                  [WebServiceBinding( ConformsTo = WsiProfiles.BasicProfile1_1 )]
                  [ToolboxItem( false )]
                  public class Service1 : System.Web.Services.WebService
                  {

                  [WebMethod]
                  public string UpdateResponses()
                  {
                  return "Hello World";
                  }
                  }
                  }

                  My flex code is this:

                  private function doWebService():void
                  {
                  var service:WebService = new WebService();
                  service.loadWSDL(" http://localhost/Hello/Service1.asmx?WSDL");
                  service.addEventListener(ResultEvent.RESULT, success);
                  service.addEventListener(FaultEvent.FAULT, fault);
                  service.UpdateResponses();
                  }

                  This works for me, however as soon as I take the flex code into my real project, I can't access the same ASP webservice.

                  Here is the WSDL

                  <?xml version="1.0" encoding="utf-8" ?>
                  - <wsdl:definitions xmlns:soap=" http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm=" http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns=" http://tempuri.org/" xmlns:s=" http://www.w3.org/2001/XMLSchema" xmlns:soap12=" http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/" targetNamespace=" http://tempuri.org/" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/">
                  - <wsdl:types>
                  - <s:schema elementFormDefault="qualified" targetNamespace=" http://tempuri.org/">
                  - <s:element name="UpdateResponses">
                  <s:complexType />
                  </s:element>
                  - <s:element name="UpdateResponsesResponse">
                  - <s:complexType>
                  - <s:sequence>
                  <s:element minOccurs="0" maxOccurs="1" name="UpdateResponsesResult" type="s:string" />
                  </s:sequence>
                  </s:complexType>
                  </s:element>
                  </s:schema>
                  </wsdl:types>
                  - <wsdl:message name="UpdateResponsesSoapIn">
                  <wsdl:part name="parameters" element="tns:UpdateResponses" />
                  </wsdl:message>
                  - <wsdl:message name="UpdateResponsesSoapOut">
                  <wsdl:part name="parameters" element="tns:UpdateResponsesResponse" />
                  </wsdl:message>
                  - <wsdl:portType name="Service1Soap">
                  - <wsdl:operation name="UpdateResponses">
                  <wsdl:input message="tns:UpdateResponsesSoapIn" />
                  <wsdl:output message="tns:UpdateResponsesSoapOut" />
                  </wsdl:operation>
                  </wsdl:portType>
                  - <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
                  <soap:binding transport=" http://schemas.xmlsoap.org/soap/http" />
                  - <wsdl:operation name="UpdateResponses">
                  <soap:operation soapAction=" http://tempuri.org/UpdateResponses" style="document" />
                  - <wsdl:input>
                  <soap:body use="literal" />
                  </wsdl:input>
                  - <wsdl:output>
                  <soap:body use="literal" />
                  </wsdl:output>
                  </wsdl:operation>
                  </wsdl:binding>
                  - <wsdl:binding name="Service1Soap12" type="tns:Service1Soap">
                  <soap12:binding transport=" http://schemas.xmlsoap.org/soap/http" />
                  - <wsdl:operation name="UpdateResponses">
                  <soap12:operation soapAction=" http://tempuri.org/UpdateResponses" style="document" />
                  - <wsdl:input>
                  <soap12:body use="literal" />
                  </wsdl:input>
                  - <wsdl:output>
                  <soap12:body use="literal" />
                  </wsdl:output>
                  </wsdl:operation>
                  </wsdl:binding>
                  - <wsdl:service name="Service1">
                  - <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
                  <soap:address location=" http://localhost/Hello/Service1.asmx" />
                  </wsdl:port>
                  - <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12">
                  <soap12:address location=" http://localhost/Hello/Service1.asmx" />
                  </wsdl:port>
                  </wsdl:service>
                  </wsdl:definitions>
                  • 6. Re: Can't get web service to work
                    kittuokkade Level 1
                    Dont u have portnumber in address
                    • 7. Re: Can't get web service to work
                      BitPail Level 1
                      No I didn't have a port, the service must have been using the default port 80, but it did work in my test application. I changed my webservice to use a specific port with the following URL http://localhost:1860/Service1.asmx, again it worked in my test application but fails with the same error in my real application.
                      • 8. Re: Can't get web service to work
                        BitPail Level 1
                        Ah...a little progress here...

                        After getting completely frustrated with this problem, I started commenting out everything in my real program, except a button that calls the web service and it worked. So I started slowly uncommenting things checking the web service each time I uncommented something. I found that as soon as I accessed a method in an ActionScript file in another package, the error occurred. Here is the package structure:

                        FlexProjectFolder
                        companyName
                        flex
                        application
                        Config.as
                        common
                        Tools.as
                        MainApp.mxml

                        I'm finding that as soon as I access a method in the Tools.as file from the MainApp.mxml the error occurs. However, if I can still access the Config.as without errors occurring.

                        I would like to maintain this structure, how do I access these files without causing the error. Does anyone have any idea why this is occurring?

                        • 9. Re: Can't get web service to work
                          BitPail Level 1
                          Got it...finally!

                          In my Tools.as file I had a static method called Split(Array,delimiter). I added this because I didn't like the stock implementation of String.Split....ie you get nothing if the delimiter isn't found in the string, I wanted an array with a single element in it, the original string.

                          Anyways....there must have been a naming conflict with the Split method in the SDK because as soon as I changed the name of the method to SplitMeUp it worked and I no longer got the error when loading the WSDL.