Jump to content

Recommended Posts

Ok, this is my first adventure in SOAP and WSDL at all.  Everything I have done via an API to date has been using XML and CURL....

 

I will say that the tutorials on the web, are very basic and not very helpful when it comes to useful info about SOAP.

 

Here is my code so far:

 

<?PHP
   
$wsdl="http://apps.xora.com/xoraapps/services/XoraTimeTrackLocationServices40?wsdl";
  
$client = new SoapClient("$wsdl", array('trace' => 1,'exceptions' => 0));

$creds = array("accountId"=>"xxxxx",
"username"=>"admin",
"password"=>"xxxxxx"
);  
   
$locations = array(
"numberOfLocations"=>"1", 
"userId"=>"7834"
);

$result = $client->getLatestLocation(
    new SoapParam(Credential, "$creds"),
    new SoapParam(LatestLocationDetailCriteria, "$locations")
    );
    
if (is_soap_fault($result)) {
    echo "Error Code <br />";
    echo "---------- <br />";
    $err_cd = $result->faultcode;
    $error_code = explode(":", $err_cd);
    echo "$error_code[1] <br />";
    echo "$result->faultstring <br /><br />";
}
  
var_dump($client->__getFunctions());  

?>

 

and here is what I get back:

 

Error Code
----------
Server Error.
3501

array(5) { [0]=> string(98) "ArrayOf_tns2_LandmarkStatus deleteLandmarks(Credential $credential, ArrayOf_xsd_string $landmarks)" [1]=> string(118) "GeofenceActivity40 getGeofenceActivity(Credential $credential, DateTimeRange $dateTimeRange, PageRequest $pageRequest)" [2]=> string(151) "LocationEntry40 getLocationEntries(Credential $credential, DateTimeRange $dateTimeRange, string $userId, string $eventFilter, PageRequest $pageRequest)" [3]=> string(115) "ArrayOf_tns2_LandmarkStatus createLandmarks(Credential $credential, Scope $scope, ArrayOf_tns2_Landmark $landmarks)" [4]=> string(160) "ArrayOf_tns2_LatestLocationDetails getLatestLocation(Credential $credential, LatestLocationDetailCriteria $locationDetailCriteria, SelectOptions $selectOptions)" } 

 

I am assuming my SoapClient is making connection, because I am getting back the function list.  What I think is happening, is my values of my variables arent being set correctly.  Maybe cause I am not setting Namespace???  Like I said, I have not found much help out on the web, if someone can point in the right direction, I do want to learn why and how to make this work, but right now, just appear to be running in circles.

Link to comment
https://forums.phpfreaks.com/topic/119268-php5-soap-help/
Share on other sites

Ok, I have narrowed it down to the variables for credential and locationDetailCriteria being sent

 

Request : 
<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws40.xora.com" xmlns:ns2="http://timetrack.xora.com/TimeTrackServices40/common/type/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://timetrack.xora.com/TimeTrackServices40/location/type/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getLatestLocation>
<credential xsi:type="ns2:Credential"/>
<locationDetailCriteria xsi:type="ns3:LatestLocationDetailCriteria"/>
<selectOptions xsi:nil="true" xsi:type="ns2:SelectOptions"/>
</ns1:getLatestLocation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

 

Link to comment
https://forums.phpfreaks.com/topic/119268-php5-soap-help/#findComment-614775
Share on other sites

Ok, a little more help.  I need to be able to set a type of:

 

type="impl:ArrayOf_xsd_string"

 

I use the following:

 

$location->userId = new SoapVar("$user_id", XSD_STRING, 'ArrayOf_xsd_string', "http://www.w3.org/2001/XMLSchema");

 

but I get the following:

 

<userId xsi:type="xsd:ArrayOf_xsd_string">7834</userId>

 

I need the change the xsd: to impl:  but I can not find an encoding type that will do so.  Anyone have any ideas?

Link to comment
https://forums.phpfreaks.com/topic/119268-php5-soap-help/#findComment-615019
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.