I am trying to use the XMLWriter class in PHP to generate XML. I am working in CodeIgniter. When I try to output XML, I get this error (HTTP wrapper does not support writeable connections). What does it mean and what do I need to do to fix it? I am using this class here: http://www.phpbuilder.com/board/showthread.php?t=10356853.
What's your output call look like? That error usually means you're trying to save to an http url, e.g. like:
$myobj->save('http://example.com/path/file.xml');
which generally will fail. This requires an HTTP upload, but provides none of the specifics necessary to perform one. Should it be a PUT? A POST? What's the fieldname the receiving server is expecting? etc...
Related
I am currently writing my own server in C++ for Posix systems. Before anyone says anything about how I should really use a prebuilt server, please be aware that I do use prebuilt servers for anything business related. This project is entirely a learning experience.
I would like this system to support server side scripting as well as static hosting. I run into a problem when I try to include support for the most important server side scripting language: PHP.
Standard PHP provides several predefined variables that give access to information about an incoming request. It also provides standard HTTP functions that interact with the request in specific ways. Further, it is supposed to be possible to perform IO operations on the request and response bodies by using the filenames php://input and php://output respectively to refer to the appropriate socket and permissions.
I know that I would be able to define all these variables and implement all these functions myself in the top of a wrapper script and then use include to run the user's script in the same context, but that seems cumbersome. I also have no idea how to map php://input or php://output to the actual request socket's file descriptor.
I don't know much about PHP interpreters. Is there a way to provide essential request data (user-agent, INET address, method, URI, version, headers, socket file descriptor, and maybe something I'm forgetting) to the PHP interpreter to be able to access the native definitions and implementations of these variables and functions? Or is it standard practice for the author of the server to define and implement these himself?
Most important, if I do have to implement these things myself, how do I map php://input and php://output to the correct file descriptor and permissions?
Thanks to everyone. Any help is appreciated.
I need to implement a SOAP server that will respond to a third-party application that behaves as a SOAP client.
The server should be in PHP, so I started using nusoap and http://www.wsdltophp.com/ to generate the skeleton.
Here's the wsdl file they gave me:
http://pastebin.com/YXBbszqE
The guy from support said I should start with the Ping request, because it's the most simple and straightforward to implement.
I'm new to this and will really appreciate some help.
Here's what I have so far for the server:
http://pastebin.com/vARst5t0
and to simulate the client:
http://pastebin.com/seG7EmM6
and it gives me an error:
http://pastebin.com/Say6FmF6
Thanks a lot, guys.
EDIT:
I found that on the server, after disabled the error_reporting, I don't receive the previous error.
I forgot to mention that I use the nusoap feature of loading the wsdl file and not defining each complexType manually, but it's still not working, now I get the following error:
Operation 'Ping' is not defined in the WSDL for this service.
And I'm sure it is there.
Maybe it comes from the options you chose when generating the package. Indeed, when calling the MySoapServicePing::Ping() method, parameters are maybe not sent properly : contained by an array or not. So try modifying the generation behaviour and send the request again.
You may also look to the XML request sent to the SOAP server in order to ensure that it does not come from the request. To get the XML request, you can call the MySoapWsdlClass::getSoapClient()->__getLastRequest() method or the $mySoapServicePing->getLastRequest() method (depends on the version of the generator) after sending the request.
Let me know if it changes anything or not.
Thank you guys, I ended up using the php native functions and it was much easier to configure.
How does PHP's function xmlrpc_encode_request() work?
Does it need the value of allow_url_fopen set to true?
Well, you access external URLs with this function, so does it need this configuration? I can't test it myself at the moment, unfortunately.
Thanks in advance!
No, it does not. This function is just for marshalling the requested function name and its parameters. It builds an XML string. Therefore it does not need to retrieve external URLs itself.
So this function in itself is not particular useful. Later on you will need to send the XML-encoded RPC request over an HTTP stream. And in this step 2, you need either allow_url_fopen, the curl extension, or the pecl http functions. Most XML-RPC libraries however provide a means to transmit the RPC request in HTTP via PHPs native socket functions.
So in essence, allow_url_fopen is not required.
I'm using Zend XML-RPC Client library to send XML requests to another non-PHP XML RPC server.(it's a java JBoss install, but I don't have control to change it/patch it/hack it). One request I'm making has a <nil/> element, which is a XML-RPC extension. The XML-RPC server I'm talking to doesn't support that because the request fails with Failed to parse XML-RPC request: Unknown type: nil.
Is there any way to tell Zend to not send the <nil/> value and send something else instead? Others have asked this before: http://framework.zend.com/issues/browse/ZF-1919
I don't think so, however:
The array of parameters for the remote method can contain native PHP types,
Zend_XmlRpc_Value objects, or a mix of each.
You actually have full control over the type of parameters passed to the remote method. Converting null values to empty strings before sending the request should be trivial, isn't it?
I know that this is a simple question for PHP guys but I don't know the language and just need to do a simple "get" from another web page when my page is hit. i.e. signal the other page that this page has been hit.
EDIT: curl is not available to me.
If curl wrappers are on (they are per default), you can use:
file_get_contents('http://www.example.org');
Note that this happens synchronous, so before the request has completed, your page won't either. It would be better to log access to a logfile (or database) and export the data occasionally. Alternatively, you could do the request after your page has completed, and output has been sent to the client.
Beware file_get_contents() and fopen():
If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail.
There's numerous ways... the simplest is file_get_contents('http://...');
Other functions like fopen() also support http: streams.
If you need more control, I'd suggest looking at curl (see curl_init)
There are a number of ways to send a GET request with PHP. As mentioned above, you can use file_get_contents, fopen or cURL.
You can also use the HTTP extension, the fsockopen() function or streams via fopen.
I'd advise checking out what WordPress has done, as it handles almost all possibilities.
You'll probably want to use cURL