Skip to Content
0
Oct 16, 2019 at 06:34 AM

QueryDocumentOutputRequestIn Web Service

130 Views

Hi every body,

I would like to retreive all Customers invoices PDF.

I am not experimented with using the SAP API and I need some help.

To retreive the PDF, I wrote a PHP Script using Curl and QueryDocumentOutputReques Web Service.

While testing it, I enabled CURL verbose and always got a "500 internal error".

However, I saw the authentication was correct. Therefore, I thought it was my request which was wrong.

You can find below, my php CURL use and my request.

Thank you to everybody who can help.

Extract of my PHP script:

39 function RecupUrl($url,$request)

40 {

41 $headers = array(

42 "Content-type:text/xml",

43 "Accept: multipart/form-data",

44 "Cache-Control: no-cache",

45 "Pragma: no-cache",

46 "SOAPAction: <url>",

47 "Content-length: ".strlen($request),

48 );

49

51 $ch = curl_init();

52

53 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

54 curl_setopt($ch, CURLOPT_VERBOSE, 1);

55 curl_setopt($ch, CURLOPT_URL, $url);

56 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

57 curl_setopt($ch, CURLOPT_USERPWD, 'XXXXX:PPPPP); // XXXX=user name, PPPPP=Password

58 curl_setopt($ch, CURLOPT_POST, 1);

59 curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" );

60 curl_setopt($ch, CURLOPT_POSTFIELDS,$request);

61 curl_setopt($ch, CURLOPT_FAILONERROR, true);

62 curl_setopt($ch, CURLOPT_FORBID_REUSE, true);

63 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);

67 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

68

69 curl_setopt($ch, CURLOPT_HEADER, array(

70 "Content-Type: multipart/form-data"

71 ));

73 $data = curl_exec($ch);

74 curl_close($ch);

76 return $data;

78 }

The request :

$request='

<?xml version="1.0" encoding="utf-8"?>

http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob=" http://sap.com/xi/SAPGlobal20/Global">

<soapenv:Header/>

<soapenv:Body>

<glob:DocumentOutputRequestPdf_sync>

<DocumentOutputRequestPDFInformation>

<ReadByDocumentUUID>XXXX-XXXX-XXXX</ReadByDocumentUUID>

</DocumentOutputRequestPDFInformation>

</glob:DocumentOutputRequestPdf_sync>

</soapenv:Body>

</soapenv:Envelope>';