Working with Zend Soap classes and auto WSDL - php

Something very strange.
WSDL file generates fine. Here is source simple class
class SoapTest
{
/**
* Prapapapapapapap
* #return string Bls bls
*/
public function getList()
{
return "code";
}
}
Code for WSDL, Server, Client
if (isset($_REQUEST['wsdl'])) {
$ad = new Zend_Soap_AutoDiscover();
$ad->setClass('SoapTest');
$ad->handle();
} else if ( isset($_REQUEST['client']) ) {
$client = new Zend_Soap_Client("http://localhost/test.php");
echo $client->getList();
}
else {
$server = new Zend_Soap_Server("http://localhost/test.php?wsdl");
$server->setClass('SoapTest');
$server->handle();
}
Autogenerated WSDL have some problems with SoapServer
Uncaught exception 'Zend_Soap_Server_Exception' with message 'Invalid XML' in Z:\home\localhost\www\Zend\Soap\Server.php:694 Stack trace: #0 Z:\home\localhost\www\Zend\Soap\Server.php(817): Zend_Soap_Server->_setRequest('') #1 Z:\home\localhost\www\test.php(54): Zend_Soap_Server->handle() #2 {main} thrown in Z:\home\localhost\www\Zend\Soap\Server.php on line 694
I just don't understand why? There is no extra symbol in WSDL like space or \n, all headers are specified.
Php 5.2.12
ZF 1.10.0

all problems from eAccelerator

Related

SOAP request not working in PHP

