[PHP] cURL issues posting to an end point

2012-10-04 Thread Bastien Koert
Hi All,

I have a page that receives third party data into my app, xml data via
https post. This works fine and I receive the data as expected. The
issue I am facing is around posting XML data back as a synchronous
response to the post I receive. I am using the following code:

function sendXMLConfirmation($data)
{
  /*
   * XML Sender/Client.
   */
  // Get our XML. You can declare it here or even load a file.


  $xml_builder = '?xml version=1.0 encoding=utf-8?
Envelope version=01.00
Sender
Id/
Credential25412/Credential
/Sender
Recipient
Id/
/Recipient
TransactInfo transactType=response

TransactId'.$hash.'/TransactId
TimeStamp'.date(Y-m-d H:m 
).'/TimeStamp
Status
Code200/Code

ShortDescriptionSuccess/ShortDescription

LongDescriptionCANDIDATE Data transfer was a success/LongDescription
/Status
/TransactInfo
Packet
PacketInfo 
packetType=response
PacketId1/PacketId
ActionSET/Action
ManifestManifest 
Data/Manifest
Status
Code/

ShortDescription/

LongDescription/
/Status
/PacketInfo
Payload![CDATA[]]/Payload
/Packet
/Envelope
 ';


  // We send XML via CURL using POST with a http header of text/xml.
$ch = curl_init();

$url = 'https://staging.somesite.com/Sprocessor/DispatchMessage.asmx';

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);   // for https
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));

//Execute the request and also time the transaction ( optional )

$start = array_sum(explode(' ', microtime()));

$result = curl_exec($ch);

curl_close($ch);
// Print CURL result.
echo $ch_result;
}


The endpoint recipient says they are not receiving the data and I am
at a loss to figure out why. Any insight would be appreciated.

Thanks,

-- 

Bastien

Cat, the other other white meat

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



RES: [PHP] cURL issues posting to an end point

2012-10-04 Thread Alejandro Michelin Salomon
Bastien:

-Mensagem original-
De: Bastien Koert [mailto:phps...@gmail.com] 
Enviada em: quinta-feira, 4 de outubro de 2012 11:54
Para: PHP-General
Assunto: [PHP] cURL issues posting to an end point

Hi All,

I have a page that receives third party data into my app, xml data via https
post. This works fine and I receive the data as expected. The issue I am
facing is around posting XML data back as a synchronous response to the post
I receive. I am using the following code:

function sendXMLConfirmation($data)
{
  /*
   * XML Sender/Client.
   */
  // Get our XML. You can declare it here or even load a file.


  $xml_builder = '?xml version=1.0 encoding=utf-8?
Envelope version=01.00
Sender
Id/

Credential25412/Credential
/Sender
Recipient
Id/
/Recipient
TransactInfo
transactType=response

TransactId'.$hash.'/TransactId
TimeStamp'.date(Y-m-d H:m
).'/TimeStamp
Status
Code200/Code

ShortDescriptionSuccess/ShortDescription

LongDescriptionCANDIDATE Data transfer was a success/LongDescription
/Status
/TransactInfo
Packet
PacketInfo
packetType=response

PacketId1/PacketId
ActionSET/Action
ManifestManifest
Data/Manifest
Status
Code/

ShortDescription/

LongDescription/
/Status
/PacketInfo

Payload![CDATA[]]/Payload
/Packet
/Envelope
 ';


  // We send XML via CURL using POST with a http header of text/xml.
$ch = curl_init();

$url =
'https://staging.somesite.com/Sprocessor/DispatchMessage.asmx';

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);   // for https
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);

- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
-   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));

--- NEW 
$sPost = '/Sprocessor/DispatchMessage.asmx';
$sHost = ' https://staging.somesite.com';

curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'User-Agent: My Program',
'Accept-Encoding: gzip, deflate',
'POST ' . $sPost . ' HTTP/1.1',
'Host: ' . $sHost,
'Content-type: application/soap+xml; charset=utf-8',
'Content-Length: ' . strlen($xml_builder)
);

 END NEW -
