问题描述
我需要将 Navision 连接到我的 PHP 应用程序。我尝试使用我在论坛中阅读过的不同方式,但它们都不起作用。我不知道我是否应该使用 SOAP、cURL 或其他,有人可以指导我吗?
编辑:
我尝试了以下代码,但它也不起作用。
$opts = array(
'http' => array(
'user_agent' => 'PHPSoapClient'
)
);
$context = stream_context_create($opts);
$client = new SoapClient('http://URL:7047/DynamicsNAV/WS/COMPANY/Page/mypage?wsdl/',['trace' => 1,'cache_wsdl' => WSDL_CACHE_NONE,'stream_context' => $context,'user_agent' => 'USERAG','soap_version' => SOAP_1_2]);
$security = array(
'UserName' => array(
'UserName'=>'COMPANY\MYUSER','Password'=>'mypass',)
);
$client->__getLastResponse();
$header = new SoapHeader('ChannelFactory','Credentials',$security,false);
$client->__setSoapHeaders($header);
$checkVatParameters = array(
'level' => '01');
$result = $client->checkVat($checkVatParameters);
print_r($result);
try {
$ret = $client->getAllItm();
print_r($ret);
}catch(Exception $e){
echo $e->getMessage();
}
致命错误:未捕获的 SoapFault 异常:[WSDL] SOAP-ERROR:解析 WSDL:无法从 myurl 加载
解决方法
$.soap({
url: "http://url:7047/DynamicsNAV/WS/COMPANY/Page/ws_myws",data: {
user: "user",pass: "pass"
},dataType: "jsonp",jsonpCallback: "jsonp_callback",crossDomain: true,HTTPHeaders: {
'Content-Type': 'application/xml','Server-Protocol':'SOAP'
},success: function (response){
response = $.format(response.toString(),{method: 'xml' });
$("#output").text(response);
}
})
回应: http://url/WS/COMPANY/Page/ws_myws net::ERR_CONNECTION_TIMED_OUT