2013-03-25 3 views
0

을 사용하여 ASP.net에서 DataTable을 반환했습니다. ASP.net WebService 메서드에서 반환되는데이터를 올바르게 "소비"하는 방법을 알고 싶습니다.WebService를 사용하는 방법 PHP

나는이 예에서 작동 :

ASP.net의 WEBSERVICE :

[WebMethod] 
public DataTable searchDatabase(string search) 
{ 

    SqlConnection conn = null; 
    SqlDataReader rdr = null; 
    conn = new 
        SqlConnection("Data Source=ASUSX301A\\MSSQLINSTANCE;Initial Catalog=db_sp_vaje;Integrated Security=True;Pooling=False"); 
    conn.Open(); 

    // 1. create a command object identifying 
    //  the stored procedure 
    SqlCommand cmd = new SqlCommand(
     "dbo.sp_iskanje", conn); //here is my stored procedure which works 100% 

    // 2. set the command object so it knows 
    // to execute a stored procedure 
    cmd.CommandType = CommandType.StoredProcedure; 

    // 3. add parameter to command, which 
    // will be passed to the stored procedure 
    cmd.Parameters.Add(
     new SqlParameter("@myInput", search)); 

    // execute the command 
    SqlDataAdapter da = new SqlDataAdapter(); 
    da.SelectCommand = cmd; 
    DataTable dt = new DataTable(); 
    dt.TableName = "oglasi"; 
    dt.WriteXml(@"path", true); 
    da.Fill(dt); 

    // iterate through results, printing each to console 


    return dt; 
} 

를 내가 ASP.net에서이 웹 서비스를 호출 할 경우 잘 작동 & 내가 루프 데이터 테이블에서 결과를 얻을 수 있습니다.

이제 PHP에서 표시/반향 할 수있는 webservice에서이 데이터 테이블을 어떻게 가져올 수 있습니까?

지금까지 나는이 내 PHP 파일에 있습니다 : (BTW : 나는 호출하는 경우 기본하여 HelloWorld() PHP에서 ASP.net에서 웹 서비스 방법은 잘 작동)

$client = new SoapClient("http://localhost:10994/WebService.asmx?WSDL"); 
$params->Param1 = "car"; //this is search variable 
$result = $client->searchDatabase($params)->searchDatabaseResult; 

print_r ($result); 

그리고 결과는 다음과 같습니다 php error

$params->search = "car"; //this is search variable 

그것은 나를 위해 좋은 일하고,하지만 난 행과 열이 작동하는 방법을 알고하지 않습니다

+0

안녕하세요! 오랜 시간이지만 위에서 설명한 프로젝트에서 일하고 있습니다. 내 문제는 반환 된 DataTable의 열과 행을 조작하는 방법입니다. successfuly 함수를 호출 할 수 있지만 DataTable의 결과는 하나의 문자열로 함께 있습니다. 문제를 해결할 수 있습니까? – pafivi

답변

0

당신이 시도 했 s :-(

0

나는 이런 식으로 시도하고 잘 작동합니다.

$client = new SoapClient("http://localhost/WebService.asmx?WSDL"); 
$result = $client->__soapCall("functionName", array($SoapCallParameters)); 

var_dump($result->functionNameResult); 
관련 문제