//Execute the request and also time the transaction ( optional )

$start = array_sum(explode(' ', microtime()));

$result = curl_exec($ch);

curl_close($ch);
// Print CURL result.
echo $ch_result;
}


The endpoint recipient says they are not receiving the data and I am at a
loss to figure out why. Any insight would be appreciated.

Thanks,

-- 

Bastien

Cat, the other other white meat

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



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



Re: [PHP] cURL issues posting to an end point

2012-10-04 Thread Bastien Koert
On Thu, Oct 4, 2012 at 1:35 PM, Alejandro Michelin Salomon
amichel...@hotmail.com wrote:
 Bastien:

 -Mensagem original-
 De: Bastien Koert [mailto:phps...@gmail.com]
 Enviada em: quinta-feira, 4 de outubro de 2012 11:54
 Para: PHP-General
 Assunto: [PHP] cURL issues posting to an end point

 Hi All,

 I have a page that receives third party data into my app, xml data via https
 post. This works fine and I receive the data as expected. The issue I am
 facing is around posting XML data back as a synchronous response to the post
 I receive. I am using the following code:

 function sendXMLConfirmation($data)
 {
   /*
* XML Sender/Client.
*/
   // Get our XML. You can declare it here or even load a file.


   $xml_builder = '?xml version=1.0 encoding=utf-8?
 Envelope version=01.00
 Sender
 Id/

 Credential25412/Credential
 /Sender
 Recipient
 Id/
 /Recipient
 TransactInfo
 transactType=response

 TransactId'.$hash.'/TransactId
 TimeStamp'.date(Y-m-d H:m
 ).'/TimeStamp
 Status
 Code200/Code

 ShortDescriptionSuccess/ShortDescription

 LongDescriptionCANDIDATE Data transfer was a success/LongDescription
 /Status
 /TransactInfo
 Packet
 PacketInfo
 packetType=response

 PacketId1/PacketId
 ActionSET/Action
 ManifestManifest
 Data/Manifest
 Status
 Code/

 ShortDescription/

 LongDescription/
 /Status
 /PacketInfo

 Payload![CDATA[]]/Payload
 /Packet
 /Envelope
  ';


   // We send XML via CURL using POST with a http header of text/xml.
 $ch = curl_init();

 $url =
 'https://staging.somesite.com/Sprocessor/DispatchMessage.asmx';

 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);   // for https
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_TIMEOUT, 4);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);

 - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
 -   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));

 --- NEW 
 $sPost = '/Sprocessor/DispatchMessage.asmx';
 $sHost = ' https://staging.somesite.com';

 curl_setopt($ch, CURLOPT_HTTPHEADER,
 array(
 'User-Agent: My Program',
 'Accept-Encoding: gzip, deflate',
 'POST ' . $sPost . ' HTTP/1.1',
 'Host: ' . $sHost,
 'Content-type: application/soap+xml; charset=utf-8',
 'Content-Length: ' . strlen($xml_builder)
 );

  END NEW -
 //Execute the request and also time the transaction ( optional )

 $start = array_sum(explode(' ', microtime()));

 $result = curl_exec($ch);

 curl_close($ch);
 // Print CURL result.
 echo $ch_result;
 }


 The endpoint recipient says they are not receiving the data and I am at a
 loss to figure out why. Any insight would be appreciated.

 Thanks,

 --

 Bastien

 Cat, the other other white meat

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



Thanks, Alejandro,

So much closer that before, however I am getting an error on this.
Unexpected ';' on line 151 which is the closing array );

curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'User-Agent: My Program',
'Accept-Encoding: gzip, deflate',
'POST ' . $sPost . ' HTTP/1.1',
'Host: ' . $sHost,
'Content-type: application/soap+xml; charset=utf-8',
'Content-Length: ' . strlen($xml_builder)
);




-- 

Bastien

