2012-04-27 41 views
0

我已經成功讀取WSDL表單SoapClient。我嘗試以下操作值傳遞給Web方法和讀取結果:如何閱讀PHP中的.Net Web服務?

$client = new SoapClient("restaurant.asmx?wsdl"); 
$param = array('search_keywords'=>$search_text); 
$result = $client->__soapCall('getRestaurantsASP',$param); 
print_r($result); 

我得到這個錯誤:

Fatal error: Uncaught SoapFault exception: [soap:Server] 
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> 
System.Data.SqlClient.SqlException: Invalid object name 'basic_info_table'. at 
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean 
breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException 
exception, Boolean breakConnection) at 
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at 
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, 
SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject 
stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at 
System.Data.SqlClient.SqlDataReader.get_MetaData() at 
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior 
runBehavior, String resetOptionsString) at 
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, 
RunBehavior runBehavior in E:\webareas\gs937\aspservice.php on line 73 

我如何將參數傳遞給Web方法和檢索值?

+0

在服務器端看起來像是一個問題,特別是SQL查詢的問題。 – DaveRandom 2012-04-27 11:54:01

+0

但是當我測試它使用測試頁時,它返回值罰款。 – 2012-04-27 12:18:35

回答

0

我不得不添加:

<webServices> 
<protocols> 
    <add name="HttpGet"/> 
    <add name="HttpPost"/> 
    <add name="HttpSoap"/> 
</protocols> 
</webServices> 

在Web.config文件中把事情的工作。

0

正如DaveRandom所建議的,問題似乎是服務本身,而問題在於用於服務的SQL查詢。

嘗試使用SoapUI(您可以從http://sourceforge.net/projects/soapui/files/下載它)並從那裏執行服務方法。

SoapUI是一箇中立的客戶端來測試web服務。

希望它會有所幫助。