Forum Discussion

David_Shapiro's avatar
David_Shapiro
Occasional Contributor
12 years ago

Specific xsi:type=ns*:RemoteUser name values only needed





Hello,



I have xml soapui reponse with many xsi:type returns, but I only response from one with particular type.



For example,



The xml data:

...

<multiRef id="id5" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:RemoteUser" xmlns:ns7="http://beans.soap.rpc.jira.atlassian.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

         <email xsi:type="xsd:string">joe.smoo@fakemail.com</email>

         <fullname xsi:type="xsd:string">Joe Smoo</fullname>

         <name xsi:type="xsd:string">joesmoo</name>

      </multiRef>

      <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns8:RemoteProjectRole" xmlns:ns8="http://beans.soap.rpc.jira.atlassian.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

         <description xsi:type="xsd:string" xsi:nil="true"/>

         <id xsi:type="xsd:long">10002</id>

         <name xsi:type="xsd:string">Administrators</name>

      </multiRef>

...



I was using:




def request = testRunner.testCase.getTestStepByName(teststep);

def responseData = request.getProperty("Response");

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );

def holder = groovyUtils.getXmlHolder( "getProjectRoleActors#Response" );



 def x = holder.getNodeValues("//multiRef/name");



 for (def part in x) {

  log.info part;

 }



This returns all the name values even for the ones that are not listed with type RemoteUser. 



I wanted something regular repression like with getNodeValue or getNodeValues, but no luck. 



Things I tried with no success:



 def x = holder.getNodeValues("//multiRef/ns:RemoteUser/name");  # says it is not declared



 def x = holder.getNodeValues("//multiRef/RemoteUser/name"); # does not work

 def x = holder.getNodeValue("//multiRef

  • /*RemoteUser*/name"); # does not work



    How can I get just the data with RemoteUser as the type?

     

    • Hi David,



      This namespace-agnostic XPath worked for me:

      //multiRef[contains(@*[local-name()='type'], 'RemoteUser')]/*[local-name()='name']/text()



      If you need not just a values of the name nodes, but the nodes itself, try this:

      //multiRef[contains(@*[local-name()='type'], 'RemoteUser')]/*[local-name()='name']



      Hope it will help...
    • AlexKaras's avatar
      AlexKaras
      Champion Level 3
      Hi David,



      This namespace-agnostic XPath worked for me:

      //multiRef[contains(@*[local-name()='type'], 'RemoteUser')]/*[local-name()='name']/text()



      If you need not just a values of the name nodes, but the nodes itself, try this:

      //multiRef[contains(@*[local-name()='type'], 'RemoteUser')]/*[local-name()='name']



      Hope it will help...
    • AlexKaras's avatar
      AlexKaras
      Champion Level 3
      Hi David,



      While, as Tanya already pointed out, this is TestComplete but not SoapUI forum, can you post (attach) the complete response?
    • David_Shapiro's avatar
      David_Shapiro
      Occasional Contributor
      I tried to attach a txt file but it did not let me.  I will paste the content here:




      <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>

            <ns1:getProjectRoleActorsResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://soap.rpc.jira.atlassian.com">

               <getProjectRoleActorsReturn href="#id0"/>

            </ns1:getProjectRoleActorsResponse>

            <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:RemoteProjectRoleActors"



      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://beans.soap.rpc.jira.atlassian.com">

               <project href="#id1"/>

               <projectRole href="#id2"/>

               <roleActors soapenc:arrayType="ns2:RemoteRoleActor[2]" xsi:type="soapenc:Array">

                  <roleActors href="#id3"/>

                  <roleActors href="#id4"/>

               </roleActors>

               <users soapenc:arrayType="ns2:RemoteUser[2]" xsi:type="soapenc:Array">

                  <users href="#id5"/>

                  <users href="#id6"/>

               </users>

            </multiRef>

            <multiRef id="id6" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:RemoteUser" xmlns:ns3="http://beans.soap.rpc.jira.atlassian.com"



      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

               <email xsi:type="xsd:string">rob.low@fakemail.com</email>

               <fullname xsi:type="xsd:string">Rob Low</fullname>

               <name xsi:type="xsd:string">roblow</name>

            </multiRef>

            <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:RemoteRoleActor" xmlns:ns4="http://beans.soap.rpc.jira.atlassian.com"



      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

               <descriptor xsi:type="xsd:string">Rob Low</descriptor>

               <parameter xsi:type="xsd:string">roblow</parameter>

               <projectRole href="#id2"/>

               <type xsi:type="xsd:string">atlassian-user-role-actor</type>

               <users soapenc:arrayType="ns4:RemoteUser[1]" xsi:type="soapenc:Array">

                  <users href="#id6"/>

               </users>

            </multiRef>

            <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:RemoteProjectRole" xmlns:ns5="http://beans.soap.rpc.jira.atlassian.com"



      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

               <description xsi:type="xsd:string" xsi:nil="true"/>

               <id xsi:type="xsd:long">10002</id>

               <name xsi:type="xsd:string">Administrators</name>

            </multiRef>

            <multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns6:RemoteRoleActor" xmlns:ns6="http://beans.soap.rpc.jira.atlassian.com"



      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

               <descriptor xsi:type="xsd:string">Kevin Bacon</descriptor>

               <parameter xsi:type="xsd:string">kevbac</parameter>

               <projectRole href="#id2"/>

               <type xsi:type="xsd:string">atlassian-user-role-actor</type>

               <users soapenc:arrayType="ns6:RemoteUser[1]" xsi:type="soapenc:Array">

                  <users href="#id5"/>

               </users>

            </multiRef>

            <multiRef id="id5" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:RemoteUser" xmlns:ns7="http://beans.soap.rpc.jira.atlassian.com"



      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

               <email xsi:type="xsd:string">kevin.bacon@fakemail.com</email>

               <fullname xsi:type="xsd:string">Kevin Bacon</fullname>

               <name xsi:type="xsd:string">kevbac</name>

            </multiRef>

            <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns8:RemoteProject" xmlns:ns8="http://beans.soap.rpc.jira.atlassian.com"



      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

               <description xsi:type="xsd:string" xsi:nil="true"/>

               <id xsi:type="xsd:string">10012</id>

               <issueSecurityScheme xsi:type="ns8:RemoteScheme" xsi:nil="true"/>

               <key xsi:type="xsd:string" xsi:nil="true"/>

               <lead xsi:type="xsd:string" xsi:nil="true"/>

               <name xsi:type="xsd:string">Product Catalog</name>

               <notificationScheme xsi:type="ns8:RemoteScheme" xsi:nil="true"/>

               <permissionScheme xsi:type="ns8:RemotePermissionScheme" xsi:nil="true"/>

               <projectUrl xsi:type="xsd:string" xsi:nil="true"/>

               <url xsi:type="xsd:string" xsi:nil="true"/>

            </multiRef>

         </soapenv:Body>

      </soapenv:Envelope>