[英]PHP Soap Client __getLastRequest() empty
我不得不道歉,我意識到Stack Overflow上有很多這樣的問題....甚至可能滿滿的...... :)
我正在使用PHP的內置soap客戶端對soap服務進行Web調用。 根據wsdl,它期望我傳遞的項目是一個字符串。 沒有文檔而不是wsdl和公司聲明它是xml。 所以我已經構建了一個對象,並在php中將其轉換為xml,並且他們已經確認xml看起來正確他們期望的內容。
這是我班上的方法
$options = array( 'trace' => 1, 'exceptions' => 1, "features" => SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new SoapClient($this->submitUrl."?WSDL", $options);
$client->InsertLeadInformation($xml);
print_r($client->__getLastRequest());
我已經回應了調用上方的xml並且它看起來正確但是當我傳遞它時__getLastRequest()肥皂信封是空的?
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://xxxxxxxx.com/webservices2"><SOAP-ENV:Body><ns1:InsertLeadInformation/></SOAP-ENV:Body></SOAP-ENV:Envelope>
有人有想法么? 先感謝您
我能夠解決這個問題,我不確定它是否需要在每個soap調用中使用這種方式,但是我必須將傳入的xml添加到索引為sLeadInfo的數組中,因為它是包含元素的XML。 我之前添加了我的xml,但這似乎不起作用。 您可以在gerenateXML()的倒數第二行看到編輯
這是針對saleslogix的,只要有人好奇並尋找答案
private function generateXML(){
$xml = new stdClass();
$xml->LeadCapture = new stdClass();
$xml->LeadCapture->Common = new stdClass();
$xml->LeadCapture->Common->DataSource = $this->dataSource;
$xml->LeadCapture->Common->TrackId = $this->trackId;
$xml->LeadCapture->Common->leadSourceCode = $this->leadSourceCode;
$xml->LeadCapture->Person = new stdClass();
$xml->LeadCapture->Person->FirstName = $this->firstname;
$xml->LeadCapture->Person->LastName = $this->lastName;
$xml->LeadCapture->Person->Title = $this->title;
$xml->LeadCapture->Person->Email = $this->email;
$xml->LeadCapture->Person->Phone = $this->phone;
$xml->LeadCapture->Person->Fax = $this->fax;
$xml->LeadCapture->Person->Address1 = $this->address1;
$xml->LeadCapture->Person->Address2 = $this->address2;
$xml->LeadCapture->Person->City = $this->city;
$xml->LeadCapture->Person->State = $this->state;
$xml->LeadCapture->Person->PostalCode = $this->postalCode;
$xml->LeadCapture->Person->Note = $this->note;
$xml->LeadCapture->Company = new stdClass();
$xml->LeadCapture->Company->CompanyName = $this->companyName;
$xml->LeadCapture->Company->Address1 = $this->companyAddress1;
$xml->LeadCapture->Company->Address2 = $this->companyAddress2;
$xml->LeadCapture->Company->City = $this->companyCity;
$xml->LeadCapture->Company->State = $this->companyState;
$xml->LeadCapture->Company->PostalCode = $this->companyPostalCode;
$xml->LeadCapture->Company->Country = $this->companyCountry;
$result = array('sLeadInfo'=>php_object_to_xml::object_to_xml($xml));
return $result;
private function submitDataSoap($xml) {
$xmlstring = $xml;
$options = array( 'trace' => 1, 'exceptions' => 1, "features" => SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new SoapClient($this->submitUrl."?WSDL", $options);
$result = $client->InsertLeadInformation($xmlstring);
print_r($result);
//print_r($xml);
//print_r($client->__getLastRequest());
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.