Showing posts with label rest. Show all posts
Showing posts with label rest. Show all posts

Soap vs Rest website services

http://www.blisswebsolution.com/web-development-and-designing-services-company.html
Web services are increasingly becoming popular these days because of their usefulness.
When it comes to truly cross software communication, only web services come in spare.
And #XML is the most common language for electronic communications.
Let us try our hands on it.
We are converting XML document to PHP array with help of web services, as follows.
namespace Application\Parse;
use SimpleXMLIterator;
use SimpleXMLElement;
$xml = simplexml_load_string($xml
string, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
Just take care that, in XML tags, numbers alone are NOT allowed, some text should be there in front of numbers.
Otherwise it may create errors during conversion.
Similarly, reverse conversion from PHP array to XML document is also few lines of code as given below.
function to_xml(SimpleXMLElement $object, array $data)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
$new_object = $object->addChild($key);
to_xml($new_object, $value);
} else {
$object->addChild($key, $value);
}
}
}
$xml = new SimpleXMLElement('<rootTag
/>');
to_xml($xml, $my_array)
And then, print it to verify
print $xml->asXML();
With help of web services, we can
- Create a #REST_client
- Create a #REST_server
- Create a #SOAP_client
- Create a #SOAP_server
To fix website or mobile app related complex problems, feel free to contact us at: http://www.blisswebsolution.com/web-development-and-designing-services-company.html