Ambigious PHP Web Service error message - php

did anyone ever encounter the following error message
Extra content at the end of the document
when trying to consume a PHP web service from a client
that runs on php 5.3?
I guess soembody did. ^^
Anyways, I don't seem to find an error in the server code which
works for several clients of mine for quite some time now.
Is this possibly a php problem in the recent version?
My client code looks like this:
try
{
$client = new SoapClient("http://someserver/server.php?wsdl", array('trace' => 1, 'feature' => SOAP_SINGLE_ELEMENT_ARRAYS));
}
catch(Exception $e)
{$this->handleException($e);}
Any thoughts on this would be highly appreciated.
TIA
K

Sounds like the XML is not well formatted. Is the WSDL generated or created manually?

Related

Script selenium python always detected as bot on flashseats :(

my script always detected why ?!!!!
most of time i use python selenium for scraping website but this time i'am always detected by "https://www.flashseats.com"
Can you help me please!!
here's part of my selenium code , i even try to use different proxies but :( same result,
please propose me a solution either in python or PHP.
chrome_options = webdriver.ChromeOptions()
options = webdriver.ChromeOptions()
options.add_argument('--disable-infobars')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--incognito')
options.add_argument('--disable-plugins-discovery')
options.add_argument('--start-maximized')
#_chrome_options = Options()
#_chrome_options.add_argument('disable-infobars')
driver = webdriver.Chrome(r'C:\browser\chromedriver.exe', chrome_options=chrome_options)
time.sleep(10)
driver.get("https://www.flashseats.com/")
I know that might be a late answer, but you can try using Selenium-Profiles or undetected-chromedriver for that.
To answer your question: You're most likely getting detected because of values in javascript like navigator.webdriver, which might be different than in a normal browser.

Youtube API v3 missing "creation date" in request

I'm trying to make Youtube v3 Data API work on my website.
I shamelessly copied this code from google's code samples, and it is not working. The error message showed is this:
An client error occurred: All cacheable requests must have creation dates.
I previously had issues with API keys as I forgot almost everything about APIs in general and I just thought this sample would have been useful to remember things. I managed to generate the appropriate key and now I know for sure it isn't the real problem.
Sadly Google didn't find posts related to this issue, except two links to the actual Php Library that I implemented in my site to make everything work. By looking at it closely I noticed a developer comment that could be useful.
$rawDate = $resp->getResponseHeader('date');
$parsedDate = strtotime($rawDate);
if (empty($rawDate) || false == $parsedDate) {
// We can't default this to now, as that means future cache reads
// will always pass with the logic below, so we will require a
// date be injected if not supplied.
throw new Google_Exception("All cacheable requests must have creation dates.");
}
I can understand english pretty well but I really don't know what to do now.
I even tried to add some sort of date in the request in my code, but it isn't working (you can laugh):
// Call the search.list method to retrieve results matching the specified
// query term.
$searchResponse = $youtube->search->listSearch('id,snippet', array(
'q' => $_GET['q'],
'maxResults' => $_GET['maxResults'],
'date' => strtotime(),
));
An client error occurred: (list) unknown parameter: 'date'
Any tips? Thank you in advance
EDIT: I know, this PHP library is currently in beta, but there must be some workaround.
EDIT 2: I found a temporary work around. I inverted the logic gate of that 'if' in the Php Library and now it works. But I don't like doing this, and I won't mark this as solved. At least if you know the reason of the bug please explain it to me, I'm really interested.

Access the webserver by using javascript instead of php

I'm now using phonegap to develop a application. I have found a similar php code which can assess to a local server here, but unfortunately phonegap doesn't support php.
Can anyone help me to 'translate' the php code below into JQuery ajax or any other javascript code? Thanks!
require_once('nusoap.php');
/* create client */
$endpoint = "http://www.pascalbotte.be/rcx-ws/rcx";
$ns = "http://phonedirlux.homeip.net/types";
$client = new soapclient($endpoint);
// queryRcx is the name of the method you want to consume
// RcxQuery_1 is the name of parameter object you have to send
// x and y are the names of the integers contained in the object
$result = $client->call('queryRcx',array('RcxQuery_1' => array('x' => 12,'y' => 13)), $ns);
print_r($result);
Step 1. Resolve the 404 associated with http://www.pascalbotte.be/rcx-ws-rpc/rcx?WSDL
Step 2. Get a JavaScript SOAP client.
Step 3. ... ... ...
Step 4. PROFIT!
Seriously though. All this really takes is a JavaScript based SOAP client. While they aren't a dime-a-dozen, they are pretty common. The one above is for jQuery, but it is easy enough to find other implementations.
The fact that the WSDL definition causes a 404 may or may not be a problem as the actual wsdl definition is technically optional, but you really want to figure out what happened.
You can add this header to the PHP file or .htaccess to avoid problems with cross domain reqs:
header('Access-Control-Allow-Origin: *');
Replace the all(*) with your domain ;)
Good luck!

Can use ASP to call PHP soap?

