Intereting Posts

Как отправить запрос XML-мыла с помощью php curl

Я отправляю запрос через мыло, используя php curl, получая java Exception. Когда я запрашиваю ответ, я получаю ошибку. Я много пробовал в конце, но проблема не решена.

$soap_request = "<?xml version=\"1.0\"?>"; $soap_request .= "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"; $soap_request .= " <soap:Body>\n"; $soap_request .= " <RevodocLead xmlns='http://localhost/'>\n"; $soap_request .= " <inode>\n"; $soap_request .= " <version>1.0</version>\n"; $soap_request .= " <sourceuserid>test@test.in</sourceuserid>\n"; $soap_request .= " <sourceid>18641254455</sourceid>\n"; $soap_request .= " <dealercode>1458445284</dealercode>\n"; $soap_request .= " <created>18-12-2015 13:45EST</created>\n"; $soap_request .= " <browser>Android Browser</browser>\n"; $soap_request .= " <os>Macintosh</os>\n"; $soap_request .= " <agent>atinek@gmail.com</agent>\n"; $soap_request .= " <product>mortgage-renewal</product>\n"; $soap_request .= " <name>success</name>\n"; $soap_request .= " <address>success</address>\n"; $soap_request .= " <email>success</email>\n"; $soap_request .= " <phone>success</phone>\n"; $soap_request .= " <propertyvalue>325000</propertyvalue>\n"; $soap_request .= " <mortgage>300000</mortgage>\n"; $soap_request .= " <referralcode>F3S2A2</referralcode>\n"; $soap_request .= " <note>value</note>\n"; $soap_request .= " <futurecontact>yes</futurecontact>\n"; $soap_request .= " </inode>\n"; $soap_request .= " </RevodocLead>\n"; $soap_request .= " </soap:Body>\n"; $soap_request .= "</soap:Envelope>"; $header = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: myactionMethod", "Content-length: ".strlen($soap_request), ); $soap_do = curl_init(); curl_setopt($soap_do, CURLOPT_URL, $url ); curl_setopt($soap_do, CURLOPT_HEADER, false); curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 100); curl_setopt($soap_do, CURLOPT_TIMEOUT, 100); 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, $soap_request); curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header); if(curl_exec($soap_do) === false) { $err = 'Curl error: ' . curl_error($soap_do); curl_close($soap_do); print $err; } else { $result = curl_exec($soap_do); echo '<pre>'; print_r($result); curl_close($soap_do); //print 'Operation completed without any errors'; } 

Я получаю ошибку

soap: Serverjava.lang.ClassCastException: java.lang.String не может быть добавлено в javax.xml.bind.JAXBElement

Пожалуйста, проверьте код ниже. Он отлично работает.

 class RevodocLeadSoapClient extends SoapClient { function __construct($wsdl, $options) { parent::__construct($wsdl, $options); $this->server = new SoapServer($wsdl, $options); } public function __doRequest($request, $location, $action, $version) { $result = parent::__doRequest($request, $location, $action, $version); return $result; } function __anotherRequest($call, $params) { $location = 'https://www.t1.revodoc.com/ws/services/RevoLeadWebService'; $action = 'http://localhost/'.$call; $request = '<?xml version="1.0" encoding="UTF-8" standalone="no"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:typens="https://secure.maventa.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <SOAP-ENV:Body> <RevodocLead xmlns="http://localhost/">'; $request .= $params; $request .= '</RevodocLead> </SOAP-ENV:Body> </SOAP-ENV:Envelope>'; $result =$this->__doRequest($request, $location, $action, '1'); return $result; } } // Create new SOAP client $wsdl = 'https://www.t1.revodoc.com/ws/services/RevoLeadWebService?wsdl'; $client = new RevodocLeadSoapClient($wsdl, array( 'cache_wsdl' => WSDL_CACHE_NONE, 'cache_ttl' => 86400, 'trace' => true, 'exceptions' => true, )); $operations = "RevodocLead"; $soap_request .= "<inode>"; $soap_request .= "<version>1.0</version>"; $soap_request .= "<sourceuserid>test@test.in</sourceuserid>"; $soap_request .= "<sourceid>18641254455</sourceid>"; $soap_request .= "<dealercode>1458445284</dealercode>"; $soap_request .= "<created>18-12-2015 13:45EST</created>"; $soap_request .= "<browser>Android Browser</browser>"; $soap_request .= "<os>Macintosh</os>"; $soap_request .= "<agent>atinek@gmail.com</agent>"; $soap_request .= "<product>mortgage-renewal</product>"; $soap_request .= "<name>success</name>"; $soap_request .= "<address>success</address>"; $soap_request .= "<email>success</email>"; $soap_request .= "<phone>success</phone>"; $soap_request .= "<propertyvalue>325000</propertyvalue>"; $soap_request .= "<mortgage>300000</mortgage>"; $soap_request .= "<referralcode>F3S2A2</referralcode>"; $soap_request .= "<note>value</note>"; $soap_request .= "<futurecontact>yes</futurecontact>"; $soap_request .= "</inode>"; // Make the request try { $request = $client->__anotherRequest($operations, $soap_request); } catch (SoapFault $e ){ echo "Last request:<pre>" . htmlentities($client->__getLastRequest()) . "</pre>"; exit(); } //Print Response. #RevodocLeadResponse echo '<pre><b>', htmlentities($request), '</b></pre>';