PHP Websample
-
- Advanced member
- Posts: 230
- Joined: Thu Aug 07, 2014 10:04 am
PHP Websample
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
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
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
PHP Websample
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
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
-
- Advanced member
- Posts: 230
- Joined: Thu Aug 07, 2014 10:04 am
PHP Websample
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
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
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
Freddy
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
PHP Websample
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.
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.
-
- Advanced member
- Posts: 230
- Joined: Thu Aug 07, 2014 10:04 am
PHP Websample
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
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
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.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
PHP Websample
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.
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.
-
- Advanced member
- Posts: 230
- Joined: Thu Aug 07, 2014 10:04 am
PHP Websample
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.
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.
-
- Advanced member
- Posts: 230
- Joined: Thu Aug 07, 2014 10:04 am
PHP Websample
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?
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?
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
PHP Websample
Did you change
$protected_url = "https://localhost:51008";
to point to your Server server? Is Switch server running?
$protected_url = "https://localhost:51008";
to point to your Server server? Is Switch server running?
-
- Advanced member
- Posts: 230
- Joined: Thu Aug 07, 2014 10:04 am
PHP Websample
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?
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?
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
PHP Websample
SOAP/Client.php is standard part of PHP distribution. My copy is located in /opt/local/lib/php/SOAP/Client.php
-
- Advanced member
- Posts: 230
- Joined: Thu Aug 07, 2014 10:04 am
PHP Websample
Unfortunately I am on windows
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
PHP Websample
ArielRauch wrote: Unfortunately I am on windows
Shouldn't matter. What PHP distribution did you install?
Shouldn't matter. What PHP distribution did you install?