尝试使用SAP B1 9.2的Web服务时遇到错误(OrdersService-> GetByParams):
env:Sender-Unknown SOAP Command
我可以登录,注销并从OrdersService.wsdl调用Update方法没有问题 这是我调用OrdersService-> GetByParams方法的代码。
<?php
error_reporting(E_ALL);
try{
$OrdersService = new GetByParams("http://shockwave/B1WS/WebReferences/OrdersService.wsdl");
$headers = array();
$headers[] = new SoapHeader('http://shockwave/B1WS/Service.asmx','SessionID', '3A8F8F0E-D114-4F6B-8BCC-509F55F4406F');
$headers[] = new SoapHeader('http://shockwave/B1WS/Service.asmx','ServiceName','OrdersService');
$OrdersService->__setSoapHeaders($headers);
$parametros =array('DocEntry'=>'2390');
$respuesta = $OrdersService->GetByParams($parametros);
}
catch (SoapFault $fault) {
$error = 1;
print(" <h1>Error, idiota<br> ".$fault->faultcode."-".$fault->faultstring);
echo "<br>Request: \n".htmlspecialchars($OrdersService->__getLastRequest()) ."\n";
echo "<br>Response: \n".htmlspecialchars($OrdersService->__getLastResponse())."\n";
}
class GetByParams extends SoapClient {
function __doRequest($request, $location, $action, $version, $one_way = null) {
$namespace = "http://www.sap.com/SBO/DIS";
$request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="'.$namespace.'"', $request, 1);
$request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
$request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request);
$request = preg_replace('/UTF-8/', 'UTF-16', $request, 1);
return parent::__doRequest($request, $location, $action, $version, $one_way = null);
}
}
// <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="OrdersService" xmlns:ns2="http://shockwave/B1WS/Service.asmx">
// <SOAP-ENV:Header>
// <ns2:SessionID>3A8F8F0E-D114-4F6B-8BCC-509F55F4406F</ns2:SessionID>
// <ns2:ServiceName>OrdersService</ns2:ServiceName>
// </SOAP-ENV:Header>
// <SOAP-ENV:Body>
// <ns1:GetByParams/>
// </SOAP-ENV:Body>
// </SOAP-ENV:Envelope>
?>
代码登录:
$LoginService = new LoginSoap("http://XXXXX/B1WS/WebReferences/LoginService.wsdl");
echo "<pre>";
$options = array(
'DatabaseServer' => 'shockwave',
'DatabaseName' => 'XXXX',
'DatabaseType' => 'XXXX',
'CompanyUsername' => 'XXXX',
'CompanyPassword' => 'XXXX',
'Language' => 'ln_Spanish',
'LicenseServer' => 'XXXX:30000',
);
$LoginId = $respuesta->SessionID;
unset($LoginService);
//Logueamos
$respuesta = $LoginService->Login($options);
echo "Login ...<br><h1>Logueado ID: ".$respuesta->SessionID."</h1>";
Code LogOut:
//LogOut
$respuesta = $LoginService->Logout($LoginId);
echo "<br>Logout ... ";
echo '<h1>Deslogueado';
echo "</pre>";