Stuck on this. Hope someone can shed some light on it.

The issues involves Drupal 7 Rules and Web Service Client (wsclient) when consuming SOAP results. The Rule breaks when trying to loop on any SOAP object array result set. In this case, FindServiceTickets.

The Rule works fine when the I use an action that returns only a single object, such as GetServiceTicket. Yet it breaks specifically when I attempt to loop over a SOAP object array result set, in this case the FindServiceTicketsResponse result. It breaks even if I do nothing in the loop at all.

I perform the FindServiceTickets action, pull 10 Tickets. The FindServiceTicketsResponse result contains an array of Ticket objects. I can even see the correct 10 Ticket and their field details in the error drump, actually, so the Web Service Client appears to work fine.

When it breaks Drupal throws the following:

Warning: array_keys() expects parameter 1 to be array, object given in array_keys() (line 1040 of /Applications/MAMP/htdocs/drupal/sites/all/modules/entity/includes/entity.wrapper.inc). =>...

Recoverable fatal error: Argument 2 passed to EntityMetadataWrapperIterator::__construct() must be of the type array, null given, called in /Applications/MAMP/htdocs/drupal/sites/all/modules/entity/includes/entity.wrapper.inc on line 1040 and defined in __construct() (line 1118 of /Applications/MAMP/htdocs/drupal/sites/all/modules/entity/includes/entity.wrapper.inc). =>....

What do I miss? Do I need to cast the stdClass Object into into a List of Ticket Object, or ArrayOfTicket? If so, where and how do I do that, where do I cast it? I have not solved this.

Any suggestions or links to a solution would be greatly, greatly appreciated!

Issue fork rules-2008334

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agp1001001’s picture

Priority: Normal » Major
cweagans’s picture

Priority: Major » Normal

A few things:

1) Support requests are never major or critical. The priority is not representative of the importance it has to you, but the importance to the project.

2) In order to help you, you're going to need to provide code, not just screenshots of errors.

3) This is not an issue with Drupal core, and should probably be taken up in either the Rules or wsclient queue. I'm going to let you decide which queue to move it to, but I'm certain that it does not belong here.

Thanks, and sorry I wasn't more help.

agp1001001’s picture

Thanks for your replay, cweagans. Please excuse the post faux pas. I hadn't posted here before.

