Forum Discussion

minoseah629's avatar
Occasional Contributor
8 years ago

Assertions with XPATH

Sorry if this is in wrong area, but I am new to SOAP UI os.  


I am currently trying to achieve a simple test case where if I call a service with no parameters, the response should not provide me any information back.  Super simple. 


With that, I am trying to get an understanding of xpath assertions. 


I used xpath in selenium tests.  


But I do not understand what I am doing wrong on the Xpath match configuration screen. 


I see that when I click Declare, it provides me namespaces in XPath Expression box. 


It provides this: 

declare namespace soap='';
declare namespace ns1='https://ForceDevelopmentServices.ServiceCode.DCPDS.EducationData.DataContracts';
declare namespace ns2='';
declare namespace ns3='';
declare namespace ns4='https://USAF.A1.Personnel.ForceDevelopment.DAL.Services.Base';

Under Assertions, 


I used a online xpath tester to get this xpath expression:



I would expect to place a ? in the expected results box, but when I click on Select from current I get an error message saying "Missing content to select from".  I then tried to click on the 'Test' to see what happens, I get another error message saying "Missing Content"


I looked over Query/Match, I did not get much from this view since it does not seem to do anything when I put in xpath query or Matching Value


Any assistance would be greatly appreciated.  Thanks in advance.




xmlns:for1="https://ForceDevelopmentServices.ServiceCode.DCPDS.EducationData.DataContracts"> <soap:Header/> <soap:Body> <for:GetAcquisitionsCertificationsBySSANResponse> <!--Optional:--> <for:GetAcquisitionsCertificationsBySSANResult> <!--Zero or more repetitions:--> <for1:DCPDSAcquisitionsCertification> <!--Optional:--> <for1:SSAN>?</for1:SSAN> <!--Optional:--> <for1:ACQ_DT_CAREER_LVL_ACHVD>?</for1:ACQ_DT_CAREER_LVL_ACHVD> <!--Optional:--> <for1:ACQ_CAREER_LEVEL_ACHVD_DESC>?</for1:ACQ_CAREER_LEVEL_ACHVD_DESC> <!--Optional:--> <for1:ACQ_CAREER_LVL_APPR_AUTH>?</for1:ACQ_CAREER_LVL_APPR_AUTH> <!--Optional:--> <for1:ACQ_CAREER_LVL_APPR_AUTH_DESC>?</for1:ACQ_CAREER_LVL_APPR_AUTH_DESC> <!--Optional:--> <for1:ACQ_CERT_CAREER_FIELD>?</for1:ACQ_CERT_CAREER_FIELD> <!--Optional:--> <for1:ACQ_CERT_CAREER_FIELD_DESC>?</for1:ACQ_CERT_CAREER_FIELD_DESC> </for1:DCPDSAcquisitionsCertification> </for:GetAcquisitionsCertificationsBySSANResult> </for:GetAcquisitionsCertificationsBySSANResponse> </soap:Body> </soap:Envelope>


4 Replies

  • kondasamy's avatar
    Regular Contributor

    Your XPATH should be 


    and you should have declared namespaces for 'for' and 'for1'




  • nmrao's avatar
    Champion Level 3



    Namespaces can be confusing, once you get how they work, then it should be easy.


    Regarding Namespaces:
    #1 Elements GetAcquisitionsCertificationsBySSANResponse, GetAcquisitionsCertificationsBySSANResult are belong to namespace "https://ForceDevelopmentServices.ServiceCode.DCPDS.EducationData.Interfaces"



    #2 And rest of the elements are belong to namespace "https://ForceDevelopmentServices.ServiceCode.DCPDS.EducationData.DataContracts"


    Note that one needs to be aware of namespaces.


    If you see the actual response, elements of #1 have prefix "for", but in the xpath below, the same namespace is mapped to prefix "ns1".


    Similarly, elements of #2 have prefix "for1", but in the xpath, the same namespace is mapped to prefix "ns2".


    In the XPath assertion, you have to use the same prefixes that you declare ( and should not concern about prefix that is actually present in the response.)


    XPath Assertion:


    declare namespace ns1='https://ForceDevelopmentServices.ServiceCode.DCPDS.EducationData.Interfaces';
    declare namespace ns2='https://ForceDevelopmentServices.ServiceCode.DCPDS.EducationData.DataContracts';



    Also there is another way for the same xpath, to use any namespace using "*"





    In the above full xpath is mentioned. You can also use the short xpath, like you tried, only if that element is unique in the response.


    declare namespace ns2='https://ForceDevelopmentServices.ServiceCode.DCPDS.EducationData.DataContracts';



  • raptor's avatar
    Occasional Contributor


    I am also getting the same "Missing content to select from" popup when I click on Select from Current button for XQuery Match Assertion.


    Xquery Expression is as below


    declare namespace soap='';
    declare namespace ns1='';

    for $x in //ns1:GetSupplierByCityResponse/ns1:SupplierDataLists/ns1:SupplierDatas/ns1:SupplierData
    return <SupplierNumber>{data($x/ns1:SupplierNumber)}</SupplierNumber>



    Please help me fix this as I am using SOAP UI for the first time. I am just using the tutorial below to learn


  • JHunt's avatar
    Community Hero

    It just means you are trying to test your assertion, but you haven't yet got a webservice response to test against. (When you click 'Test' or 'Select From Current', it only runs the assertion against the last response you received. It doesn't send the request.)


    All you need to do is send your Test Request (green play button). If you've saved your assertion, it will run automatically now. Then, if you need to edit the assertion, you can open the assertion editor now and you will be able to test it.