0

I am trying to integrate the SOAP xml request using PHP CURL method I have tried a lot of methods to get a response from the client system but always goes for a failed message. Below is the code which I am trying it,

    <?php 



$envelope = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:rbss="RBSS"><soap:Header/><soap:Body><rbss:PushData><!--Optional:--><rbss:xml><RBSS><ead_Response_DateTime>20-05-2016 10:25:16 </Lead_Response_DateTime><Lead_Push_DateTime>20-05-2016 10:25:16 </Lead_Push_DateTime><Lead_Recd_DataTime>20-05-2016 10:25:16 </Lead_Recd_DataTime><FirstName>Ismail</FirstName><Phone1>7760120077</Phone1><Phone2>7760120077</Phone2><Email>test@gmail.com</Email><DOB>20-05-2016</DOB><Age>25</Age><Child_DOB>20-05-2002</Child_DOB><Child_Age></Child_Age><Pincode>400052</Pincode><City_Name>Bangalore</City_Name><Address>2, Akshardhamů..</Address><Annual_Income>1000000</Annual_Income><Annual_Income_Slab></Annual_Income_Slab><SMS_Keyword></SMS_Keyword><Short_Code></Short_Code><Circle_Operator></Circle_Operator><Sum_Assured></Sum_Assured><Premium_Pitched></Premium_Pitched><Company_Name>WRS </Company_Name><Website_Name>indiainverstors.in </Website_Name><UTN_Source>FaceBook </UTN_Source><Lead_Source></Lead_Source><Type_Of_Lead></Type_Of_Lead><Verification_Type></Verification_Type><Product_Name></Product_Name><Product_Category></Product_Category><No_of_Companies></No_of_Companies><Names_of_Companied></Names_of_Companied><SMS_Message_Sent></SMS_Message_Sent><Customer__Remarks></Customer__Remarks><FLAG></FLAG><Lead_Type>INCOMING_WEB</Lead_Type><Channel_Type>INTERNET</Channel_Type><Mode_Type>PREFIXED_APPOINTMENT</Mode_Type><Source_Type>Valueleaf</Source_Type><Campaign_Type>APR_16</Campaign_Type><Opportunity_Id>123456</Opportunity_Id><PROSPECT_ID></PROSPECT_ID><Title>MR</Title><UID></UID><LastName>Malik</LastName><Gender>Male</Gender><MaritalStatus></MaritalStatus><MobileNo>7760120077</MobileNo><AgeAtRetirement></AgeAtRetirement><VendorCSE_Name></VendorCSE_Name><TermOfPlan></TermOfPlan><Smoker_NonSmoker></Smoker_NonSmoker><VendorCode></VendorCode><MeetingDate>20-01-2017</MeetingDate><MeetingTime></MeetingTime><City_ID>11</City_ID><ID>123</ID><CallcenterID></CallcenterID><ADDLInfo1></ADDLInfo1><ADDLInfo2></ADDLInfo2></RBSS></rbss:xml></rbss:PushData></soap:Body></soap:Envelope>';

$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "http://company.service.com/IPRU_PFA_Vendor_Data/Service.asmx?op=PushData");
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST,           true );            
curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $envelope); 
curl_setopt($soap_do, CURLOPT_HTTPHEADER, array("Content-Type: text/xml", "Content-length: ".strlen($envelope))); 

$result = curl_exec($soap_do);
print_r($result);

curl_close($soap_do);
if($result==true)
{
    echo "success";
}
else
{
    echo "Something went wrong";
}

?>

Everytime the else statement is giving the output. Can anyone say me where exactly I am going wrong.

Riteu
  • 57
  • 2
  • 2
  • 10
  • try setting the `CURLOPT_RETURNTRANSFER` to false – Flakes Oct 24 '17 at 10:35
  • If i set it to false I will not be getting any response right? – Riteu Oct 24 '17 at 10:39
  • Yes. But you are checking if it is true only? – Flakes Oct 24 '17 at 10:41
  • yes i need to know the response when the request has been sent so that I can capture at my end. – Riteu Oct 24 '17 at 10:43
  • Are you expecting a true/false as a response? It will be string on success or false on failure. see : https://stackoverflow.com/questions/16452636/php-curl-what-does-curl-exec-return – Flakes Oct 24 '17 at 10:44
  • 1
    I have changed the CURLOPT_RETURNTRANSFER to false and it works, and has you said it returns only string either 0 or 1. But if i want to get the response message from the client server..? – Riteu Oct 24 '17 at 10:53
  • I did not say it will return either 0 or 1.I said _It will be string on success or false on failure_. Please check the curl page in the manual – Flakes Oct 24 '17 at 10:59
  • Ya sorry it was string which it gives back. – Riteu Oct 24 '17 at 11:01
  • But how can i load the string value which will be giving in a xml format? – Riteu Oct 24 '17 at 12:06
  • That is another question. please post it as a new one. – Flakes Oct 24 '17 at 12:12

0 Answers0