Service Virtualization

 View Only
  • 1.  Invalid XPath: Prefix must resolve to a namespace: soapenv

    Posted Sep 03, 2024 06:42 AM

    Sample Request : 

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rel="https://test.com/release4_0">
       <soapenv:Header/>
       <soapenv:Body>
          <rel:GetDetails4.3>
          <rel:shipment-id>SHIP12345</rel:shipment-id>
          </rel:GetDetails4.3>
       </soapenv:Body>
    </soapenv:Envelope>

    Sample Response:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
        <SOAP-ENV:Body>
            <GetDetails4.3 xmlns="http://test.com/release4_0">
                <shipment>
                    <status>
                       <delivered>
                          <delivery-time>2024-09-02T14:26:56.954Z</delivery-time>
                       </delivered>
                    </status>
                </shipment>
            </GetDetailse4.3>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    I want to get the value of delivery-time from this response. The Xpath query which I used in CA Devtest is as below, 

    /SOAP-ENV:Envelope/SOAP-ENV:Body/:GetDetails4.3/:shipment/:status/:delivered/:delivery-time/text()

    But I am getting the below error, 

    Invalid XPath: Prefix must resolve to a namespace: soapenv
    Failed to execute the XPath queryorg.apache.xpath.domapi.XPathStylesheetDOM3Exception: Prefix must resolve to a namespace: soapenv`

    Earlier the response used to be like the one below ,

    <soapenv:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
        <soapenv:Body>
            <GetDetails4.3 xmlns="http://test.com/release4_0">
                <shipment>
                    <status>
                       <delivered>
                          <delivery-time>2024-09-02T14:26:56.954Z</delivery-time>
                       </delivered>
                    </status>
                </shipment>
            </GetDetailse4.3>
        </soapenv:Body>
    </soapenv:Envelope>

    The Xpath query , I used to give then, was as below and I was getting the correct response.

    /soapenv:Envelope/soapenv:Body/:GetDetails4.3/:shipment/:status/:delivered/:delivery-time/text().

    Now after the change in the response format, I am not able to read the value from the SOAP response using the Xpath Query. 

    Could someone assist with a resolution for the same. 



    ------------------------------
    Shalini Murukes
    ------------------------------


  • 2.  RE: Invalid XPath: Prefix must resolve to a namespace: soapenv

    Broadcom Employee
    Posted Sep 03, 2024 09:26 AM
    HI Shalini
    There is only a minor issue here.

    1. The Sample Response does not have a matching XML tag for "GetDetails4.3".
    It's misspelled as "GetDetailse4.3"

    Once that is corrected, I dont see any problem. PLease try and let me know
    how it goes.

    [image: image.png]

    --
    regards
    Sankar Natarajan

    --
    This electronic communication and the information and any files transmitted
    with it, or attached to it, are confidential and are intended solely for
    the use of the individual or entity to whom it is addressed and may contain
    information that is confidential, legally privileged, protected by privacy
    laws, or otherwise restricted from disclosure to anyone else. If you are
    not the intended recipient or the person responsible for delivering the
    e-mail to the intended recipient, you are hereby notified that any use,
    copying, distributing, dissemination, forwarding, printing, or copying of
    this e-mail is strictly prohibited. If you received this e-mail in error,
    please return the e-mail to the sender, delete it from your computer, and
    destroy any printed copy of it.




  • 3.  RE: Invalid XPath: Prefix must resolve to a namespace: soapenv

    Posted Sep 03, 2024 09:54 AM

    That was a sample names I created , since I cant send the original names in the xpath in public forum. 

    I have the correct spellings in the original script in the Xpath Query in the DevTest scripts. 

    In that case, is there anything I am missing on it. When the format of the response got changed(capital letters in the response now), the scripts started to fail . 




  • 4.  RE: Invalid XPath: Prefix must resolve to a namespace: soapenv

    Broadcom Employee
    Posted Sep 03, 2024 10:07 AM
    Please mail me the exact XML that you have used and the Xpath expression.
    Pelase replace any sensitive data, but retain the tag names as they are.

    You may mail me directly Sankar.Natarajan@broadcom.com


    --
    regards
    Sankar Natarajan

    --
    This electronic communication and the information and any files transmitted
    with it, or attached to it, are confidential and are intended solely for
    the use of the individual or entity to whom it is addressed and may contain
    information that is confidential, legally privileged, protected by privacy
    laws, or otherwise restricted from disclosure to anyone else. If you are
    not the intended recipient or the person responsible for delivering the
    e-mail to the intended recipient, you are hereby notified that any use,
    copying, distributing, dissemination, forwarding, printing, or copying of
    this e-mail is strictly prohibited. If you received this e-mail in error,
    please return the e-mail to the sender, delete it from your computer, and
    destroy any printed copy of it.




  • 5.  RE: Invalid XPath: Prefix must resolve to a namespace: soapenv

    Posted Sep 03, 2024 10:31 AM

    Hi Sankar , 

    I have sent the details to your inbox. 




  • 6.  RE: Invalid XPath: Prefix must resolve to a namespace: soapenv

    Posted Sep 03, 2024 11:09 AM

    Hi Sankar , 

    I created the xpath again by copying it from the response and it seems to work . 

    I will run the complete automation suite, to ensure it is working as before. 

    Thank You for the support.




  • 7.  RE: Invalid XPath: Prefix must resolve to a namespace: soapenv

    Broadcom Employee
    Posted Sep 03, 2024 11:45 AM
    HI Shalini
    Thats good to hear. Btw, I could use the XML response that you
    have sent along with the xpath, IT worked fine as well.

    --
    regards
    Sankar Natarajan

    --
    This electronic communication and the information and any files transmitted
    with it, or attached to it, are confidential and are intended solely for
    the use of the individual or entity to whom it is addressed and may contain
    information that is confidential, legally privileged, protected by privacy
    laws, or otherwise restricted from disclosure to anyone else. If you are
    not the intended recipient or the person responsible for delivering the
    e-mail to the intended recipient, you are hereby notified that any use,
    copying, distributing, dissemination, forwarding, printing, or copying of
    this e-mail is strictly prohibited. If you received this e-mail in error,
    please return the e-mail to the sender, delete it from your computer, and
    destroy any printed copy of it.




  • 8.  RE: Invalid XPath: Prefix must resolve to a namespace: soapenv

    Broadcom Employee
    Posted Sep 03, 2024 11:26 AM

    I used the below response and XPaths and it worked for me too.

    Response:

     <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
        <SOAP-ENV:Body>
            <GetDetails4.3 xmlns="test.com/release4_0">
                <shipment>
                    <status>
                       <delivered>
                          <delivery-time>2024-09-02T14:26:56.954Z</delivery-time>
                       </delivered>
                    </status>
                </shipment>
            </GetDetails4.3>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    XPath: /SOAP-ENV:Envelope/SOAP-ENV:Body/:GetDetails4.3/:shipment/:status/:delivered/:delivery-time/text()