Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $soapUrl = "https://wsvc.cdiscount.com/ProductCatalogService.svc/soap"; // asmx URL of WSDL
- $soapUser = "seller@feedub.com"; // username
- $soapPassword = $this->TokenId; // password
- // xml post structure
- $xml_post_string = '
- <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">
- <soapenv:Header/>
- <soapenv:Body>
- <cdis:CheckProductsAvailable>
- <!--Optional:-->
- <cdis:headerMessage>
- <cdis1:Context>
- <cdis1:CatalogID>1</cdis1:CatalogID>
- <cdis1:CustomerPoolID>1</cdis1:CustomerPoolID>
- <cdis1:SiteID>100</cdis1:SiteID>
- </cdis1:Context>
- <cdis1:Localization>
- <cdis1:Country>Fr</cdis1:Country>
- <cdis1:Currency>Eur</cdis1:Currency>
- <cdis1:DecimalPosition>2</cdis1:DecimalPosition>
- <cdis1:Language>Fr</cdis1:Language>
- </cdis1:Localization>
- <cdis1:Security>
- <cdis1:DomainRightsList> </cdis1:DomainRightsList>
- <cdis1:IssuerID>?</cdis1:IssuerID>
- <cdis1:SessionID>?</cdis1:SessionID>
- <cdis1:TokenId>bb5f70da20154ec98e5b8e90d1bfac7c</cdis1:TokenId>
- <cdis1:UserName>pp</cdis1:UserName>
- </cdis1:Security>
- <cdis1:Version>1.0</cdis1:Version>
- </cdis:headerMessage>
- <!--Optional:-->
- <cdis:products>
- <cdis2:ListProducts>
- <!--Zero or more repetitions:-->
- <cdis2:CheckProductQuantity>
- <cdis2:ProductId>1</cdis2:ProductId>
- <cdis2:Quantity>1</cdis2:Quantity>
- </cdis2:CheckProductQuantity>
- </cdis2:ListProducts>
- </cdis:products>
- </cdis:CheckProductsAvailable>
- </soapenv:Body>
- </soapenv:Envelope>
- ';
- $headers = array(
- "Content-type: text/xml;charset=\"utf-8\"",
- "Accept: text/xml",
- "Namespace: http://tempuri.org",
- "Cache-Control: no-cache",
- "Pragma: no-cache",
- "SOAPAction: http://www.cdiscount.com/IProductCatalogExternalService/CheckProductsAvailable",
- "Content-length: ".strlen($xml_post_string),
- ); //SOAPAction: your op URL
- $url = $soapUrl;
- // PHP cURL for https connection with auth
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- // converting
- $response = curl_exec($ch);
- curl_close($ch);
- // converting
- $response1 = str_replace("<soap:Body>","",$response);
- $response2 = str_replace("</soap:Body>","",$response1);
- // convertingc to XML
- //$parser = simplexml_load_string($response2);
- var_dump($response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement