cancel
Showing results for 
Search instead for 
Did you mean: 
bgehring
Nintex Newbie

xPath Query and Collections

Jump to solution


OK so I am working on a project where I need to connect to an external system with a web request and send some SOAP and I get a SOAP response. That all works great. Now I am attempting to parse the SOAP response into several collections. I have a Query XML action where I specify a query like /SOAP-ENV:Envelope/SOAP-ENV:Body/defaultNS:getRecordsResponse/defaultNS:getRecordsResult/defaultNS:number. I am storing the text of this result into a collection. Then I repeat this action a bunch more times for other elements in the SOAP return. Finally I want to loop through the results and add them to a list.

In my Query XML action if I use Run Now I get all the results I am expecting. Output one shows all the numbers, output 2 shows all the states with no xml or markup being displayed. After this I do a collection Action to get a count of the elements in the collection. I manually count about 15 items. Then I do a For Each Action where I specify the collection, the Store result in text field and the index variable. Within my loop I write to the log the values of each item. I will eventually write these to a list.

The problem is when I get to printing out the results, the count operation only counts 1 item and then when it shows me the value of that one item it is the entire xml, not the value I parsed out in my query. I can't figure out why. Here are some of the actions.

2-12-2016 3-58-48 PM.jpg

2-12-2016 4-01-10 PM.jpg

2-12-2016 4-02-07 PM.jpg

2-12-2016 4-03-06 PM.jpg

2-12-2016 4-03-48 PM.jpg

2-12-2016 4-05-20 PM.jpg

Any help here would be greatly appreciated.

Thanks,

     Berney

Tags (1)
Reply
5 Replies
janeyres
Nintex Newbie

Re: xPath Query and Collections

Jump to solution

Hi,

Are you able to post the XML you're getting back from the web service please?

Thanks

Jan

0 Kudos
Reply
bgehring
Nintex Newbie

Re: xPath Query and Collections

Jump to solution

The xml is something like this. I changed some stuff so I wasn't posing company data. Also this xml has only one entry instead of the 15 or 20 that I get back.

<SOAP-ENV:Envelope xmlnsSmiley FrustratedOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Body>
    <getRecordsResponse xmlns="http://www.service-now.com/incident">
      <getRecordsResult>
        <active>1</active>
        <activity_due></activity_due>
        <approval>not requested</approval>
        <assigned_to />
        <assignment_group>c7bf6488dzycke40a861b11ff15744ec</assignment_group>
        <business_duration></business_duration>
        <business_stc>0</business_stc>
        <calendar_duration></calendar_duration>
        <calendar_stc>0</calendar_stc>
        <caller_id>5c681a94bdjejdmcjsu665d8459c9ded</caller_id>
        <category>inquiry</category>
        <caused_by />
        <close_code />
        <close_notes />
        <closed_at></closed_at>
        <closed_by />
        <cmdb_ci>0e168724b4de98402ddjfufjrufj9dae</cmdb_ci>
        <contact_type>phone</contact_type>
        <correlation_display />
        <correlation_id />
        <delivery_plan />
        <description>Email trail is located on the work notes.

From: Doe, Jane
Sent: Thursday, November 01, 2012 8:08 AM
To: Doe, Jim; Dough, Bob
Subject: RE: Subject line - urgent - production issue

