I'm trying to connect my app with Drupal. It return me this error: "Something went wrong - -32602 : Server error. Wrong number of method parameters.". I think it should work.
Have anyone any clue what is wrong here?
My code:
set_time_limit(0);
require_once("IXR_Library.php");
// Create the client object
$client = new IXR_Client('http://localhost/drupal6/xmlrpc.php');
//$client->debug=true;
$username = "admin";
$password = "admin";
$params = array(0,$username,$password,10);
if (!$client->query('metaWeblog.getRecentPosts', $params)) {
die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}
$myresponse = $client->getResponse();
You are getting an error message (Specification for Fault Code Interoperability, version 20010516) from the XMLRPC endpoint you're communicating with.
It is a defined error code:
-32602 ---> server error. invalid method parameters
The RPC method you requested was found by the server but you passed invalid parameters to it. Contact the support of the service you consume to get a list of all available methods. If your parameters should be available, contact the support and discuss the issue with them.
In your case, double-check what the Drupal manual tells you about the metaWeblog.getRecentPosts XMLRPC Method blogapi_xmlrpcDrupal API:
array(
'metaWeblog.getRecentPosts',
'blogapi_metaweblog_get_recent_posts',
array('array', 'string', 'string', 'string', 'int'),
t('Returns a list of the most recent posts in the system.'),
),
If this insufficient documentation, look the missing pieces up from within the source-code of Drupal.
For example the first parameter needs to be a string but you use the integer number 0 here.
For more information how you can make use of XMLRPC Introspection please see a releated question / answer: XMLRPC showing -32601 error (using PHP).
I do not know if drupal supports XMLRPC Introspection, but it looks like it does.
Related
I have consistent difficulty using any client service method that is not explicitly exampled somewhere. Despite following the docs and even reading the sourcecode, The class or method names I come up with following the scheme are never right.
The documentation at Packagist (see 'Making Requests") says the client library classes are autogenerated from the Google endpoints, which agrees with the description in the library's docs on Github that say the pattern for accessing methods should be "$service->resource->method(args)".
So why the following?
// works:
// I get a countable object of active classrooms owner by the specified id
$response = $this->ClassroomService->courses->listCourses([
'courseStates' => 'ACTIVE',
'teacherId' => 'me']);
// works:
// I get an instance of the single classroom's object containing lots of meta data
$response = $this->ClassroomService->courses->get( $id );
// does not work:
// 500 error, obj has no such method
$response = $this->ClassroomService->topics->listCoursesTopics( $id );
According to the API Explorer all three should be fine.
What am I missing about using client service objects?
Edit
Ultimately I determined the resource in my example to be 'courses_topics'; the method was correct per the docs. Thanks for the idea #ebram.
The question remains how the methods are named though. courseWork is my next challenge and it does not fit the the naming pattern of topics.
There is no topics member of ClassroomService.
The member is named courses_topics.
This is documented in the "Properties summary" at the bottom of the Classroom documentation.
Your code should look like this:
$response = $this->ClassroomService->courses_topics->listCoursesTopics( $id );
The documentation for Google_Service_Classroom_CoursesTopics_Resource does incorrectly give sample code where the member is named ->topics.
Given that API documentation is generated from source, but sample code is (generally) written by hand, I'll assume the API documentation is correct and the sample code is incorrect. I'd file a documentation-bug with Google.
Update:
I looked at the PHP source code for Google_Service_Classroom in GitHub and verified that the property is named courses_topics instead of topics, so in conclusion: the sample code is wrong.
What's also interesting is the resource-type in the actual source-code is Google_Service_Classroom_Resource_CoursesTopics but the documentation refers to it as Google_Service_Classroom_CoursesTopics_Resource - so that documentation is definitely wrong.
I am trying to extract some basic details from the RETS server using PHRETS but been getting this error
[*Uncaught Error: Call to undefined method PHRETS\Session::SearchQuery() in D:\Software\XAMPP\htdocs\PHRETS-master\RetsExtract.php:21 Stack trace: #0 {main} thrown in D:\Software\XAMPP\htdocs\PHRETS-master\RetsExtract.php on line 21*]
and can't seem to understand what is causing this.
So based on retsmd.com, I have Property as the resource, Listing as the class and based on these two I think I can extract the data using the SearchQuery() method.
I am relatively new to PHP and the RETS environment but here is the part of the code:
<?php
require_once("vendor/autoload.php");
$config = new \PHRETS\Configuration;
$config->setLoginUrl('http://matrixrets.crebtools.com/rets/Login.ashx');
$config->setUsername('userName');
$config->setPassword('pwdHere');
// optional. value shown below are the defaults used when not overridden
$config->setRetsVersion('1.8'); // see constants from \PHRETS\Versions\RETSVersion
$config->setUserAgent('agenUsr/1.0');
$config->setUserAgentPassword('pwdHere'); // string password, if given
$config->setHttpAuthenticationMethod('digest'); // or 'basic' if required
$config->setOption('use_post_method', false); // boolean
$config->setOption('disable_follow_location', false); // boolean
$rets = new \PHRETS\Session($config);
$bulletin = $rets->Login();
$search = $rets->SearchQuery("Property", "Listing", "(ListDate=1990-01-01+)");
?>
I am using this part of the from the GitHub repo of the PHRETS. Any idea what could be the issue here?
Thanks
This depends on the PHRETS version you are using.
Seems like you are using PHRETS library version 2.* and you referred the documentation of version 1.*
Both will work fine.
So in case anyone is looking for a solution to this, I have found a fix.
Apparently, its not SearchQuery() but just Search(). I don't know why the creator has SearchQuery() as the method in Github but Search() would show you the results that you're looking for.
I want to use nusoap library in applications using laravel 4.
I have an update on the composer with NoiselabsNuSOAP :
NuSOAP Library with composer
And I have followed the user manual
My code :
public function CallSOAP()
{
$client = new \nusoap_client('http://mywebsite/services/VcareServices.php', true);
$response = $client->call('validateLogin', array('EMAIL'=>'bertho_joris#yahoo.co.id', 'PASSWORD'=>'3b774f5aae6b97a060864f8310hg6785'));
return $response;
}
But I get an error message :
UnexpectedValueException The Response content must be a string or
object implementing __toString(), "boolean" given.
My question:
Is this library I can use for my laravel application?
How do I use to use it?
it's true maybe your SOAP response it's not the right one, but first of all try adding:
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
and check what is your service returning, maybe you have to specify the element of the response object like:
return $response['MyValue'];
or
return $response['key']['value'];
It looks to me like the nusoap library is being loaded correctly, otherwise you would get an error about \nusoap_client not being a recognised function.
It is more likely that the endpoint you are working with (http://mywebsite/services/VcareServices.php) is not providing a valid SOAP response.
Check that your endpoint complies with the SOAP protocol, or test your client against an existing SOAP server that you know works. That should help you diagnose the problem.
I need communicate with web-service construct in .net(i think), but when i try call a method, return this error:
The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/TripointWebservicesVersionedGeneral/Ping'.
Code to connect to web-service and execute method:
$client = new SoapClient(
'...?wsdl',
array(
'trace' => 1,
'soap_version' => SOAP_1_2
)
);
//$test = $client->__soapCall('Ping',array(''));
$test = $client->Ping();
What is the reason of this error? or what i need to do to call a method?
I have already read this PHP Fatal error: "The SOAP action specified on the message, '', does not match the HTTP SOAP Action", and put in option of soap connection this "'action' => '.../Ping'" but don't help me.
i've found the reason why i can't call the method's, its because of this:
One of the problems:
The PHP returns "Caught exception: Cannot process the message because the content type ‘text/xml; charset=utf-8′ was not the expected type ‘application/soap+xml; charset=utf-8′."
The reason:
WCF is running a new version of web services than expected by the PHP.
The solution:
Change the binding type of the WCF service from binding="wsHttpBinding" to binding="basicHttpBinding".
This insures that your .NET web service would support clients and other services that conform to the WS-I standards.
url source:
http://spacebug.com/php-calling-wcf-part-1-html
Not a full answer, but I just wanted to highlight that you're probably facing this problem because you're using SoapClient to try and consume a web service that uses WS-Addressing. You should try to track down what others do in this situation:
http://www.cdatazone.org/index.php?/archives/15-WS-Addressing-for-extsoap.html
https://github.com/wso2/wsf
I'm trying to use Zend_Soap_Client to communicate with an ASP.net web service. Here's my client call:
$client = new Zend_Soap_Client(null, array(
'location' => 'http://example.com/service.asmx',
'uri' => 'http://example.com/'
));
$user = new UserDetail();
$result = $client->UserDetails($user);
However this always gives me the error:
System.NullReferenceException: Object reference not set to an instance of an object. at Service.UserDetails(UserDetail UserDetail)
some googling revealed that this is quite a common problem. The most common solution seemed to be to pass the parameters as an array, so I tried:
$result = $client->UserDetails(array('UserDetail' => $user));
but this gave the same error. I also tried passing the params as a stdClass object, nesting the array in another with 'params' as the key, and a few other things but the error is always the same.
I have the ASP code for the web service itself, the relevant method is:
public Result UserDetails(UserDetail UserDetail) {
[some stuff]
Hashtable ht = new Hashtable();
ht = UserDetail.GenerateData();
}
the error is caused by the GenerateData() call.
I assume the UserDetails method is getting null instead of my object as the parameter, but I'm not sure how I should be calling the method, or how I can debug this further. The majority of the Zend_Soap_Client examples I've found seem to be using WSDL, which this service is not; not sure if that is relevant. Any help appreciated!
I eventually solved this with:
$userDetails = new UserDetails();
$userDetails->UserDetail = $user;
$client->UserDetails($userDetails);
it seems ASP.net expects (and returns) params to be nested in an object/array with the same name as the method being called.
If you have any possibility to change the asp.net code I'd suggest you try an implementation of the method UserDetails without parameters just to make sure that code isn't broken.
I would then create a consumer-method in asp.net, debug the http-request and see how the userdetail-object is serialized/broken down in array form. Then it's "just" a matter of creating a similar http request from php.