02-26-2009 3:32 PM
Hi @ all,
I would like to send an HTTP Request with an XML File in the body to an SAP System
I have the target URL and the a XML File.
Now the question is. Is it possible to use something like the HTTP_POST FuBa to send an url post request with an xml file?
If yes can anybody give me a hint?
I have a php script which exactly do this coding. But to integrate it all in one system it is necessary to transform it into ABAP and call it there.
// compose url and request and call send function
function test($productID, $categoryID) {
// create url
$PIhost = "XXX.wdf.sap.corp";
$PIport = "50080";
$PIurl = "/sap/xi/adapter_plain";
$PIurl .= "?sap-client=800";
$PIurl .= "&service=XXX";
$PIurl .= "&namespace=XXX";
$PIurl .= "&interface=Frontend_Interface";
$PIurl .= "&qos=EO";
$PIurl .= "&sap-user=XXX";
$PIurl .= "&sap-password=XXX";
// create xml
$request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$request .="<n1:FrontendInbound_MessageType xmlns:n1=\"http://crmpiebay.com\">\n";
$request .= "\t<FrontendInbound>\n";
$request .= "\t\t<ProductName/>\n";
$request .= "\t\t<ProductCategory>".$categoryID."</ProductCategory>\n";
$request .= "\t\t<ProductID>".$productID."</ProductID>\n";
$request .= "\t\t<MessageID/>\n";
$request .= "\t</FrontendInbound>\n";
$request .= "</n1:FrontendInbound_MessageType>";
// send http request
postToHost($PIhost, $PIport, $PIurl, $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/".$_SERVER["PHP_SELF"], $request);
}
// send post request to PI server
function postToHost($host, $port, $path, $referer, $data_to_send) {
$fp = fsockopen($host, $port);
if($fp) {
$res="";
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Referer: $referer\r\n");
fputs($fp, "Content-type: text/plain\r\n");
fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data_to_send);
while(!feof($fp)) {
$res .= fgets($fp, 128);
}
fclose($fp);
return $res;
}
}
Would be great if anybody could give me a hint how to solve such a HTTP Post request with XML body data.
Thanks in advance.
Chris
Edited by: Christian Kuehne on Feb 26, 2009 4:32 PM
07-01-2009 7:55 PM
07-09-2009 9:44 AM
hi friend could you please share your solution regarding this query if u got it already?