Jane
Bob talking about each orders, Building should be able to release the order one by one without effort, and a whole lot more of an email message that I am blanking out with this inane writing so as to have an example to post without incriminating anybody.
</description>
        <due_date></due_date>
        <escalation>0</escalation>
        <expected_start></expected_start>
        <follow_up></follow_up>
        <group_list />
        <impact>2</impact>
        <incident_state>20</incident_state>
        <knowledge>0</knowledge>
        <location>7a579b94b4c25jujujujuju8459c9d71</location>
        <made_sla>1</made_sla>
        <notify>1</notify>
        <number>12324557</number>
        <opened_at>2012-11-12 14:18:28</opened_at>
        <opened_by>4e689294b4d6lokijuhygtd8459c9d5e</opened_by>
        <order>0</order>
        <parent />
        <priority>3</priority>
        <problem_id />
        <reassignment_count>0</reassignment_count>
        <rfc />
        <service_offering />
        <severity>3</severity>
        <short_description>Bobs Shipping Issues</short_description>
        <skills />
        <sla_due></sla_due>
        <state>20</state>
        <subcategory />
        <sys_class_name>incident</sys_class_name>
        <sys_created_by>jdoe</sys_created_by>
        <sys_created_on>2012-11-12 14:23:02</sys_created_on>
        <sys_domain>global</sys_domain>
        <sys_id>32aqswdefrgt3804a86156c9689c0b4f</sys_id>
        <sys_mod_count>4</sys_mod_count>
        <sys_updated_by>jbobe</sys_updated_by>
        <sys_updated_on>2014-12-23 08:28:15</sys_updated_on>
        <time_worked></time_worked>
        <u_actual_start>2012-11-12 14:18:28</u_actual_start>
        <u_affected_user>5c681a94b4d6lokijuhygtd8459c9ded</u_affected_user>
        <u_alternate_phone />
        <u_areas_impacted />
        <u_assigned>2012-11-12 14:23:02</u_assigned>
        <u_available_workarounds />
        <u_caller_computer />
        <u_change />
        <u_change_number />
        <u_change_request />
        <u_ci_filter_type>Service</u_ci_filter_type>
        <u_ci_on_resolution />
        <u_communication_detail />
        <u_communication_type />
        <u_component />
        <u_descriptor>functionality</u_descriptor>
        <u_descriptor_on_resolution />
        <u_email_subject />
        <u_highest_priority>0</u_highest_priority>
        <u_important_links />
        <u_it_service>dd8164bdacbhygtf01c940685f69192a</u_it_service>
        <u_it_service_on_resolution />
        <u_next_update></u_next_update>
        <u_notification_count>0</u_notification_count>
        <u_p1_incident_manager />
        <u_post_to_scroller>0</u_post_to_scroller>
        <u_resolution_code />
        <u_resolution_comment />
        <u_resolved></u_resolved>
        <u_resolved_by />
        <u_send_email>0</u_send_email>
        <u_send_to />
        <u_send_to_group />
        <u_show_all_computers>0</u_show_all_computers>
        <u_systems_affected />
        <u_target_resolution></u_target_resolution>
        <u_users_affected />
        <u_was_p1>0</u_was_p1>
        <upon_approval>proceed</upon_approval>
        <upon_reject>cancel</upon_reject>
        <urgency>2</urgency>
        <user_input></user_input>
        <watch_list />
        <work_end></work_end>
        <work_start></work_start>
      </getRecordsResult>
    </getRecordsResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

0 Kudos
Reply
janeyres
Nintex Newbie

Re: xPath Query and Collections

Jump to solution

Hi,

Well I've run it through a test workflow and it works ok for me:

It's probably worth double checking the XML that is being passed in via the WSIncidentsResult variable as it may not be in the format you're expecting.

Please let me know if you need any further help?

Thanks

Jan

0 Kudos
Reply
bgehring
Nintex Newbie

Re: xPath Query and Collections

Jump to solution

You are right, I am getting a partial xml result. No idea why, but not all the xml is returning. I tried storing the xml in a single line of text and in a multiline, but got the same result. Is there anything on the nintex side that would limit the size of that text I can store? I am not doing any xslt transforms, but I did also just add capture errors and there were none. Thanks for the help. We don't have an answer but at least now there is a road to look down. so new question, what would cause the response to be truncated?
I know from doing the run now action on that step that the service is returning a full response at least in that case. Any ideas here?

Thanks,

     Berney

0 Kudos
Reply
janeyres
Nintex Newbie

Re: xPath Query and Collections

Jump to solution

Hi,

You could try setting the Force top level XML node in the Web Service action, this can help if the xml returned is a fragment. But you could also do an XSL transform which would let you manipulate the results before they are stored in the variable, you could filter out any information you didn't need to use.

Jan

0 Kudos
Reply