Page 1 of 2
PHP Websample
Posted: Sun Sep 07, 2014 8:28 am
by ArielRauch
Hi,
I am not sure if this is the right place to post this problem - feel free to route me:)
I have installed the web services module and I am trying to get the sample working but I am receiving "connection failed" after entering the credentials. My setup is as follows:
Switch 12 on:
1. Windows 2008R2 Standard
2. HP Server (12 GB RAM)
Web Sample:
1. same server
2. IIS7.5
3. php 5.6
4. Enabled:
a. openssl
b. curl
c. soap
5. phpinfo is working - of course
Switchclient is connecting without problems
Any suggestions how I can debug to understand what is the problem?
Thanks
Ariel
PHP Websample
Posted: Sun Sep 07, 2014 6:42 pm
by dkelly
Here's a minimal PHP example I wrote last year.
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
require 'SOAP/Client.php';
$protected_url = "
https://localhost:51008";
$my_cert_file = "cacert.pem";
$user = "USERNAME;EN";
$pass = "PASSWORD";
try {
$client = @new SoapClient("butterfly.wsdl",
array( 'local_cert', $my_cert_file,
'trace' => true,
'exceptions' => true,
'login' => $user,
'password' => $pass
));
$client->__setLocation($protected_url);
} catch (Exception $e) {
echo $e->getMessage();
die();
}
$connectReply = $client->CheckConnect();
$credentials = array('login' => $user, 'password' => $pass);
$loginReply = $client->CheckUserNameAndPass($credentials);
$flowsReply = $client->GetFlowList();
#print_r($flowsReply);
foreach ($flowsReply->flowList as $flowId) {
$flowParms = array('flowId' => $flowId);
$flowNameReply = $client->GetFlowName($flowParms);
$flowStateReply = $client->GetFlowState($flowParms);
if ($flowStateReply->FlowState == 3) {
echo $flowId . " " . $flowStateReply->FlowState . " " . $flowNameReply->flowName . "n";
$submitPtsReply = $client->GetSubmitPoints($flowParms);
if (is_array($submitPtsReply->submitPoints)) {
foreach ($submitPtsReply->submitPoints as $submitPtId) {
$submitPtParms = array('flowId' => $flowId, 'submitPointId' => $submitPtId);
$submitPtNameReply = $client->GetSubmitPointName($submitPtParms);
echo " " . $submitPtId . " " . $submitPtNameReply->submitPointData->name . "n";
}
} else {
$submitPtParms = array('flowId' => $flowId, 'submitPointId' => $submitPtsReply->submitPoints);
$submitPtNameReply = $client->GetSubmitPointName($submitPtParms);
print_r($submitPtNameReply);
echo " " . $submitPtsReply->submitPoints . " " . $submitPtNameReply->submitPointData->name . "n";
}
}
}
die();
?>
Dwight Kelly
Advanced Switch concepts with scripting XML, SQL and Javascript seminar @ September 30, 2014 @ Graph Expo & remote classroom
PHP Websample
Posted: Mon Sep 08, 2014 8:16 am
by ArielRauch
Hi,
thank you very much for your help!
when running the code I receive an 500 internal error.
I am not a PHP programmer but you require in the code: "SOAP/client.php" which I do not have.
Every advice how to progress would be great.
Ariel
PHP Websample
Posted: Mon Sep 08, 2014 1:00 pm
by freddyp
Did you put the files of the PHP in the document root folder of the PHP server? You will find the location of that document root folder in the phpinfo. In the settings subfolder of the sample there is a settings.php that also specifies the subfolder (if any) the sample is located in, so you may have to change that.
Freddy
PHP Websample
Posted: Mon Sep 08, 2014 3:23 pm
by dkelly
ArielRauch wrote: I am not a PHP programmer
That's going to be a problem. Webservices is a complex topic and can't be solved by cut-n-paste programming. I recommend that you hire an experienced PHP developer.
PHP Websample
Posted: Mon Sep 08, 2014 4:05 pm
by ArielRauch
dkelly: I am not offended especially not as I know you inspected my LinkedIn profile:)
freddy: Yes, I put it in the root folder and I adjusted the parameters in settings.php
I assume it is an installation/permission issue
PHP Websample
Posted: Mon Sep 08, 2014 4:38 pm
by gabrielp
Just curious -- what does the web services module do? I've done a lot with PHP's SoapClient and it's really great. I did some stuff with Switch in Javascript using their Soap class which turned out all right but it would be great if I could roll in my PHP code into Switch somehow.
PHP Websample
Posted: Mon Sep 08, 2014 4:59 pm
by dkelly
The easiest way to think about Webservices is that you could write your own SwitchClient application using it.
Webservices module enables a developer to connect to a running Switch server, inquire about flows, jobs, etc and submit jobs to submitpoints. Webservices uses an older SOAP protocol. It doesn't support latest SOAP version nor does it support REST.
PHP Websample
Posted: Mon Sep 08, 2014 4:59 pm
by ArielRauch
Gabriel: The Web services module actually offers the same functionality as the SwitchClient.
It means that you can implement a web application which enables remote users (like your customers) to upload and monitor jobs. It is - if I understand correctly - an open solution to what Connect and Connect all is used today.
PHP Websample
Posted: Mon Sep 08, 2014 5:00 pm
by ArielRauch
I have made some more research and debugging and got the following error message:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in C:inetpubwwwrootincludelibSwitchClientService_v4.0.php:1234 Stack trace: #0 [internal function]: SoapClient->__doRequest(‘__soapCall(‘CheckUserNameAn…’, Array, Array) #2 C:inetpubwwwrootincludelibSwitchClientService_v4.0.php(1281): switchclientService->CheckUserNameAndPass(Object(switchclientCheckUserNameAndPass)) #3 C:inetpubwwwrootincludecheckloginfromswitch.php(33): switchclientService->isAdminCredentials() #4 {main} thrown in C:inetpubwwwrootincludelibSwitchClientService_v4.0.php on line 1234
Any ideas?
PHP Websample
Posted: Mon Sep 08, 2014 5:10 pm
by dkelly
Did you change
$protected_url = "
https://localhost:51008";
to point to your Server server? Is Switch server running?
PHP Websample
Posted: Mon Sep 08, 2014 5:21 pm
by ArielRauch
Hi,
in the code you sent me I defined the $protected_url and yrs switch server is running. The switchclient is connecting without any problems.
The code you sent me references SOAP/Client.php which does not reside on my server. It is part of the pear package which is not installed.
In the sample code from enfocus the php file is not referred.
Do I need this package?
PHP Websample
Posted: Mon Sep 08, 2014 6:01 pm
by dkelly
SOAP/Client.php is standard part of PHP distribution. My copy is located in /opt/local/lib/php/SOAP/Client.php
PHP Websample
Posted: Mon Sep 08, 2014 7:23 pm
by ArielRauch
Unfortunately I am on windows
PHP Websample
Posted: Mon Sep 08, 2014 7:36 pm
by dkelly
ArielRauch wrote: Unfortunately I am on windows
Shouldn't matter. What PHP distribution did you install?