Forum Discussion

crislawrence's avatar
crislawrence
New Contributor
16 years ago

Trying to parse a Salesforce login response using groovy in SoapUI 3.5

I need to extract the serverUrl and sessionId from the response I get from a Salesforce login request using a Saleforce developer setup.  The response comes back just fine and looks like this:


 
     
       
            <metadataserverurl>https://na7-api.salesforce.com/services ... 000000KYuL

            false
            false
            https://na7-api.salesforce.com/services ... 000000KYuL
            00DA0000000KYuL!ARgAQDutrkJyY4HK73.HsH6sosqaMSMtOk6pSFL2fnhIWYTpUD0xAGRjUxKtlGQ50RxVf15g0FEk2NTmhOotmeBFgZVYL42z
            005A0000000RfaYIAS
           
              false
              $
              USD
              false
              false
              00DA0000000KYuLMAW
              false
              Villanova University
              00eA0000000nzgpIAA
             
             
              cris.lawrence@villanova.edu
              Cris Lawrence
              005A0000000RfaYIAS
              en_US
              en_US
              cris.lawrence@verizon.net
              America/Los_Angeles
              Standard
              Theme2
           

       

     

 


log.info("Login Response")
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
holder = groovyUtils.getXmlHolder("Test Request#Response" )
log.info("Response: " + holder.xml)
serverUrl = holder.getNodeValue( "//serverUrl" )
assert serverUrl != null

The assert fails although the holder.xml string does show the entire xml response.  Any node I substitute for 'serverUrl' in the xpath gives me the same result.  Any reason why this doesn't work?  Is there another way for me to get my data without resorting searching the string?

Thanks for any and all help.

- Cris

2 Replies

  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Try this:

    holder.declareNamespace("default","urn:enterprise.soap.sforce.com")
    def serverUrl = holder.getNodeValue( "//default:serverUrl" )
    assert serverUrl != null