Active
Project:
Web service client
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Jan 2013 at 16:20 UTC
Updated:
6 Jan 2013 at 16:20 UTC
Hi,
I see this example: http://drupal.org/node/1114320
And have this CURL code from this website:http://www.pfz.nl/forum/topic/2656-httppost-voor-xml-met-bevestiging/
What I would like is to set/alter the price of products using this XML webservice of a supplier
/**
* Define POST URL and also payload
*/
define('XML_PAYLOAD', '<PRINTING_QUOTATION>
<SALES_ORGANISATION>3400</SALES_ORGANISATION>
<CUSTOMER_NUMBER>80842***</CUSTOMER_NUMBER>
<CONTACT_PERSON>4141484</CONTACT_PERSON>
<LOGIN>4141484</LOGIN>
<PASSWORD>80842***</PASSWORD>
<PRODUCT_PRINT_ID>40000485</PRODUCT_PRINT_ID>
<QUANTITY>100</QUANTITY>
<PRINTING_POSITION>
<PRINTING_POSITION_ID>T-TOP</PRINTING_POSITION_ID>
<PRINT_SIZE_HEIGHT>50</PRINT_SIZE_HEIGHT>
<PRINT_SIZE_WIDTH>50</PRINT_SIZE_WIDTH>
<PRINTING_TECHNIQUE>
<ID>E</ID>
<COLORS>1</COLORS>
</PRINTING_TECHNIQUE>
</PRINTING_POSITION>
<PRINTING_POSITION>
<PRINTING_POSITION_ID>BOTTOM</PRINTING_POSITION_ID>
<PRINT_SIZE_HEIGHT>30</PRINT_SIZE_HEIGHT>
<PRINT_SIZE_WIDTH>30</PRINT_SIZE_WIDTH>
<PRINTING_TECHNIQUE>
<ID>T1</ID>
<COLORS>4</COLORS>
</PRINTING_TECHNIQUE>
</PRINTING_POSITION>
</PRINTING_QUOTATION>');
define('XML_POST_URL', 'http://b2b.midoceanbrands.com/invoke/b2b.main/get_print_price_xml');
/**
* Initialize handle and set options
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, XML_POST_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, XML_PAYLOAD);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
/**
* Execute the request and also time the transaction
*/
$start = array_sum(explode(' ', microtime()));
$result = curl_exec($ch);
$stop = array_sum(explode(' ', microtime()));
$totalTime = $stop - $start;
/**
* Check for errors
*/
if ( curl_errno($ch) ) {
$result = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
} else {
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
switch($returnCode){
case 404:
$result = 'ERROR -> 404 Not Found';
break;
default:
break;
}
}
/**
* Close the handle
*/
curl_close($ch);
/**
* Output the results and time
*/
echo 'Total time for request: ' . $totalTime . "\n";
echo $result;
/**
* Exit the script
*/
exit(0);
Can anyone help to brng this to drupal wsclient code?
Thanks a lot in advance,
greetings, Martijn