B
B
bigtrouble2015-06-23 14:29:36
PHP
bigtrouble, 2015-06-23 14:29:36

SOAP client or curl request, which is better?

Hello everyone, the parsing of information from the mail of Russia through has been working for a long time SoapClient, often requests hang, now we are thinking of using a parsing library, which under the hood itself generates requests and sends data via curl.
Actually the question is the following - is the game worth the candle? Perhaps native SoapClientis better suited for these purposes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-06-23
@zenden2k

Why not combine? For example:

class SOAPHttpSender extends SoapClient 
{
    /**
    * Overrides the __doRequest method of SoapClient
    * 
    * @param $request Values to be sent via post/get method
    * @param $location WSDL 
    * @param $action Soap action
    * @param $version Soap version
    * @return $response Boolean
    */
    public function __doRequest($request,$location,$action,$version)
    {
        // Modify as per your requirement. For example, check out the Api-Key, user agent, soap action, etc. that we need to send in HTTP Header.
        $headers = array('Method: POST','Connection: Close','User-Agent: YOUR-USER-AGENT','Content-Type: text/xml','Api-Key:XYZ','SOAPAction: "'.$action.'"', 'SOAPVersion: "'.$version.'"'); 

        $ch = curl_init($location);
        curl_setopt_array($ch, array(CURLOPT_VERBOSE => FALSE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $request, CURLOPT_HEADER => FALSE, CURLOPT_HTTPHEADER => $headers));
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;
    }	
}
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question