Cat, the other other white meat

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



RES: [PHP] cURL issues posting to an end point

2012-10-04 Thread Alejandro Michelin Salomon
Bastien:

curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'User-Agent: My Program',
'Accept-Encoding: gzip, deflate',
'POST ' . $sPost . ' HTTP/1.1',
'Host: ' . $sHost,
'Content-type: application/soap+xml; charset=utf-8',
'Content-Length: ' . strlen($xml_builder) 
 ) --- This is missing
);

Alejandro M.S
-Mensagem original-
De: Bastien Koert [mailto:phps...@gmail.com] 
Enviada em: quinta-feira, 4 de outubro de 2012 15:49
Para: Alejandro Michelin Salomon
Cc: PHP-General
Assunto: Re: [PHP] cURL issues posting to an end point

On Thu, Oct 4, 2012 at 1:35 PM, Alejandro Michelin Salomon
amichel...@hotmail.com wrote:
 Bastien:

 -Mensagem original-
 De: Bastien Koert [mailto:phps...@gmail.com] Enviada em: quinta-feira, 
 4 de outubro de 2012 11:54
 Para: PHP-General
 Assunto: [PHP] cURL issues posting to an end point

 Hi All,

 I have a page that receives third party data into my app, xml data via 
 https post. This works fine and I receive the data as expected. The 
 issue I am facing is around posting XML data back as a synchronous 
 response to the post I receive. I am using the following code:

 function sendXMLConfirmation($data)
 {
   /*
* XML Sender/Client.
*/
   // Get our XML. You can declare it here or even load a file.


   $xml_builder = '?xml version=1.0 encoding=utf-8?
 Envelope version=01.00
 Sender
 Id/

 Credential25412/Credential
 /Sender
 Recipient
 Id/
 /Recipient
 TransactInfo 
 transactType=response

 TransactId'.$hash.'/TransactId
 
 TimeStamp'.date(Y-m-d H:m ).'/TimeStamp
 Status
 
 Code200/Code

 ShortDescriptionSuccess/ShortDescription

 LongDescriptionCANDIDATE Data transfer was a success/LongDescription
 /Status
 /TransactInfo
 Packet
 PacketInfo 
 packetType=response

 PacketId1/PacketId

ActionSET/Action
 
 ManifestManifest Data/Manifest
 Status
 
 Code/

 ShortDescription/

 LongDescription/
 /Status
 /PacketInfo

 Payload![CDATA[]]/Payload
 /Packet
 /Envelope
  ';


   // We send XML via CURL using POST with a http header of text/xml.
 $ch = curl_init();

 $url =
 'https://staging.somesite.com/Sprocessor/DispatchMessage.asmx';

 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);   // for https
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_TIMEOUT, 4);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);

 - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:
text/xml'));
 -   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));

 --- NEW 
 $sPost = '/Sprocessor/DispatchMessage.asmx';
 $sHost = ' https://staging.somesite.com';

 curl_setopt($ch, CURLOPT_HTTPHEADER,
 array(
 'User-Agent: My Program',
 'Accept-Encoding: gzip, deflate',
 'POST ' . $sPost . ' HTTP/1.1',
 'Host: ' . $sHost,
 'Content-type: application/soap+xml; charset=utf-8',
 'Content-Length: ' . strlen($xml_builder) );

  END NEW -
 //Execute the request and also time the transaction ( optional 
 )

 $start = array_sum(explode(' ', microtime()));

 $result = curl_exec($ch);

 curl_close($ch);
 // Print CURL result.
 echo $ch_result;
 }


 The endpoint recipient says they are not receiving the data and I am 
 at a loss to figure out why. Any insight would be appreciated.

 Thanks,

 --

 Bastien

 Cat, the other other white meat

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



Thanks, Alejandro,

So much closer that before, however I am getting an error on this.
Unexpected ';' on line 151 which is the closing array );

curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'User-Agent: My Program',
'Accept-Encoding: gzip, deflate