Rob Clarke
Rob Clarke

Reputation: 167

Questions about xPath structure with SoapUI and Property Transfer - some basics needed

I am now trying another xpath property transfer in SoapUI, and am struggling again. Rather than specifics I thought I would ask some general questions. If the response I am wanting to extract from has a line like this:

  <ns2:getApprovedPortChangeRequestsResponse xmlns:ns2="http://transferobjects.abc.abc.org">

Oddly, when I click the ns: button in SoapUI it generates the following:

declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://transferobjects.abc.abc.org';
declare namespace ns2='http://abc.abc.org/api/serviceorder';

But the message response is pretty clear with the ns2 line above

Then I think that I can safely assume that I should do this:

declare namespace ns2='getApprovedPortChangeRequestsResponse';  

Now, when I do the part describing what I want to capture, I am using the ns2 tag, following by the section names that follow as I go in to the message, in this case two layers:

//ns2:return/approvedPortChangeRequests/@version  

The value I want is the value of the field called version, don't know if I want the @ symbol this time, it's a numeric value, but I get null regardless of whether the @ is there or not. I have thoroughly checked the response message and pretty certain I have it right. There are a couple of other sections in the response above the field, but they are at the same level as , from what I can see.

I have tried including the getApprovedPortChangeRequestsResponse as a parent layer in the last line, with no effect.

Only when I use getApprovedPortChangeRequestsResponse in the ns2 declaration can I get anything other than Null, and then only verbose errors like this:

[net.sf.saxon.trans.XPathException: XPath syntax error at char 7 on line 2 in {\n//ns2:/return}:
    QName cannot end with colon: {ns2:}]

Basically, I am utterly ignorant and my googlefu hasn't shown me any resource where I can build any sort of understanding of what I am doing, so any suggestion on that front would be appreciated. I just need a couple of examples of doing this in SoapUI, and I should be sweet. Thanks in advance.

EDIT- Full Response here:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getApprovedPortChangeRequestsResponse xmlns:ns2="http://transferobjects.abc.abc.org">
         <return>
            <success>true</success>
            <approvedPortChangeRequests>
               <lspOverride>false</lspOverride>
               <numbers>
                  <complete>false</complete>
                  <gainingCompanyId>11667</gainingCompanyId>
                  <losingCompanyId>11657</losingCompanyId>
                  <notRequired>false</notRequired>
                  <phoneNumber>
                     <phoneNumber>098453509</phoneNumber>
                  </phoneNumber>
               </numbers>
               <DateTimeStart>2018-03-07T08:00:00+13:00</DateTimeStart>
               <som>6001309</som>
               <category>Simple</category>
               <requestDateTime>2018-03-07T12:05:25+13:00</requestDateTime>
               <requesterResellerId>21</requesterResellerId>
               <responderResellerId>1</responderResellerId>
               <responseDue>
                  <actualDays>0</actualDays>
                  <actualHours>1</actualHours>
                  <actualMinutes>47</actualMinutes>
                  <businessDays>0</businessDays>
                  <businessHours>1</businessHours>
                  <businessMinutes>47</businessMinutes>
                  <negative>false</negative>
               </responseDue>
               <status>
                  <status>Awaiting APC Approval</status>
               </status>
               <version>1</version>
            </approvedPortChangeRequests>
         </return>
      </ns2:getApprovedPortChangeRequestsResponse>
   </soap:Body>
</soap:Envelope>

Upvotes: 0

Views: 781

Answers (1)

craigcaulfield
craigcaulfield

Reputation: 3538

In your payload, version is an element rather than an attribute, so you don't need the @.

soapUI tries to help you out by declaring namespaces, but you can go simpler. If version is all you need and there's only one, you can navigate directly to it regardless of namespaces by using //version. The // notation will select a node no matter where it is in the payload.

Upvotes: 1

Related Questions