我正在製作php/c#控制檯應用程序/ c#soap服務,並且在Web服務中創建了許多功能,但我無法調用其中一個他們。即使它在測試表單中正常工作,也無法調用Web服務功能
我調用的函數是一個從數據庫中獲取字符串值的函數。呼叫工作正常的Windows(使用本地主機),但把它當到Linux服務器下單運行我得到一個異常說明如下:
功能(「getLastResetTime」),是不是這個服務
有效的方法
奇怪的是,從Linux服務器我可以通過訪問asmx文件並運行getLastResetTime函數來訪問測試表單,它返回所期望的,它似乎是PHP不能做的電話。
下面是我使用PHP來調用腳本代碼
function getLastResetTime()
{
include ("../../config.php");
include ("../../includes/get-settings.php");
include ("../../includes/general.php");
try
{
$client = new SoapClient("http://192.168.1.74/EmailServer/EmailSoapService/EmailSoapService.asmx?WSDL", array("trace" => 1, "exception" => 0));
$result = $client->__soapCall("getLastResetTime", array());
echo "Last Reset: " . $result->getLastResetTimeResult;
}
catch (Exception $e)
{
echo $e->getMessage();
}
}
下面的截圖證明了Web方法是工作單之下,它返回什麼
以下是網絡服務功能的代碼
[WebMethod(Description = "Gets the time the Email Server last reset")]
public string getLastResetTime()
{
SoapHandler soapHandler = new SoapHandler();
return soapHandler.getLastResetTime();
}
以下是Web服務調用
public string getLastResetTime()
{
try
{
using (ConnectDb db = new ConnectDb(appSettings))
{
string query = "SELECT * FROM settings";
using (MySqlCommand cmd = new MySqlCommand(query, db.conn))
{
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
if (reader.GetString("setting") == "app_lastRestart")
{
return reader.GetString("value");
}
}
}
}
}
return "N/A";
}
catch (MySqlException ex)
{
return ex.Message;
}
}
我不明白爲什麼這是行不通的,我猜我可能失去了一些東西很簡單,但無法找到它的代碼。
感謝您提供的任何幫助。