vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

XPath with namespace in request variable usage is not supported

Open betancour opened this issue 5 years ago • 8 comments
trafficstars

Last time, you explain how to get the internal variable, but didn't work. I am going to put the original response and where the token lays.

<!-- HTTP/1.1 200 OK
SOAPAction: ""
X-Frame-Options: SAMEORIGIN
Referrer-Policy: origin-when-cross-origin
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
Content-Security-Policy: default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';
X-XSS-Protection: 1; mode=block
Content-Type: text/xml;charset=utf-8
Content-Length: 732
Date: Fri, 24 Jan 2020 18:04:10 GMT
Server: SWS
Connection: close
Vary: Accept-Encoding
Content-Encoding: gzip -->

<!-- <?xml version="1.0" encoding="UTF-8"?> -->
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    <soap-env:Header>
        <eb:MessageHeader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" eb:version="1.0" soap-env:mustUnderstand="1">
            <eb:From>
                <eb:PartyId eb:type="URI">SWS</eb:PartyId>
            </eb:From>
            <eb:To>
                <eb:PartyId eb:type="URI">Client</eb:PartyId>
            </eb:To>
            <eb:CPAId>BBAA</eb:CPAId>
            <eb:ConversationId>SWS</eb:ConversationId>
            <eb:Service eb:type="xxxxxXML">Session</eb:Service>
            <eb:Action>SessionCreateRS</eb:Action>
            <eb:MessageData>
                <eb:MessageId>6203700650503870194</eb:MessageId>
                <eb:Timestamp>2020-01-24T18:04:10</eb:Timestamp>
                <eb:RefToMessageId>1234</eb:RefToMessageId>
            </eb:MessageData>
        </eb:MessageHeader>
        <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
            <wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">000012552225ASDASD465411</wsse:BinarySecurityToken>
        </wsse:Security>
    </soap-env:Header>
    <soap-env:Body>
        <SessionCreateRS xmlns="http://www.opentravel.org/OTA/2002/11" version="1" status="Approved">
            <ConversationId>SWS</ConversationId>
        </SessionCreateRS>
    </soap-env:Body>
</soap-env:Envelope>

Reference Incorrect request variable reference syntax, it should be "variableName.(response|request).(headers|body).(headerName|JSONPath|XPath|*)"

Using a Xpath tool to get the variable //soap-env:Envelope/soap-env:Header/wsse:Security/wsse:BinarySecurityToken

## @name SessionCreateRQ

@token = {{SessionCreateRQ.response.body.//soap-env:Envelope/soap-env:Header/wsse:Security/wsse:BinarySecurityToken}}

returns: Invalid XPath query

Please any help I'll appreciate.

Thanks in advance.

Best regards

Yitzhak

betancour avatar Jan 24 '20 18:01 betancour

Thanks so much @Huachao , I really adore this plugin and using it in rest services is marvelous.

betancour avatar Jan 29 '20 15:01 betancour

Maybe you can try something like this. @token = {{SessionCreateRQ.response.body./*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='Security']//*[local-name()='BinarySecurityToken']}} Found this one that helped me at least https://stackoverflow.com/a/5239991

ZefQ avatar Feb 13 '20 20:02 ZefQ

@ZefQ @betancour nice workaround.

Huachao avatar Feb 14 '20 02:02 Huachao

Namespace support would be great!

Stadly avatar Feb 14 '20 11:02 Stadly

It works, thanks so much...

betancour avatar Feb 14 '20 12:02 betancour

@Stadly sure, I will leave this issue open

Huachao avatar Feb 14 '20 14:02 Huachao

Maybe you can try something like this. @token = {{SessionCreateRQ.response.body./*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='Security']//*[local-name()='BinarySecurityToken']}} Found this one that helped me at least https://stackoverflow.com/a/5239991

Thanks so much,

@ZefQ and @Huachao

Excellent support. appreciate so much the help...

betancour avatar Feb 14 '20 14:02 betancour

I'll bump this ticket because it would be really nice if this is fixed. A fix shouldn't be that hard because any XPath library can handle namespaces.

edwinm avatar Apr 22 '22 09:04 edwinm