1 2 Previous Next 19 Replies Latest reply on Feb 27, 2009 4:49 PM by tereus

    can't force SOAPClient to generate correct SOAP

    tereus

      Hi there,
      I have a problem with SOAPClient. I use it to call a WebService, but the generated SOAP body doesn't contain the object graph I want it to contain.
      First, a piece of WSDL:

      <xs:element name="sendDRO" type="tns:sendDRO"/>
      <xs:element name="sendDROResponse" type="tns:sendDROResponse"/>
      <xs:complexType name="sendDRO">
      <xs:sequence>
      <xs:element minOccurs="0" name="dro" type="tns:dro"/>
      </xs:sequence>
      </xs:complexType>
      <xs:complexType name="dro">
      <xs:sequence>
      <xs:element maxOccurs="unbounded" minOccurs="0" name="dane" nillable="true" type="tns:odbiorca"/>
      <xs:element minOccurs="0" name="dataDo" type="xs:dateTime"/>
      <xs:element minOccurs="0" name="dataOd" type="xs:dateTime"/>
      </xs:sequence>
      


      sendDRO is an operation i want to use. The "dro" type is my own class, as this WebService is mine, deployed on tomcat from web.xml.

      Now I want to send a WS message containing this DRO object (which matches wsdl's dro type perfectly, as it was generated automatically from DRO type).
      The question is : how should I attach the DRO object? I tried two ways:

      1. the dro type.

      public Message prepareDRO(Message msg) {
       Map<String,Object> map = new HashMap<String, Object>();
       map.put("sendDRO.dro", ((DRO)msg.getBody().get(WSFacade.PAYLOAD_NAME)));
       msg.getBody().add(map);
       return msg;
      }
      

      Here i tried to name this object "dro" insted of "sendDRO.dro" as well.

      2. Generate wrapper class sendDRO (matching WSDL type) and do something like:

      public Message prepareDRO(Message msg) {
       Map<String,Object> map = new HashMap<String, Object>();
       map.put("sendDRO", new SendDRO(((DRO)msg.getBody().get(WSFacade.PAYLOAD_NAME))));
       msg.getBody().add(map);
       return msg;
      }
      
      


      For all those cases, the SOAP msg which SOAPClient was sending to WS was the same:
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="http://webservice_producer/testingwsfacade">
       <soapenv:Header/>
       <soapenv:Body>
       <tes:sendDRO>
       <!--Zero or more repetitions: - cloned-->
      
       </tes:sendDRO>
       </soapenv:Body>
      </soapenv:Envelope>
      


      And, ofcourse, inside WS method the "dro" param was null.

      Can anybody tell me what am I doing wrong?

      Thanks

        • 1. Re: can't force SOAPClient to generate correct SOAP
          tfennelly

          What version of the ESB are you using and which SOAPClient action are you using (sorry.... there are 2 depending on the version of the ESB you're using)?

          If you're using the soapUI SOAPClient, take a look at section titled "Transforming the SOAP Request" on SOAPClient wiki page (last section). Not sure if the WISE based soap client supports something similar. Stefano?

          • 2. Re: can't force SOAPClient to generate correct SOAP
            tereus

            I'm using JBOSSESB 4.4 (build revision 23343), and SOAPClient org.jboss.soa.esb.actions.soap.SOAPClient from 4.4 version.

            I've read the document You have pasted, and as You can see, the ognl map i provide seems to be correct. I don't think I have to do some additional transformations in smooks, because (as I said) the object I'm sending is the same from which the WebService's WSDL was generated. Maybe I don't understand something about OGNL? I don't have any other idea how should i construct the OGNL map.

            Thanks

            • 3. Re: can't force SOAPClient to generate correct SOAP
              tfennelly

              OK... can you use a soapUI client, load up the wsdl and generate a request template for the operation. Looking at the code too, it looks like you can get it to dump the SOAP template at different stages in it's lifecycle by adding a "dumpSOAP" parameter (any value) to the parameter Map.

              • 4. Re: can't force SOAPClient to generate correct SOAP
                tereus

                Ok, I can generate SOAP, but I can't compare it to the one which SOAPClient produces, as it's empty [pasted in my first post]. Moreover, don't You think it should work 'out of the box'? The object to serialize is the one on which WSDL was generated!

                • 5. Re: can't force SOAPClient to generate correct SOAP
                  tfennelly

                   

                  "tereus" wrote:
                  Ok, I can generate SOAP, but I can't compare it to the one which SOAPClient produces, as it's empty [pasted in my first post].


                  What you posted in your first post is the *final* SOAP message. I asked you to post in the original (unmodified) SOAP template as generated by soapUI, or output to the console after adding the "dumpSOAP" parameter to the parameter Map.

                  "tereus" wrote:
                  Moreover, don't You think it should work 'out of the box'?


                  What's your point? Maybe there is a bug, or maybe you're using it incorrectly 'out of the box'! Do you want help from this forum, or are you just looking to have a bitch??

                  • 6. Re: can't force SOAPClient to generate correct SOAP
                    tereus

                     

                    I asked you to post in the original (unmodified) SOAP template as generated by soapUI


                    soapUI -> new Project -> import WSDL -> create sample request for all operations [checked]

                    sample soap:
                    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tes="http://webservice_producer/testingwsfacade">
                     <soapenv:Header/>
                     <soapenv:Body>
                     <tes:sendDRO>
                     <!--Optional:-->
                     <dro>
                     <!--Zero or more repetitions:-->
                     <dane>
                     <!--Optional:-->
                     <kod>?</kod>
                     <!--Optional:-->
                     <kodZewnetrzny>?</kodZewnetrzny>
                     <!--Optional:-->
                     <umowa>
                     <!--Optional:-->
                     <kod>?</kod>
                     <!--Zero or more repetitions:-->
                     <przylacza>
                     <!--Optional:-->
                     <kod>?</kod>
                     <!--Optional:-->
                     <kodNadrzedne>?</kodNadrzedne>
                     <!--Optional:-->
                     <kodPPE>?</kodPPE>
                     <!--Zero or more repetitions:-->
                     <moce>
                     <!--Optional:-->
                     <kierunek>?</kierunek>
                     <!--Optional:-->
                     <maksymalna>
                     <!--Optional:-->
                     <dtCzas>?</dtCzas>
                     <!--Optional:-->
                     <sezon>?</sezon>
                     <!--Optional:-->
                     <wartosc>?</wartosc>
                     </maksymalna>
                     <!--Optional:-->
                     <przekroczenie>
                     <!--Optional:-->
                     <nadwyzka>
                     <!--Optional:-->
                     <ilosc>?</ilosc>
                     <!--Optional:-->
                     <wartosc>?</wartosc>
                     </nadwyzka>
                     <!--Zero or more repetitions:-->
                     <wartosci>
                     <!--Optional:-->
                     <dtCzas>?</dtCzas>
                     <!--Optional:-->
                     <sezon>?</sezon>
                     <!--Optional:-->
                     <wartosc>?</wartosc>
                     </wartosci>
                     </przekroczenie>
                     <!--Optional:-->
                     <umowna>?</umowna>
                     <!--Optional:-->
                     <urzadzenie>?</urzadzenie>
                     <!--Optional:-->
                     <wielkosc>?</wielkosc>
                     </moce>
                     <!--Zero or more repetitions:-->
                     <pomiary>
                     <!--Optional:-->
                     <jednostka>?</jednostka>
                     <!--Optional:-->
                     <kanal>?</kanal>
                     <!--Optional:-->
                     <kierunek>?</kierunek>
                     <!--Optional:-->
                     <mnozna>?</mnozna>
                     <!--Zero or more repetitions:-->
                     <rozliczenia>
                     <!--Optional:-->
                     <kodStrefy>?</kodStrefy>
                     <!--Optional:-->
                     <wartosc>?</wartosc>
                     <!--Optional:-->
                     <wskazanieDo>
                     <!--Optional:-->
                     <dtCzas>?</dtCzas>
                     <!--Optional:-->
                     <wartosc>?</wartosc>
                     </wskazanieDo>
                     <!--Optional:-->
                     <wskazanieOd>
                     <!--Optional:-->
                     <dtCzas>?</dtCzas>
                     <!--Optional:-->
                     <wartosc>?</wartosc>
                     </wskazanieOd>
                     </rozliczenia>
                     <!--Optional:-->
                     <typUrzadzenia>?</typUrzadzenia>
                     <!--Optional:-->
                     <urzadzenie>?</urzadzenie>
                     <!--Optional:-->
                     <wielkosc>?</wielkosc>
                     </pomiary>
                     <!--Optional:-->
                     <taryfa>?</taryfa>
                     </przylacza>
                     </umowa>
                     </dane>
                     <!--Optional:-->
                     <dataDo>?</dataDo>
                     <!--Optional:-->
                     <dataOd>?</dataOd>
                     </dro>
                     </tes:sendDRO>
                     </soapenv:Body>
                    </soapenv:Envelope>
                    

                    And the SOAP correctly models the object [DRO].


                    Do you want help from this forum, or are you just looking to have a bitch??


                    Definitely, it's all about a nice bitch.

                    • 7. Re: can't force SOAPClient to generate correct SOAP
                      tereus

                      Hi,
                      No one knows correct solution ? I don't believe it doesn't exist.

                      • 8. Re: can't force SOAPClient to generate correct SOAP
                        beve

                        Hi,

                        could you also post the action configuration from jboss-esb.xml for the SOAPClient ?

                        Thanks,

                        /Daniel

                        • 9. Re: can't force SOAPClient to generate correct SOAP
                          tereus

                          Ofcourse,
                          thanks for reply

                          Here it is:

                          <service category="WSClient" name="zapiszDROWSClient" >
                           <listeners>
                           <jms-listener name="zapiszDROWSClient_queue"
                           busidref="zapiszDROWSClient_queue">
                           </jms-listener>
                           </listeners>
                           <actions>
                           <action name="getDRO" process="getDRO"
                           class="com.winuel.energy.soa.esb.actions.DroActions"/>
                           <action name="prepareDRO" process="prepareDRO"
                           class="com.winuel.energy.soa.esb.actions.DroActions"/>
                           <action name="WSClient"
                           class="org.jboss.soa.esb.actions.soap.SOAPClient">
                           <property name="wsdl"
                           value="http://10.7.23.44:8082/ZEORK_SOA-0.1.0/FacadeTest?wsdl" />
                           <property name="responseAsOgnlMap" value="true" />
                           <property name="SOAPAction" value="sendDRO"/>
                           </action>
                           </actions>
                           </service>
                          


                          Those two actions (getDRO, prepareDRO) does, respectively, get DRO object from database (smooks from stream), and prepares ognl map (i posted it earlier).

                          Cheers


                          • 10. Re: can't force SOAPClient to generate correct SOAP
                            beve

                            Thanks!

                            Can I have the wsdl as well? :)

                            Thanks,

                            /Daniel

                            • 11. Re: can't force SOAPClient to generate correct SOAP
                              tereus

                              Ofcourse ! Here it is:

                              <definitions name='TestingWSFacadeServiceService' targetNamespace='http://webservice_producer/testingwsfacade' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/testingwsfacade' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
                               <types>
                               <xs:schema targetNamespace='http://webservice_producer/testingwsfacade' version='1.0' xmlns:tns='http://webservice_producer/testingwsfacade' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
                               <xs:element name='returnSome' type='tns:returnSome'/>
                               <xs:element name='returnSomeResponse' type='tns:returnSomeResponse'/>
                               <xs:element name='sendDRO' type='tns:sendDRO'/>
                               <xs:element name='sendDROResponse' type='tns:sendDROResponse'/>
                               <xs:complexType name='sendDRO'>
                               <xs:sequence>
                              
                               <xs:element minOccurs='0' name='dro' type='tns:dro'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='dro'>
                               <xs:sequence>
                               <xs:element maxOccurs='unbounded' minOccurs='0' name='dane' nillable='true' type='tns:odbiorca'/>
                               <xs:element minOccurs='0' name='dataDo' type='xs:dateTime'/>
                               <xs:element minOccurs='0' name='dataOd' type='xs:dateTime'/>
                               </xs:sequence>
                              
                               </xs:complexType>
                               <xs:complexType name='odbiorca'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='kod' type='xs:string'/>
                               <xs:element minOccurs='0' name='kodZewnetrzny' type='xs:string'/>
                               <xs:element minOccurs='0' name='umowa' type='tns:umowa'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='umowa'>
                              
                               <xs:sequence>
                               <xs:element minOccurs='0' name='kod' type='xs:string'/>
                               <xs:element maxOccurs='unbounded' minOccurs='0' name='przylacza' nillable='true' type='tns:przylacze'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='przylacze'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='kod' type='xs:string'/>
                               <xs:element minOccurs='0' name='kodNadrzedne' type='xs:string'/>
                              
                               <xs:element minOccurs='0' name='kodPPE' type='xs:string'/>
                               <xs:element maxOccurs='unbounded' minOccurs='0' name='moce' nillable='true' type='tns:moc'/>
                               <xs:element maxOccurs='unbounded' minOccurs='0' name='pomiary' nillable='true' type='tns:pomiar'/>
                               <xs:element minOccurs='0' name='taryfa' type='xs:string'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='moc'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='kierunek' type='xs:string'/>
                              
                               <xs:element minOccurs='0' name='maksymalna' type='tns:mocMaksymalna'/>
                               <xs:element minOccurs='0' name='przekroczenie' type='tns:przekroczenie'/>
                               <xs:element minOccurs='0' name='umowna' type='xs:double'/>
                               <xs:element minOccurs='0' name='urzadzenie' type='xs:string'/>
                               <xs:element minOccurs='0' name='wielkosc' type='xs:string'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='mocMaksymalna'>
                               <xs:sequence>
                              
                               <xs:element minOccurs='0' name='dtCzas' type='xs:dateTime'/>
                               <xs:element minOccurs='0' name='sezon' type='xs:string'/>
                               <xs:element minOccurs='0' name='wartosc' type='xs:double'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='przekroczenie'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='nadwyzka' type='tns:nadwyzka'/>
                               <xs:element maxOccurs='unbounded' minOccurs='0' name='wartosci' nillable='true' type='tns:wartoscMocy'/>
                              
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='nadwyzka'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='ilosc' type='xs:double'/>
                               <xs:element minOccurs='0' name='wartosc' type='xs:double'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='wartoscMocy'>
                              
                               <xs:sequence>
                               <xs:element minOccurs='0' name='dtCzas' type='xs:dateTime'/>
                               <xs:element minOccurs='0' name='sezon' type='xs:string'/>
                               <xs:element minOccurs='0' name='wartosc' type='xs:double'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='pomiar'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='jednostka' type='xs:string'/>
                              
                               <xs:element minOccurs='0' name='kanal' type='xs:string'/>
                               <xs:element minOccurs='0' name='kierunek' type='xs:string'/>
                               <xs:element minOccurs='0' name='mnozna' type='xs:string'/>
                               <xs:element maxOccurs='unbounded' minOccurs='0' name='rozliczenia' nillable='true' type='tns:rozliczenie'/>
                               <xs:element minOccurs='0' name='typUrzadzenia' type='xs:string'/>
                               <xs:element minOccurs='0' name='urzadzenie' type='xs:string'/>
                               <xs:element minOccurs='0' name='wielkosc' type='xs:string'/>
                               </xs:sequence>
                               </xs:complexType>
                              
                               <xs:complexType name='rozliczenie'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='kodStrefy' type='xs:string'/>
                               <xs:element minOccurs='0' name='wartosc' type='xs:double'/>
                               <xs:element minOccurs='0' name='wskazanieDo' type='tns:wskazanie'/>
                               <xs:element minOccurs='0' name='wskazanieOd' type='tns:wskazanie'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='wskazanie'>
                              
                               <xs:sequence>
                               <xs:element minOccurs='0' name='dtCzas' type='xs:dateTime'/>
                               <xs:element minOccurs='0' name='wartosc' type='xs:double'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='sendDROResponse'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='return' type='xs:string'/>
                               </xs:sequence>
                              
                               </xs:complexType>
                               <xs:complexType name='returnSome'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='person' type='tns:person'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='person'>
                               <xs:sequence>
                               <xs:element name='age' type='xs:double'/>
                              
                               <xs:element minOccurs='0' name='born' type='xs:dateTime'/>
                               <xs:element minOccurs='0' name='name' type='xs:string'/>
                               <xs:element minOccurs='0' name='surname' type='xs:string'/>
                               <xs:element minOccurs='0' name='works' type='tns:company'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='company'>
                               <xs:sequence>
                               <xs:element maxOccurs='unbounded' minOccurs='0' name='employees' nillable='true' type='tns:person'/>
                              
                               <xs:element minOccurs='0' name='name' type='xs:string'/>
                               </xs:sequence>
                               </xs:complexType>
                               <xs:complexType name='returnSomeResponse'>
                               <xs:sequence>
                               <xs:element minOccurs='0' name='return' type='tns:person'/>
                               </xs:sequence>
                               </xs:complexType>
                               </xs:schema>
                              
                               </types>
                               <message name='TestingWSFacadeService_returnSomeResponse'>
                               <part element='tns:returnSomeResponse' name='returnSomeResponse'></part>
                               </message>
                               <message name='TestingWSFacadeService_sendDRO'>
                               <part element='tns:sendDRO' name='sendDRO'></part>
                               </message>
                               <message name='TestingWSFacadeService_returnSome'>
                               <part element='tns:returnSome' name='returnSome'></part>
                              
                               </message>
                               <message name='TestingWSFacadeService_sendDROResponse'>
                               <part element='tns:sendDROResponse' name='sendDROResponse'></part>
                               </message>
                               <portType name='TestingWSFacadeService'>
                               <operation name='returnSome' parameterOrder='returnSome'>
                               <input message='tns:TestingWSFacadeService_returnSome'></input>
                               <output message='tns:TestingWSFacadeService_returnSomeResponse'></output>
                               </operation>
                              
                               <operation name='sendDRO' parameterOrder='sendDRO'>
                               <input message='tns:TestingWSFacadeService_sendDRO'></input>
                               <output message='tns:TestingWSFacadeService_sendDROResponse'></output>
                               </operation>
                               </portType>
                               <binding name='TestingWSFacadeServiceBinding' type='tns:TestingWSFacadeService'>
                               <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
                               <operation name='returnSome'>
                               <soap:operation soapAction=''/>
                              
                               <input>
                               <soap:body use='literal'/>
                               </input>
                               <output>
                               <soap:body use='literal'/>
                               </output>
                               </operation>
                               <operation name='sendDRO'>
                               <soap:operation soapAction=''/>
                              
                               <input>
                               <soap:body use='literal'/>
                               </input>
                               <output>
                               <soap:body use='literal'/>
                               </output>
                               </operation>
                               </binding>
                               <service name='TestingWSFacadeServiceService'>
                              
                               <port binding='tns:TestingWSFacadeServiceBinding' name='TestingWSFacadeServicePort'>
                               <soap:address location='http://10.7.23.44:8082/ZEORK_SOA-0.1.0/FacadeTest'/>
                               </port>
                               </service>
                              </definitions>
                              


                              • 12. Re: can't force SOAPClient to generate correct SOAP
                                tfennelly

                                So the body of the SOAP template you need to populate looks like:

                                <tes:sendDRO>
                                 <!--Optional:-->
                                 <dro>
                                 <!--Zero or more repetitions:-->
                                 <dane>
                                 <!--Optional:-->
                                 <kod>?</kod>
                                 <!--Optional:-->
                                 <kodZewnetrzny>?</kodZewnetrzny>
                                
                                 etc...
                                


                                For this, you should have a DRO object that models this and looks something like (getters/setters omitted):

                                public class DRO {
                                 private Dane dane;
                                 etc ....
                                }
                                
                                public class Dane {
                                 private ??? kod;
                                 private ??? kodZewnetrzny;
                                }
                                
                                etc etc...
                                


                                Then wrap this up in a Request object similar to one of the options you had in your original post on this thread:

                                DRO dro = message.getBody().get();
                                SendDRORequest resultObj = new SendDRORequest(dro);
                                
                                message.getBody().add(resultObj);
                                


                                Where SendDRORequest looks like:

                                public class SendDRORequest {
                                 private DRO dro;
                                }
                                


                                If this doesn't work, then you need to set that "dumpSOAP" parameter and send us the output (I already asked you for this a few times ;) ). This should show the OGNL expressions that were inserted into the "?" insertion points and that will tell you what the SOAPClient expects the input model to look like.

                                • 13. Re: can't force SOAPClient to generate correct SOAP
                                  tfennelly

                                  Sorry... typo in there...

                                  SendDRORequest resultObj = new SendDRORequest(dro);

                                  ... should obviously have been ...

                                  SendDRORequest requestObj = new SendDRORequest(dro);

                                  • 14. Re: can't force SOAPClient to generate correct SOAP
                                    tereus

                                    One fast question about SOAPClient - in this example, when Ihave and a collection of inside, can I have a List in DRO, or i should have an object called Dane, which contains a List ? It could be crucial. Another question is do I have to have a SendDRORequest object, or I can just map to DRO object?
                                    Answers to those questions can be very useful for me.

                                    Thanks!

                                    1 2 Previous Next