I posted it here because Web Service Client (wsclient) author Klaus Purer (https://drupal.org/user/262198) suggested I post this here when I wrote it to him. He replied:

"Hi, please post all support requests to the drupal.org issue queue. Thanks!"

Prior to that a few days ago I had posted this same post as a Forums Topic, yet it received no replies.

You suggest I post it to the Rules or wsclient queue, yet do I find that on this same Issues board by designating which type of Component under which it falls? (I saw neither in the list.) Or is there another location?

Hope to find some support. Thanks for the guidance.

agp1001001’s picture

Project: Drupal core » Web service client
Version: 7.22 » 7.x-1.0
Component: other » Code
Assigned: agp1001001 » Unassigned
agp1001001’s picture

The exported rule:

	{ "rules_rule_cw_tickets" : {
	    "LABEL" : "Rule CW Tickets",
	    "PLUGIN" : "reaction rule",
	    "REQUIRES" : [ "rules", "wsclient" ],
	    "ON" : [ "node_view" ],
	    "IF" : [
	      { "node_is_of_type" : {
	          "node" : [ "node" ],
	          "type" : { "value" : { "cw_ticket" : "cw_ticket" } }
	        }
	      }
	    ],
	    "DO" : [
	      { "data_create" : {
	          "USING" : {
	            "type" : "wsclient_cw_service_ticket_ApiCredentials",
	            "param_CompanyId" : "XXXXXX",
	            "param_IntegratorLoginId" : "XXXXX",
	            "param_IntegratorPassword" : "XXXXXXX"
	          },
	          "PROVIDE" : { "data_created" : { "data_credential" : "Data Credential" } }
	        }
	      },
	      { "data_create" : {
	          "USING" : {
	            "type" : "wsclient_cw_service_ticket_FindServiceTickets",
	            "param_credentials" : [ "data-credential" ],
	            "param_conditions" : "XXXXXXXX",
	            "param_limit" : "10",
	            "param_skip" : "0"
	          },
	          "PROVIDE" : { "data_created" : { "data_fst" : "Data FindServiceTickets" } }
	        }
	      },
	      { "wsclient_cw_service_ticket_FindServiceTickets" : {
	          "USING" : { "param_parameters" : [ "data-fst" ] },
	          "PROVIDE" : { "result" : { "result" : "FindServiceTicketsResponse" } }
	        }
	      },
	      { "LOOP" : {
	          "USING" : { "list" : [ "result:FindServiceTicketsResult" ] },
	          "ITEM" : { "list_item" : "Current list item" },
	          "DO" : []
	        }
	      }
	    ]
	  }
	}
agp1001001’s picture

Project: Web service client » Rules
Version: 7.x-1.0 » 7.x-2.3
Component: Code » Module Integrations
agp1001001’s picture

Title: Can't solve Rule break on loop of Web Service Client SOAP result array » "array_keys() expects parameter 1 to be array, object given" on loop over wsclient SOAP array
Component: Module Integrations » Rules Core
Priority: Normal » Major
FileSize
430.17 KB
1.91 MB
1.87 MB
72.5 KB
3.36 KB

Still getting this error:

array_keys() expects parameter 1 to be array, object given

It happens when trying to iterate within a Rule loop over a SOAP result of an array using wsclient module (Web Service Client).

I generated outputs using PHP var_dump() on each of the variables within the rule, referring to Option 3 on https://drupal.org/node/1114308.

Attached, you will find:

  • the exported Drupal Rule FindContacts as a file
  • the PHP var_dump() outputs from 3 rule variables credential, fc, and result as a single file.
  • the error message output, part 1, as a file
  • the error message output, part 2, as a file
  • the ContactsAPI wsdl file
  • a screenshot of the Drupal output page

Please note: I have no var_dump() output from the list_item iterator variable of the rule loop because the error occurs before any next step can happen within the loop, before it can output a message.

Please note: I created this Drupal rule on different SOAP action and different SOAP endpoint than first posted. I created it on the SOAP ContactsApi instead of on the SOAP ServiceTicketApi. Both are from the same web services provider. I performed the action FindContacts instead of FindServiceTicket.

The same issue occurs with Contacts as with ServiceTicket.

Top of error message part 1 (full file attached):

<em class="placeholder">Warning</em>: <em class="placeholder">array_keys() expects parameter 1 to be array, object given</em> in <em class="placeholder">array_keys()</em> (line <em class="placeholder">1040</em> of <em class="placeholder">/Applications/MAMP/htdocs/drupal/sites/all/modules/entity/includes/entity.wrapper.inc</em>). => Array

and top of error message part 2 (full file attached):

<em class="placeholder">Recoverable fatal error</em>: <em class="placeholder">Argument 2 passed to EntityMetadataWrapperIterator::__construct() must be of the type array, null given, called in /Applications/MAMP/htdocs/drupal/sites/all/modules/entity/includes/entity.wrapper.inc on line 1040 and defined</em> in <em class="placeholder">__construct()</em> (line <em class="placeholder">1118</em> of <em class="placeholder">/Applications/MAMP/htdocs/drupal/sites/all/modules/entity/includes/entity.wrapper.inc</em>). => Array

I replaced my client's text fields with "xxxxxx" in the attached files.

I very much hope someone might identity what does not work here. Please let me know if I can clarify any of the above. Thanks.

agp1001001’s picture

Also, this only occurs on an array result, not on a non-array result.

The issue occurs on the iteration over the array, not on getting the array result.

e.g. I get back a single complexType ServiceTicket when I perform a GetServiceTicket (which does not return an array, but just one complexType) and I can use it to, say, create a node with its fields. FindServiceTickets, returns an array of ServiceTicket. I get the array back fine but I cannot iterate over it.

asirjacques made their first commit to this issue’s fork.

solideogloria’s picture

Status: Active » Closed (outdated)