PHP Classes
elePHPant
Icontem

QTransfer: Send HTTP requests and process XML responses

Recommend this page to a friend!
  Info   View files View files (16)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2009-05-17 (7 years ago) RSS 2.0 feedNot enough user ratingsTotal: 450 All time: 5,865 This week: 970Up
Version License PHP version Categories
qtransfer 0.1.1GNU General Publi...5.0XML, HTTP, PHP 5
Description Author

This package can be used to send HTTP requests and process XML responses.

There is one class that can send and receive HTTP requests and another can process the request responses.

There are also other classes to process the HTTP XML responses.

Picture of Tom Schaefer
  Performance   Level  
Name: Tom Schaefer <contact>
Classes: 39 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 9x

Winner: 1x

Details
---------
QTransfer
---------

QTransfer is a collection of classes which can be used for exchanging
data in xml format between servers language independently.
You can use it i.e. for ASP or SAAS software application based on php.

The request scheme (xsd) can be delivered to a customer who gets an API
like interface for producing valid xml based requests.

The sample setup demonstrates how to
- setup xsd schemes,
- prepare request xml data streams which request specific application data
- validate incoming responses


Sample Setup Request XML:

	$request = new Transfer_XmlRequest("Test","Module","index");
	$request->setSchema("request");
	$request->render(); // renders the domdocument to string
	if($request->isValid()) {
		$requestXML = $request->getXml(); // pure XML
	} else {
		echo "invalid request";
		exit;
	}

Q:	What does this piece of code?
A:	It builds a xml and checks its integrity. This xml is laterly send to a server
	which processes the incoming xml structure.

	sample xml output:
	<?xml version="1.0" encoding="UTF-8"?>
		<transfer>
			<head>
				<context>Test</context>
				<module>Module</module>
				<action>index</action>
				<checksum>--40 chars long checksum string here--</checksum>
				<format>xml</format>
				<version>0.1.1</version>
			</head>
			<body>
			</body>
		</transfer>

Q: Why do I have to validate the request?
A: Suppose you want to deliver some data to a customer from your server. The customer
   only has to know how to send a xml stream to a specific adress and that he will receive
   a xmlml response. He must not know anything about server language etc.. He only
   has to know how to setup his request for being able to receive xml data.
   The validation of the xml, which is send by the customer, is helps to
   avoid failures. If a xml validation fails then he knows that something went
   wrong. The major advantage of such a validation is? A customer's server and the serving host
   must not be speak the same language. So it is language independent.
   You can write PHP and your customer writes JSP, does not matter.



Sample customer request sends the xml to the hosted service front-controller etc.:

	$c	= Transfer_Curl::getInstance()
		->doPostXML("http://www.query4u.de/test/index.php",$requestXML);


The variable $c gets the response xml. Now, the response can be validated
against a reponse schema which is parametrized like the request.

	$response = new Transfer_XmlResponse("Test","Module","index");
	$response->setSchema("response");
	$response->setOutput($c);
	$response->render();

	if($response->isValid()) {
		header("content-type: text/xml");
		echo $response->getXml();
	} else {
		echo "invalid response";
	}

Now you have the requested results in xml format which can be easily
processed by any system.
  Files folder image Files  
File Role Description
Files folder imagesamples (3 files)
Files folder imageclasses (1 file, 1 directory)
Files folder imageschemes (1 directory)
Accessible without login Plain text file readme Data readme

  Files folder image Files  /  samples  
File Role Description
  Accessible without login Plain text file config.inc.php Conf. sample configuration
  Accessible without login Plain text file index.php Example sample
  Accessible without login Plain text file index2.php Example sample: same as above but shorter

  Files folder image Files  /  classes  
File Role Description
Files folder imageTransfer (7 files)
  Accessible without login Plain text file index.php Aux. include script

  Files folder image Files  /  classes  /  Transfer  
File Role Description
  Plain text file Curl.php Class Curl Object
  Plain text file CurlResponse.php Class CurlResponse Object
  Plain text file XmlRequest.php Class DomXml Request Builder
  Plain text file Checksum.php Class Checksum Builder
  Accessible without login Plain text file index.php Aux. autoloader
  Plain text file Xml.php Class DomXml Working Class
  Plain text file XmlResponse.php Class DomXml Response Builder

  Files folder image Files  /  schemes  
File Role Description
Files folder imagever0.1.1 (4 files)

  Files folder image Files  /  schemes  /  ver0.1.1  
File Role Description
  Accessible without login Plain text file request.xml Data request xml template
  Accessible without login Plain text file request.xsd Data request schema
  Accessible without login Plain text file response.xml Data response xml template
  Accessible without login Plain text file response.xsd Data response schema

Downloadqtransfer-2009-05-17.zip 20KB
Downloadqtransfer-2009-05-17.tar.gz 15KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Checksum Download .zip .tar.gz build the checksum for the request and response xml Recommended
 Version Control Unique User Downloads Download Rankings  
 0%
Total:450
This week:0
All time:5,865
This week:970Up