Advertisement
Guest User

Untitled

a guest
Dec 1st, 2016
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. $soapUrl = "https://wsvc.cdiscount.com/ProductCatalogService.svc/soap"; // asmx URL of WSDL
  2. $soapUser = "seller@feedub.com"; // username
  3. $soapPassword = $this->TokenId; // password
  4.  
  5. // xml post structure
  6.  
  7. $xml_post_string = '
  8. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cdis="http://www.cdiscount.com/" xmlns:cdis1="http://schemas.datacontract.org/2004/07/Cdiscount.Framework.Core.Communication.Messages" xmlns:sys="http://schemas.datacontract.org/2004/07/System.Device.Location" xmlns:cdis2="http://schemas.datacontract.org/2004/07/Cdiscount.Service.ProductCatalog.External.Contract.Message">
  9. <soapenv:Header/>
  10. <soapenv:Body>
  11. <cdis:CheckProductsAvailable>
  12. <!--Optional:-->
  13. <cdis:headerMessage>
  14. <cdis1:Context>
  15. <cdis1:CatalogID>1</cdis1:CatalogID>
  16. <cdis1:CustomerPoolID>1</cdis1:CustomerPoolID>
  17. <cdis1:SiteID>100</cdis1:SiteID>
  18. </cdis1:Context>
  19. <cdis1:Localization>
  20. <cdis1:Country>Fr</cdis1:Country>
  21. <cdis1:Currency>Eur</cdis1:Currency>
  22. <cdis1:DecimalPosition>2</cdis1:DecimalPosition>
  23. <cdis1:Language>Fr</cdis1:Language>
  24. </cdis1:Localization>
  25. <cdis1:Security>
  26. <cdis1:DomainRightsList> </cdis1:DomainRightsList>
  27. <cdis1:IssuerID>?</cdis1:IssuerID>
  28. <cdis1:SessionID>?</cdis1:SessionID>
  29. <cdis1:TokenId>bb5f70da20154ec98e5b8e90d1bfac7c</cdis1:TokenId>
  30. <cdis1:UserName>pp</cdis1:UserName>
  31. </cdis1:Security>
  32. <cdis1:Version>1.0</cdis1:Version>
  33. </cdis:headerMessage>
  34. <!--Optional:-->
  35. <cdis:products>
  36. <cdis2:ListProducts>
  37. <!--Zero or more repetitions:-->
  38. <cdis2:CheckProductQuantity>
  39. <cdis2:ProductId>1</cdis2:ProductId>
  40. <cdis2:Quantity>1</cdis2:Quantity>
  41. </cdis2:CheckProductQuantity>
  42. </cdis2:ListProducts>
  43. </cdis:products>
  44. </cdis:CheckProductsAvailable>
  45. </soapenv:Body>
  46. </soapenv:Envelope>
  47. ';
  48.  
  49. $headers = array(
  50. "Content-type: text/xml;charset=\"utf-8\"",
  51. "Accept: text/xml",
  52. "Namespace: http://tempuri.org",
  53. "Cache-Control: no-cache",
  54. "Pragma: no-cache",
  55. "SOAPAction: http://www.cdiscount.com/IProductCatalogExternalService/CheckProductsAvailable",
  56. "Content-length: ".strlen($xml_post_string),
  57. ); //SOAPAction: your op URL
  58.  
  59. $url = $soapUrl;
  60.  
  61. // PHP cURL for https connection with auth
  62. $ch = curl_init();
  63. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  64. curl_setopt($ch, CURLOPT_URL, $url);
  65. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  66. curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
  67. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  68. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  69. curl_setopt($ch, CURLOPT_POST, true);
  70. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
  71. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  72.  
  73. // converting
  74. $response = curl_exec($ch);
  75. curl_close($ch);
  76.  
  77. // converting
  78. $response1 = str_replace("<soap:Body>","",$response);
  79. $response2 = str_replace("</soap:Body>","",$response1);
  80.  
  81. // convertingc to XML
  82. //$parser = simplexml_load_string($response2);
  83.  
  84. var_dump($response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement