Re: RES: XML/PHP web service

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
the two options offers here are ok. But please make it secure!

Regards

Carlos

Am 09.08.2012 14:38, schrieb Alejandro Michelin Salomon:
> Philip :
> 
> Try this:
> 
> Client:
> 
> $client = new SoapClient( null, array( 'encoding' => 'utf-8', 'soap_version'
> => SOAP_1_2, 'trace' => 1, 
>                                  'uri' => 'tns: Server', 'location' => 'php
> server URL here'));
> 
> // Cut off <?xml version="1.0" encoding="utf-8"?>, to not have two xml start
> tag in the soap message.
> $xmlres = $client->__soapCall( 'ProXML', array( str_replace( '<?xml
> version="1.0" encoding="utf-8"?>'."\n", '', $sXml )));
> 
> echo '<pre>', $xmlres, '</pre>'; // print the xml output or
> var_export($xmlres, true) if $xmlres is an array.
> 
> 
> SERVER:
> 
> 
> class Receiver
> {
>     public function ProXML ( $sXML )
>     {
> 
>         libxml_use_internal_errors(true); // enabled use libxml errors
> 
>         // try..catch to cacth simplexmlelement errors
>         try
>         {
>             $xml = new SimpleXMLElement( '<?xml version="1.0"
> encoding="utf-8"?>' . $sXML ); // Try to create a xml object with the string
> passed
>         } catch (Exception $e) {
>             
>             $aErrors = libxml_get_errors(); // get errors
> 
>         		foreach ( $aErros as $oErro )
> 		      {
>                     switch ( $oErro->level )
>                     {
>                         case LIBXML_ERR_WARNING:
>                             $sCod .= '<return><code>' . $oErro->code .
> '</code><menssage>' . utf8_encode( 'warning: ' . $oErro->message ) .
>                                     '</menssage></return>';
>                     break;
>                 case LIBXML_ERR_ERROR:
>                     $sCod .= '<resposta><codigo>' . $oErro->code .
> '</code><menssage>' . utf8_encode( 'Error: ' . $oErro->message ) .
>                              '</menssage></return>';
>                     break;
>                  case LIBXML_ERR_FATAL:
>                     $sCod .= '<resposta><codigo>' . $oErro->code .
> '</code><menssage>' . utf8_encode( ' Fatal Error: ' . $oErro->message ) .
>                              '</menssage></return>';
>                      break;
>                     }
>                  }
>         }
> 
>         work here ...
> 
>     }
> 
> }
> 
> 
> $server = new SoapServer(null, array( 'uri' => 'tns: Server' ));
> 
> $server->setClass('Receiver');
> 
> $server->handle();
> 
> 
> 
> 
> Alejandro M.S
> 
> -----Mensagem original-----
> De: Phillip Baker [mailto:phillip@xxxxxxxxxxxx] 
> Enviada em: quarta-feira, 8 de agosto de 2012 19:12
> Para: php-general@xxxxxxxxxxxxx
> Assunto:  XML/PHP web service
> 
> Greetings all,
> 
> I am looking for some options here.
> 
> I am in need of creating a service on our web server that will always be
> available and automated.
> It will accept an XML file.
> 
> I will be checking to see if the XML file is valid and then passing it on to
> another server.
> But I need to accept this file without using a submit form.
> I have never done anything like this and looking for ideas.
> 
> I am using a lamp environment and looking for suggestions.
> 
> I am looking to set this up so that our vendors can set up scripts to
> automatically post XML files to our servers.
> 
> Blessed Be
> 
> Phillip
> 
> "In the Jim Crow South, for example, government failed and indeed refused to
> protect blacks from extra-legal violence. Given our history, it's stunning
> we fail to question those who would force upon us a total reliance on the
> state for defense."
> -- Robert J. Cottrol
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux