Jump to content

SOAP with cURL


dfowler

Recommended Posts

Hey guys,

I have several SOAP requests that I have been asked to convert to cURL.  How easy is this to do?  Are there any shortcuts methods?  Here is just one of the request:

 

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:con="Conferencing">
       <soap:Header/>
       <soap:Body>
          <con:SecurityValidateEmployeeLogOn>
             <con:request>
                <con:WebId></con:WebId>
                <con:Password></con:Password>
                <con:EmployeeLogin></con:EmployeeLogin>
                <con:EmployeePassword></con:EmployeePassword>
             </con:request>
          </con:SecurityValidateEmployeeLogOn>
       </soap:Body>
    </soap:Envelope>

 

Thanks for any help!

Link to comment
https://forums.phpfreaks.com/topic/128553-soap-with-curl/
Share on other sites

Ok, I've been working on this by myself, and here is where I am now:

 

<?php
ini_set('error_reporting', E_ALL);

$content = '<?xml version="1.0" encoding="utf-8" &#63;>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SecurityValidateEmployeeLogOn xmlns="Conferencing">
      <request>
        <EmployeeLogin>?</EmployeeLogin>
        <EmployeePassword>?</EmployeePassword>
      </request>
    </SecurityValidateEmployeeLogOn>
  </soap12:Body>
</soap12:Envelope>';
$content = utf8_encode($content); 
$content_length = strlen($content); 

$header = array(
"POST ".$url." HTTP/1.1\r\n",
"Host: ".$host."\r\n",
"Content-Type: application/soap+xml; charset=utf-8\r\n",
"Content-Length: ".$content_length."\r\n",
$content
); 

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);      
curl_close($ch);

echo $output;
?> 

 

I left off the $url and $host on purpose.  I am getting a connect, but I keep getting the message "Length Required".  Can anybody help me from here?

Link to comment
https://forums.phpfreaks.com/topic/128553-soap-with-curl/#findComment-667496
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.