We have wsdl :
http://xxxxxxxxxxxxxxx.com/XXXX_Beta_3_API/webservice.asmx?wsdl
IN PHP FILE : i have created a Class with some arrays in it..
class Crmtet {
public $abc;
public $abc2;
public $abc3;
public $abc4;
}
$client = new SoapClient(http://xxxxxxxxxxxxxxx.com/XXXX_Beta_3_API/webservice.asmx?wsdl);
$obj = new Crmtet();
$obj->abc= "Test";
$obj->abc2= "Test2";
$obj->abc3= "Test3";
$obj->abc4= "Test4";
$result = $client->CRM_Warehouse_Master_Insert($obj)->CRM_Warehouse_Master_InsertResult;
echo"re".$result;
But i am getting below error :
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was
unable to process request. ---> Object reference not set to an
instance of an object. in
E:\EasyPHP-12.1\www\test\inserwarrecrm.php:60 Stack trace: #0
E:\EasyPHP-12.1\www\test\inserwarrecrm.php(60):
SoapClient->__call('CRM_Warehouse_M...', Array) #1
E:\EasyPHP-12.1\www\test\inserwarrecrm.php(60):
SoapClient->CRM_Warehouse_Master_Insert(Object(Crmtet)) #2 {main}
thrown in E:\EasyPHP-12.1\www\test\inserwarrecrm.php on line 60
What is the issue.. can anyone help..??

PHP Soap with Crowd wsdl

I am trying to write a code for sso login with crowd in my custom php application. I trying to to do that with SOAP. I am in a early stage now and was going through the documentation of how to connect php soap with wsdl. But i seem to be stuck very deep as i dont know what should be done next.
<?php
class test {
function authenticateApplication()
{
$client = new SoapClient("http://localhost:8095/crowd/services/SecurityServer?wsdl");
$param = array('in0' => array('credential' => 'password','name' => 'app'));
$resp=$client->authenticateApplication($param);
$token = $resp->out->token;
print_r($resp);
}
}
$t= new test;
$t->authenticateApplication();
I Dont know whats wrong with this code. I have referred it online and it seems to be correct but when i am tring to run this program i am getting this error
Fatal error: Uncaught SoapFault exception: [soap:Client] The validated object is null in /var/www/html/badebade/soaptest.php:7 Stack trace: #0 /var/www/html/badebade/soaptest.php(7): SoapClient->__call('authenticateApp...', Array) #1 /var/www/html/badebade/soaptest.php(7): SoapClient->authenticateApplication(Array) #2 /var/www/html/badebade/soaptest.php(13): test->authenticateApplication() #3 {main} thrown in /var/www/html/badebade/soaptest.php on line 7
A little help will be much appreciated as this program authenticates the application in crowd wsdl and returns the token. Can someone help me to achieve it.
function Find($request) {
try {
$soapClient = new SoapClient('wsdl.wsdl', array('trace' => 1));
$results = $soapClient->authenticateApplication($request);
return $results;
}
catch(SoapFault $ex) {
print $ex->getMessage();
echo '<HR>';
print $ex->getTraceAsString();
echo '<HR>';
echo $ex->getLine();
}
}
$results = Find($params);

Basic PHP / SOAP error, can't debug

I'm currently having a really frustrating time with some really simple SOAP / PHP at the moment. I've spent about a week trying EVERYTHING I can think of, on multiple different servers with different versions of PHP and they all still throw the same error. Here's the code:
function test() {
$client = new SoapClient('http://xxx', array("login" => "sandbox", "password" => "password"));
print_r($client->__getFunctions());
$ap_param = array();
// it dies here. CheckServiceAvailable is a valid function returned in __getFunctions()
$result = $client->__soapcall('CheckServiceAvailable', $ap_param);
if (is_soap_fault($result)) {
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
}
}
It faults before the error catching can capture anything. Apache logs show the same fault as below:
Fatal error: Uncaught SoapFault exception: [s:Processing error] in C:\soap.php:13 Stack trace: #0 C:\soap.php(13): SoapClient->__soapCall('CheckServiceAva...', Array) #1 C:\soap.php(23): test() #2 {main} thrown in C:\soap.php on line 13
Without being able to catch the fault I'm totally stuck as to what to do. I don't really want to try nusoap.
Any ideas?
use:
try
{
$result = $client->__soapcall('CheckServiceAvailable', $ap_param);
}
catch (SoapFault $e)
{
echo "Cannot call method CheckServiceAvailable: {$e->getMessage()}";
}

Uncaught SoapFault

I am getting the following error when trying to create a new SoapClient.
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.mindbodyonline.com/0_5/ClassService.asmx?wsdl' : failed to load external entity "https://api.mindbodyonline.com/0_5/ClassService.asmx?wsdl" in C:\xampp\htdocs\Work\Ice\default\soaptest.php:8 Stack trace: #0 C:\xampp\htdocs\Work\Ice\default\soaptest.php(8): SoapClient->SoapClient('https://api.min...') #1 {main} thrown in C:\xampp\htdocs\Work\Ice\default\soaptest.php on line 8
what would cause the WSDL to not load?
Enable openssl in your php.ini you load the WSDL over https this is only working when the openssl module is enabled.
Not sure if this might be the case with you but if you are using the PHP classes provided on the Minbody API on Github, note that they have recently updated them. I had the same problem with classService.php. If you are using classService.php, update the constructor function to the following (same will apply to other services):
function __construct($debug = false)
{
$endpointUrl = "https://" . GetApiHostname() . "/0_5/ClassService.asmx";
$wsdlUrl = $endpointUrl . "?wsdl";
$this->debug = $debug;
$option = array();
if ($debug)
{
$option = array('trace'=>1);
}
$this->client = new soapclient($wsdlUrl, $option);
$this->client->__setLocation($endpointUrl);
}

(400) Bad Requestwhen using the permission to the library google-api-php-client

Uploading a file and immediately do permission->update:
public function sharingFile() {
$fileId = $this->file['id'];
$permissionId = $this->file['userPermission']['id'];
try {
$permission = $this->service->permissions->get($fileId, $permissionId);
$permission->setRole('writer');
$permission->setType('default');
print_r($permission);
return $this->service->permissions->update($fileId, $permissionId, $permission);
} catch (Exception $e) {
return "Error: " . $e;
}
return NULL;
}
and get an error:
Error: exception 'Google_ServiceException' with message 'Error calling PUT
https://www.googleapis.com/drive/v2/files/0B6xE_F1PfpXTbF9IdHgxbEJueEk/permissions/me:
(400) Bad Request' in Z:\home\site.com\www\google-api-php-client\src\io\Google_REST.php:66
Stack trace:
#0 Z:\home\site.com\www\google-api-php-client\src\io\Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest))
#1 Z:\home\site.com\www\google-api-php-client\src\service\Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest))
#2 Z:\home\site.com\www\google-api-php-client\src\contrib\Google_DriveService.php(774): Google_ServiceResource->__call('update', Array)
it may be a bug in the library?
Help, please.
Your code is trying to update permissions for the document owner and make that user a writer instead. A Drive document must have exactly one owner, so your request is invalid.

Categories