我正在通过Web服务在bd中进行插入,最后它给了我RecordID
,因此我可以在另一个Web服务中使用它。
使用SoapUI 5.5.0程序,我得到了这个结果。
<soap: Envelope xmlns: soap = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: xsd = "http://www.w3.org/2001/XMLSchema" xmlns: xsi = "http: //www.w3.org/2001/XMLSchema-instance ">
<soap: Body>
<ns1: createDataResponse xmlns: ns1 = "http://3e.pl/ADInterface">
<StandardResponse RecordID = "1011142" xmlns = "http://3e.pl/ADInterface" />
</ns1: createDataResponse>
</soap: Body>
</soap: Envelope>
这是我的代码。我正在使用codeigniter。
public function web_service($soapMethod,$soap){
$this->load->helper('xml');
// Change the url
$endpoint = 'http://192.168.0.196:1024/ADInterface/services/ModelADService';
// Basic Auth (optional)
$soapUser = '';
$soapPassword = '';
$headers = array(
'Content-type: text/xml;charset="utf-8"',
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache',
// Maybe change this url
'SOAPAction: ' . $endpoint . '/' . $soapMethod,
'Content-length: ' .strlen($soap),
);
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');
// Basic Auth (optional)
curl_setopt($ch, CURLOPT_USERPWD, $soapUser. ':' .$soapPassword);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soap);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Invoke request
$response = curl_exec($ch);
if($response === false) {
echo 'HTTP error: ' . curl_error($ch);
exit;
}
curl_close($ch);
$response = xml_convert($response);
return $response;
}
我希望我对我的解释很好