Forum Discussion

BenX's avatar
BenX
Contributor
16 years ago

[SOLVED]groovy info from request

Hi!

i have one strange situation.

here is request nr1:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ui="http://ui.ws.mmw.iskratel.si/">
   <soapenv:Header/>
   <soapenv:Body>
      <ui:uiCallMW>
         <!--Optional:-->
         <!--Optional:-->
         <sSessionID>12598504507454b3cf18cb8b94880939522609a3d0773</sSessionID>
         <sCmd>get</sCmd>
         <!--Optional:-->
         <!--Optional:-->
         <sTarget>homepage</sTarget>
         <xParams><?xml version="1.0" encoding="utf-8"?><params><terminal_ip>192.168.60.61</terminal_ip></params></xParams>
      </ui:uiCallMW>
   </soapenv:Body>
</soapenv:Envelope>


response is ok.

after this i have groovy script.
i can get value from it with:

def request = context.expand( '${uiCallMW - Request 1#Request#//ui:uiCallMW/sTarget}' )
log.info request

Thu Dec 03 10:31:09 CET 2009:INFO:homepage

works OK.


2nd case:
simmilar request like earlier:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <uiCallMW xmlns="http://ui.ws.mmw.iskratel.si/">
         <sSessionID xmlns="">12599180921925f9e46f1fd6745fe9cbe9c24516a70b1</sSessionID>
         <sCmd xmlns="">get</sCmd>
         <sTarget xmlns="">homepage</sTarget>
         <xParams xmlns=""><?xml version="1.0" encoding="utf-8"?><params><terminal_ip>192.168.60.61</terminal_ip></params></xParams>
      </uiCallMW>
   </soapenv:Body>
</soapenv:Envelope>


response is the same as before.

groovy:
def request = context.expand( '${uiCallMW - Request 1#Request#//ns1:uiCallMW[1]/sTarget[1]}' )
log.info request

Thu Dec 03 10:32:24 CET 2009:INFO:

Doesn't work!

why can't i parse value from second request? 

i really need help with this one please...

Beno
  • I am not sure where the ns1 namespace is defined in the second request so that is probably where I would start looking
  • BenX's avatar
    BenX
    Contributor
    i found solution. (i think)

    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
      <S:Body>
          <ns2:uiCallMWResponse xmlns:ns2="http://ui.ws.mmw.iskratel.si/">
            <return>
                <bIsExecuted>true</bIsExecuted>
            </return>
            <xParams>${xparam_value}</xParams>
          </ns2:uiCallMWResponse>
      </S:Body>
    </S:Envelope>


    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def holder = groovyUtils.getXmlHolder( mockRequest.requestContent )

    holder.namespaces["ui"] = "http://ui.ws.mmw.iskratel.si/"
    String xparam = holder.getNodeValue("//ui:uiCallMW[1]/xParams[1]")



    i'm not sure if i understand this situation 100% but it's working and that's important right now.