Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用web服务php获取数据库_Php_Web Services_Wsdl - Fatal编程技术网

如何使用web服务php获取数据库

如何使用web服务php获取数据库,php,web-services,wsdl,Php,Web Services,Wsdl,我需要使用web服务在php中显示数据库表内容。在那里,我将WSDL服务与php一起使用。这是我试过的代码 Test.php <?php /* Initialize webservice with your WSDL */ $client = new SoapClient("http://localhost:23995/Service1.svc?wsdl"); /* Invoke webservice method with your parameters, in this case

我需要使用web服务在php中显示数据库表内容。在那里,我将WSDL服务与php一起使用。这是我试过的代码

Test.php

<?php

/* Initialize webservice with your WSDL */
$client = new SoapClient("http://localhost:23995/Service1.svc?wsdl");


/* Invoke webservice method with your parameters, in this case: Function1 */
$response = $client->__soapCall("SelectUserDetails", array());



/* Print webservice response */
print_r($response);

?>

如何使用php在HTML表格中显示这些数据库值?根据您的输出,响应是一个对象。如果您不熟悉php对象,例如,我可以提供以下代码来访问这些对象。 在PHP中,您可以通过以下方式访问和对象:

$myObject = new stdClass(); //creating an object for demo
$myObject->name = 'My Name';
$myObject->address = 'My address1';

echo $myObject->name; // Output: My Name

echo $myObject->address; // Output: My address1
在响应中,变量$response具有以下成员:

SelectUserDetailsResult // An Object with two members ('schema' & 'any'). In which schema is null, but you have some data in the member 'any'.
您可以访问成员“任意”,如下所示:

$allEmails = $response->SelectUserDetailsResult->any;

通过这种方式,您可以使用此变量在任何html中打印其值。

您的$response是一个对象。因此,您可以通过$response->SelectUserDetailsResult->获取“any”的值any@Shan你能提供一些示例代码吗。。请注意,因为我是web service.shan新手,“'any'”的含义是什么@SachithMW请参见问题中的输出响应,有一个成员变量'any'shan,根据这个问题和他的输出假设1=userid rooter=username 12345=passwordrooter@gmail.com=电子邮件,然后,如何获取数据库中的所有用户名,以及如何在数据库中获取这些值table@Shan "1rooter12345rooter@gmail.com“不是一封电子邮件。这是1=userID rooter=username 12345=passwordrooter@gmail.com=email如何分别获取每个值,我的意思是id列为1,username列为rooter,如ewisei,要将用户名、密码和电子邮件从这个字符串中分离出来非常困难,因为没有分隔符/没有通用模式。
$allEmails = $response->SelectUserDetailsResult->any;