My customer has a PHP web service, that they want me to use.
It's PHP-based, while my web is ASP-based.
The ASP code looks like this:
Dim soapclient
WSDL_URL = "http://xxx.xxxx.xx/index.php?Action=service"
set soapclient = Server.CreateObject("MSSOAP.SoapClient30")
soapclient.ClientProperty("ServerHTTPRequest") = True
on error resume next
soapclient.mssoapinit WSDL_URL ' error here
Is ASP able to call a PHP-based soap service?
or
What should I adjust?
Thanks a lot!
The whole point of web services and SOAP is that it does not matter what language the service is implemented in and on what hardware and OS it runs.
Either there is a bug in the web service or (more likely) you're calling it in a wrong way.
I don't know ASP, I know PHP but you should have no problem accessing PHP web services from any other language, simply because the communication format is XML. Both applications would communicate using a third, intermediary language: XML. All should be fine.
We find a way to solve this question is not use "MSSOAP.SoapClient30" to ask web service, but "Msxml2.ServerXMLHTTP.4.0".
Sample code like this:
url = "http://xxx.xxx.xx/xxx.php"
SoapRequest="<?xml version="&CHR(34)&"1.0"&CHR(34)&" encoding="&CHR(34)&"utf-8"&CHR(34)&"?>"
"<soap:Envelope xmlns:xsi="&CHR(34)&"http://www.w3.org/2001/XMLSchema-instance"&CHR(34)&" xmlns:xsd="&CHR(34)&"http://www.w3.org/2001/XMLSchema"&CHR(34)&" xmlns:soap="&CHR(34)&"http://schemas.xmlsoap.org/soap/envelope/"&CHR(34)&"><soap:Body><getList></getList></soap:Body></soap:Envelope>"
Set xmlhttp = server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.Send(SoapRequest)
Response.Write xmlhttp.responseText
Set xmlhttp = Nothing
For starters you should remove the 'on error resume next' so you can see (and post) the error you're getting.

Moving from NuSOAP to PHP5 SOAP

I have been working on a script with PHP4 that relies on NuSOAP. Now, I'm trying to move this to PHP5, and use the buildin support for SOAP there.
$wsdlPath = ""; // I have obviously set these variables to something meaningful, just hidden for the sake of security
$apiPath = "";
$username = "";
$password = "";
// PHP5 style
$client = new soapclient($wsdlPath, array('login'=>username,
'password'=> $password,
'soap_version'=> SOAP_1_2,
'location'=> $apiPath,
'trace'=> 1));
// PHP4/NuSOAP style
$client = new soapclient($wsdlPath, true);
client->setEndpoint($apiPath);
$client->setCredentials($username, $password);
$client ->loadWSD);
The PHP5-version throws the following exception stacktrace:
EXCEPTION=SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://external-nbb.napi.norwegian.no.stage.osl.basefarm.net/api/napi1300?wsdl' in /home/eisebfog/public_html/database/norwegian.php:31
Stack trace:
#0 /home/eisebfog/public_html/database/norwegian.php(31): SoapClient->SoapClient('http://external...', Array)
#1 /home/eisebfog/public_html/database/index.php(53): require_once('/home/eisebfog/...')
#2 {main}
Now, as the NuSOAP version does work, and the pure PHP5 doesn't - it doesn't take a brain surgeon to figure out I'm doing something wrong. I have access to the .htaccess file, and through phpinfo() I have made sure that I'm running NuSOAP properly and running PHP5 when I should, and PHP4/Nusoap when I should.
Basically, I'm not very good with web services and soap - but if anyone has any ideas, i'd appreciate any input on what I'm doing wrong and how I can move to the native soap in PHP5. Btw, the reson I want this move in the first place is the assumed resource savings in native soap. I'd appreciate any links to benchmarks between these two solutions too.
Make sure NuSoap and PHPv5-SOAP are running on the same server. If I'm not totally wrong, both libraries uses the same class-name. Maybe it will work better if you make sure none NuSopa-files are included? And also verify that the SOAP-library are loaded:
if(!extension_loaded('soap')){
dl('soap.so'); // Actually a deprecated method. See "notes" at http://no.php.net/dl
}
I guess the version-field you refer to is defined as "SOAP 1.1" or similiar?
Best wishes :)
Btw: what are you working on? Exchange of delays from the pilot to the airport? Or perhaps a webservice which will decrease the waiting-time on luggage delivery at Osl? :p
We had very similar problems with PHP5 built-in SOAP client trying to consume a .NET-based Web-service. Also WSDL parsing failed reporting invalid schema. Putting the schema definitions into a single local file didn't help.
We gave up trying and switched to NuSOAP, which did work.
However, NuSOAP is far from perfect also. Right now I get into out-of memory situation during the parsing of 1MB+ responses. Erasing all the nasty debug code helped a little, but not radically.
Thus, looks like there's no 100% interoperable/functional SOAP client implementation in PHP at the moment.
Without testing it, I have two suggestions:
First, put your error_reporting to the highest possible (before creating the SoapClient):
error_reporting( E_ALL );
If there's something wrong with the authentication on the server's side, PHP will throw warnings. In most of the cases, it will tell you, what has gone wrong.
Second: I don't know if you can specifiy the 'location' option together with an URL to a wsdl. Theoretically, the wsdl tells your client, where the endpoint of the operations is, so you don't have to bother.

Categories