Forum Discussion

mkaplan's avatar
mkaplan
Occasional Contributor
13 years ago

ResponseAsXml - Missing match for source XPath

Hi everyone,

In my Test Steps, I have a JDBC request that returns an Xml hierarchy: <Results><ResultSet><Row><Property1></Property1><Property2></Property2></Row></ResultSet></Results>. Now my next step is to store the value of "Property1" in a Property using property transfer. I select my JDBC request as the source and "ResponseAsXml" as the Property. My problem is that I don't know what the namespace is. I tried the namespace of my WSLD and that didn't work. Any help is appreciated.

Thanks,
Michael

---EDIT---
I figured out the answer to my question. You don't need a namespace, just declare the property in the text field below "Source" and "Property" aka "//Property". Guess I thought too much about it. My second question stills stands though, I don't get why the response is different depending on whether I run it in a Test Step or individually.

Thanks,
Michael

6 Replies

  • mkaplan's avatar
    mkaplan
    Occasional Contributor
    Hi everyone,

    On another side note, my Test Steps include 3 steps so far, Request, Property Transfer, and JDBC Request. When I run the Test Steps as a whole, the first two steps work perfectly but the JDBC Request returns: <Results><ResultSet></ResultSet></Results>, which is different than if I run the JDBC Request manually (I get the XML that I posted above). Why does my JDBC Request return a different response?

    Thanks,
    Michael
  • mkaplan's avatar
    mkaplan
    Occasional Contributor
    This might be of some help. I left a part out, it shouldn't be this: <Results><ResultSet></ResultSet></Results>, it should be: <Results><ResultSet fetchSize="128"></ResultSet></Results>.

    ---EDIT---
    Fixed it. Just like the original issue, it was fixed very easily. For this issue, I added a delay between the property transfer and the JDBC Request. Derp :/

    ---EDIT(2)---
    Make sure to put spaces in your sql query when going to a new line. The JDBC Request still runs the query as one line.
  • ChristineA's avatar
    ChristineA
    Occasional Contributor
    Hi

    Sorry for asking stupid questions, but I am trying to use property transfers with ResponseAsXML (from a JSON request)

    I am definitely not structuring the source correctly - can anyone give me the correct format?

    The XML response I get back from the JSON request is:
    <Response xmlns="some.svc/doLogin">
    <doLoginResult>
    <Client>
    <Code>BWK</Code>
    <Description>Board Walk</Description>
    <Fax>1231231212</Fax>
    <Id>3</Id>
    <Logo>iVBORw0KGgoAAAANSUhEUgAAAMgAAACMCAYAAAA5kebkAAAACXBIW</Logo>
    <Max_Users>50</Max_Users>
    <Phone>1231231232</Phone>
    <Status>1</Status>
    <Website>somesite.com</Website>
    </Client>
    <Code>1</Code>
    <Message null="true"/>
    <TimeStamp>0</TimeStamp>
    <UserIdentity>
    <ClientId>3</ClientId>
    <Comments null="true"/>
    <CreatedDate>1369215629</CreatedDate>
    <Email>clientemail@hotmail.com</Email>
    <Id>47</Id>
    <Password>xnU4/X+MbtV5tOm9iT3kDDAfVcKzFCBgHrKbbEjkQfE=</Password>
    <PasswordSalt null="true"/>
    <SessionId>542269e791f8a408</SessionId>
    <UserName>TomHolt</UserName>
    </UserIdentity>
    </doLoginResult>
    </Response>

    I am trying to do a property transfer on the SessionId, the Id and the ClientID

    Let's just take the ClientID to start with
    I've set up a property transfer, with the source as the DoLogin test case (JSON POST) and the 'Property' set to ResponseAsXML
    In the Source box I have:
    //Response/doLoginResult/UserIdentity/ClientId

    I also tried

    //Response//doLoginResult//UserIdentity//ClientId

    Neither of these seem to be correct since I get an error message: Missing match for Source Xpath

    Can anyone just give me an example of what the source format should be?

    Thanks
  • ChristineA's avatar
    ChristineA
    Occasional Contributor
    OK - managed to solve my own problem, although what was wrong in the first place is anybody's guess

    I just deleted the while property transfer step, set it up again and this time it worked.

    I just used //ClientId as the source.
  • ChristineA's avatar
    ChristineA
    Occasional Contributor
    Sorry, no, still not working. When I created it again, the default was set to 'Make missing Xpaths NULL' and it was therefore passing NULLs to the properties. When I took off the 'make missing Xpaths NULL' the property transfer step failed with the same error - missing match for source XPath..

    Any help will really be appreciated...
  • ChristineA's avatar
    ChristineA
    Occasional Contributor
    OK!!

    Managed to get it working at last - the format that I used I actually got from another post....

    declare namespace ns1='your.svc/doLogin';
    //ns1:Response[1]/ns1:doLoginResult[1]/ns1:UserIdentity[1]/ns1:ClientId[1]

    and in fact you can put it in as
    //ns1:Response/ns1:doLoginResult/ns1:UserIdentity/ns1:ClientId

    which also works...

    I thought it wasn't necessary to declare namespaces but there you have it.

    It is a JSON POST request, with response as XML...