0
我收到此錯誤肥皂在PHP中,不能讓它工作
Server was unable to process request. ---> Object reference not set to an instance of an object.
我要來試圖學習如何從PHP使用SOAP服務,香港專業教育學院用C#這樣做,只是嘗試新事物。但我得到上面的錯誤,我不知道爲什麼,這是調用我嘗試訪問「call」
生病附加C#如果有幫助的東西。
謝謝!
代碼PHP
<?php
try{
$opts = array(
'https'=>array(
'user_agent' => 'PHPSoapClient'
));
$context = stream_context_create($opts);
$userC = array("UserName"=>"pato.api",
"Password"=>"745477",
"ApplicationID"=>getGUID(),
"ClientID"=>getGUID());
$Session = array("SessionId"=>getGUID());
$soap_client = new SoapClient("https://onlineavl2api-mx.navmanwireless.com/onlineavl/api/V1.3/service.asmx?WSDL",array("stream_context" => $context,"cache_wsdl" => "WSDL_CACHE_NONE"));
$request = array("UserCredentials"=>$userC,"Session"=>$Session,"IPAdress"=>"0.0.0.0","ClockVerificationUtc"=>date("Y-m-d") . 'T' . date("H:i:s"));
$vec = array("request"=>$request);
$quote = $soap_client->DoLogin($vec);
echo $quote->DoLoginResponse;
} catch (SoapFault $ex) {
echo $ex->getMessage();
}
function getGUID(){
if (function_exists('com_create_guid')){
return com_create_guid();
}else{
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid =substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
return $uuid;
}
}
?>
代碼C#中使用你的PHP腳本以下更新
public DoLoginResponse Login()
{
var Client = new ServiceSoapClient();
var request = new DoLoginRequest()
{
Session = new SessionInfo()
{
SessionId = Guid.NewGuid()
},
UserCredential = new UserCredentialInfo()
{
UserName = _User,
Password = _Password,
ApplicationID = Guid.NewGuid(),
ClientID = Guid.NewGuid()
}
};
var response = new DoLoginResponse();