Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP-SOAP; Problem with Passing Array

Posted on 2010-09-19
3
Medium Priority
?
1,127 Views
Last Modified: 2012-05-10
Greetings Experts,

I am trying to write a PHP script to integrate with an on-line service called Agemni. My problem, in a nutshell, is that I need to pass an array of items to the SOAP server Unfortunately I have no idea how to do that. I am quite new to using SOAP with PHP. The applicable part of the WSDL is below the part I'm having trouble with are the keys\values of type "tns:ArrayOfAnyType". I need to pass an array consisting of keys  fname, lname and phone initially to test.

      <s:element name="CreateEntity">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="strUsername" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="strPassword" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="strCompanyName" type="s:string" />
            <s:element minOccurs="1" maxOccurs="1" name="objecttype" type="s:int" />
            <s:element minOccurs="0" maxOccurs="1" name="keys" type="tns:ArrayOfAnyType" />
            <s:element minOccurs="0" maxOccurs="1" name="values" type="tns:ArrayOfAnyType" />
          </s:sequence>
        </s:complexType>
      </s:element>

Open in new window


Here is the code I have written so far.

<?php

// Define Variables

   $wsdl = "http://agemni.com/AgemniWebservices/service1.asmx?WSDL";

// Define array

   $parameters['parameters']['strUsername']     = "";
   $parameters['parameters']['strPassword']     = "";
   $parameters['parameters']['strCompanyName']  = "";
   $parameters['parameters']['objecttype']      = 2;
   $parameters['parameters']['keys']            = ;
   $parameters['parameters']['values']          = ;

// Fetch Dishstar WSDL
// Note WSDL caching of TTL 86400 seconds is enabled in php.ini for performance

   $client = new SoapClient($wsdl, array('trace' => 1));
   
// Make SOAP Call in WSDL mode

   try {
     $result = $client->__soapCall("CreateEntity", $parameters);

   } catch (SoapFault $fault) {
    trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
   }
    
// Display results of SOAP call
    
   var_dump($result);
            
   echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
            
?>

Open in new window


Finally here is a link to documentation for the API.
Leads and Customer API


Any help on this issue would be greatly appreciates. Thank you in advance for your assistance!
0
Comment
Question by:rwterp
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
upandrun3 earned 2000 total points
ID: 33713243
Hi rwterp,

I'm guessing you're not getting any type of response back from your request?

If it's using the WSDL, have you tried something like this:

$username = "";
$password = "";
$company_name = "";
$object_type = 2;
$keys = array("fname","lname","phone");
$values = array("Bob","Roberts","555-555-5555");

$client = new SoapClient($wsdl, array('trace' => 1));
$result = $client->CreateEntity($username,$password,$company_name,$object_type,$keys,$values);

// You can put the test and such around this and var_dump the results.

Note, I haven't tested this and it may take some tweaking.

Hope it helps,
Pete
0
 

Author Comment

by:rwterp
ID: 33713262
Pete,

Actually I am getting a response. I tried your suggestion although in a slightly different fashion and it seems to have resolved the problem. Unfortunately it introduced another problem. I'm receiving this response from the SOAP Server

string(63) "Conversion from type 'XmlNode()' to type 'String' is not valid."
 
  $KeyList    = array("phone", "fname", "lname" ,"area id","lead id","contactdate");

  $ValueList  = array("9495551212","james","bond","1","2","9/19/2010");


   $parameters['parameters']['strUsername']     = "";
   $parameters['parameters']['strPassword']     = "";
   $parameters['parameters']['strCompanyName']  = "";
   $parameters['parameters']['objecttype']      = 2;
   $parameters['parameters']['keys']            = $KeyList  ;
   $parameters['parameters']['values']          = $ValueList  ;

Open in new window

0
 

Author Closing Comment

by:rwterp
ID: 33713279
The response fully resolved the posted question.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question