9 Replies Latest reply on Sep 3, 2009 9:45 AM by Flex harUI

    multiple soap modules

    pseudoDust

      hello,

      i'm biulding a flex client that works with a soap web servise, i imported the wsdl though the wizard and all was good...

      untill i had to use a diffrent module within the same webService.

      the other module uses some of the same soap types as the first one(the type's name space is maped to the first module) and vice versa.

      as a resoult when i try to import the secound module i get the following error:

       

      The specified ActionScript package already contains a file with the same name
      as one of the classes to be generated: <some class name>.as.
      Try choosing a different ActionScript package or renaming the existing file.

       

      so naturaly i used a diffrent package, now the problem is that now i have duplicates of the same class in diffrent pakages and one module is overwriting the class deffenitions of the other module in the SchemaTypeRegistry singleton and that is cousing all kinds of weird stuff to happen...

       

      has anyone encounterd this or know how to solve this?

       

      any help would be greatly appreciated.

       

      peleg.

        • 1. Re: multiple soap modules
          Flex harUI Adobe Employee

          Put the shared classes in the main app or in a shared code module.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: multiple soap modules
            pseudoDust Level 1

            thanks for the reply,

            i'm not sure i understand your answer, i don't have access to the webservice code, so if you're refuring to changes in the webservice i'm afeared this doesn't solve my problem.

            if you mean refactoring the generated classes in flex, i'm trying to avoide that becaus then i would have to redo that work every time i update the wsdl.

             

            thanks again.

             

            peleg.

            • 3. Re: multiple soap modules
              Flex harUI Adobe Employee

              I haven't looked at the generated soap classes, but I thought they had known class names roughly matching the soap name.  You don't have to touch the generated code, simply list each class in the main app or shared code module like

               

              Import somePackage.SomeSoapClass;

              Public var someSoapClass:SomeSoapClass; SomeSoapClass;

               

               

              If the WSDL adds new classes, you'll need to catch that and update the list though.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: multiple soap modules
                pseudoDust Level 1

                the problem happens solely within the generated code and the mx.rpc package,

                the problam is that i have somePackage.SomeSoapClass and someOtherPackage.SomeSoapClass.

                say i have 2 soap moduls MySoap1 and MySoap2

                MySoap1 has a protocol MySoapRequest and the response type MySoapResponse witch are bouth defined within the MySoap1 namespace(the soap name space not mxml namespase)

                MySoap2 has another protocol AnotherSoapRequest that uses the same response type i.e. MySoapRespons(witch maped to the MySoap1 namespace)

                i then import the two moduls into diffrent package paths in my project(using the wsdl import wizard), i get the following calsses(among others):

                com.MySoap1.MySoap1Modul

                com.MySoap1.MySoapRequest

                com.MySoap1.MySoapResponse

                com.MySoap2.MySoap2Modul

                com.MySoap2.AnotherSoapRequest

                com.MySoap2.MySoapResponse

                when i send an AnotherSoapRequest request and get the result the mx.rpc.soap.SOAPDecoder interprets the soap response as com.MySoap1.MySoapResponse but sice it was requested though com.MySoap2.MySoap2Modul it's being cast to com.MySoap2.MySoapResponse, an operation that results in null...

                 

                sorry if i didnt' clarify that before.

                 

                thanks,

                 

                peleg.

                • 5. Re: multiple soap modules
                  Flex harUI Adobe Employee

                  I’m not sure I understand.  If both modules are hitting the same wsdl, you may need to import that wsdl into the main app or a separate shared code module so that both modules can share the same class definitions.  If each module hits its own wsdl, and the soap response is using different xml namespaces for the different classes in the wsdl, then I don't get how module1 ended up in module2's soap decoder.

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

                  Blog: http://blogs.adobe.com/aharui

                  • 6. Re: multiple soap modules
                    pseudoDust Level 1

                    here are examples for the 2 wsdl's:

                    module 1:

                     

                    <wsdl:definitions xmlns:tns="http://ns1.something.com/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s2="http://ns2.something.com/" targetNamespace="http://ns1.something.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
                        <wsdl:types>
                            <s:schema elementFormDefault="qualified" targetNamespace="http://ns1.something.com/">
                                <s:import namespace="http://ns2.something.com/" />
                                <s:element name="someSOAPElement">
                                    ...
                                </s:element>
                                <s:element name="someSOAPElementResponse">
                                    <s:complexType>
                                        <s:sequence>
                                            <s:element minOccurs="0" maxOccurs="1" name="someSOAPElementResult" type="s2:BillingResponse" />
                                        </s:sequence>
                                    </s:complexType>
                                </s:element>
                                <s:element name="someSOAPType" nillable="true" type="s2:someSOAPType" />
                            </s:schema>
                            <s:schema elementFormDefault="qualified" targetNamespace="http://ns2.something.com/">
                                <s:complexType name="someSOAPType">
                                    ...
                                </s:complexType>
                            </s:schema>
                        </wsdl:types>
                        <wsdl:message name="someSOAPElementSoapIn">
                            <wsdl:part name="parameters" element="tns:someSOAPElement" />
                        </wsdl:message>
                        <wsdl:message name="someSOAPElementSoapOut">
                            <wsdl:part name="parameters" element="tns:someSOAPElementResponse" />
                        </wsdl:message>
                    </wsdl:definitions>

                     

                    and module 2:

                     

                    <wsdl:definitions xmlns:tns="http://ns2.something.com/" xmlns:s="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns2.something.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
                      <wsdl:types>
                        <s:schema elementFormDefault="qualified" targetNamespace="http://ns2.something.com/">
                          <s:complexType name="someSOAPType">
                            ...
                          </s:complexType>
                          <s:element name="someSOAPElement">
                            ...
                          </s:element>
                          <s:element name="someSOAPElementResponse">
                            <s:complexType>
                              <s:sequence>
                                <s:element name="someSOAPElementResult" type="tns:someSOAPType" />
                              </s:sequence>
                            </s:complexType>
                          </s:element>
                          <s:element name="someSOAPType" nillable="true" type="tns:someSOAPType" />
                        </s:schema>
                      </wsdl:types>
                      <wsdl:message name="someSOAPElementSoapIn">
                        <wsdl:part name="parameters" element="tns:someSOAPElement" />
                      </wsdl:message>
                      <wsdl:message name="someSOAPElementSoapOut">
                        <wsdl:part name="parameters" element="tns:someSOAPElementResponse" />
                      </wsdl:message>
                    </wsdl:definitions>

                     

                    the soap decoder uses mx.rpc.xml.SchemaTypeRegistry, witch is singleton, to map the soap types calss definitions, thus the definitions are shared by all the modules in the application...

                    • 7. Re: multiple soap modules
                      Flex harUI Adobe Employee

                      What classes got generated?  What is their package name and schema registry name?

                       

                      Alex Harui

                      Flex SDK Developer

                      Adobe Systems Inc.

                      Blog: http://blogs.adobe.com/aharui

                      • 8. Re: multiple soap modules
                        pseudoDust Level 1

                        well, i cant import the two moduls into the same package since thay bouth try to generate the "someSOAPType" class, so i import them into two different packages, say com.m1 and com.m2

                        so the folowing classes are generated(among others):

                        com.m1.M1Module

                        com.m1.baseM1Module

                        com.m1.someSOAPType

                        com.m2.M2Module

                        com.m2.baseM2Module

                        com.m2.someSOAPType

                         

                        in com.m1.baseM1Module you'll find this line:

                         

                        SchemaTypeRegistry.getInstance().registerClass(new QName("http://ns2.something.com/","someSOAPType"),com.m1.someSOAPType);

                         

                        and in com.m2.baseM2Module you'll find this line:

                         

                        SchemaTypeRegistry.getInstance().registerClass(new QName("http://ns2.something.com/","someSOAPType"),com.m2.someSOAPType);

                         

                        and so one mapping overrides the other, in com.m1.baseM1Module you'l allso find:

                         

                        import com.m1.someSOAPType;

                        and

                        e.result = event.result as someSOAPType;

                        but event.result is of type com.m2.someSOAPType, and thus e.result will be null(i'm not even sure why...)

                        • 9. Re: multiple soap modules
                          Flex harUI Adobe Employee

                          I think you may have to tweak your projects to share a central definition of someSoapType, then make sure someSoapType ends up in the main app or a shared code module.

                           

                          Alex Harui

                          Flex SDK Developer

                          Adobe Systems Inc.

                          Blog: http://blogs.adobe.com/aharui