 |
ขอสอบถามพี่ๆหน่อยครับ จาก PHP Create - Call Web Service สร้างและเรียกเว็บเซอร์วิส ด้วย PHP แล้วขึ้น error Warning: Creating default object from empty value |
|
 |
|
|
 |
 |
|
ขอสอบถามพี่ๆหน่อยครับ จาก PHP Create - Call Web Service สร้างและเรียกเว็บเซอร์วิส ด้วย PHP แล้วขึ้น error Warning: Creating default object from empty value in C:\xampp\htdocs\webservice\WebServiceServer.php on line 10

อันนี้ code
Code (PHP)
<?php
require_once("lib/nusoap.php");
//Create a new soap server
$server = new soap_server();
//Define our namespace
$namespace = "http://localhost/webservice/webserviceserver.php";
$server->wsdl->schemaTargetNamespace = $namespace;
//Configure our WSDL
$server->configureWSDL("HelloWorld");
// Register our method and argument parameters
$varname = array(
'strName' => "xsd:string",
'strEmail' => "xsd:string"
);
$server->register('HelloWorld',$varname, array('return' => 'xsd:string'));
function HelloWorld($strName,$strEmail)
{
return "Hello, World! Khun ($strName , Your email : $strEmail)";
}
// Get our posted data if the service is being consumed
// otherwise leave this data blank.
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
exit();
?>
พอ run WebServiceClient.php
มันจะแจ้ง false
อันนี้ หน้า client
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com</title>
</head>
<body>
<?php
require_once("lib/nusoap.php");
$client = new nusoap_client("http://localhost/webservice/WebServiceServer.php?wsdl",true);
$params = array(
'strName' => "test webservice",
'strEmail' => "[email protected]"
);
$data = $client->call("HelloWorld",$params);
echo json_encode($data);
?>
</body>
</html>
Tag : PHP, Web Services
|
ประวัติการแก้ไข 2019-11-28 10:22:03 2019-11-28 10:22:04
|
 |
 |
 |
 |
Date :
2019-11-27 15:46:01 |
By :
erlnw001 |
View :
1029 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใช้ version ล่าสุดดูหรือยังครับ หรือไม่ก็ปิด
Code (PHP)
error_reporting(0);
|
 |
 |
 |
 |
Date :
2019-11-27 16:27:33 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
PHP Version อะไรครับ
|
 |
 |
 |
 |
Date :
2019-11-27 16:37:09 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองสลับ code ในหน้า server เป็นแบบนี้แล้วCode (PHP)
require_once("lib/nusoap.php");
//Create a new soap server
$server = new soap_server();
//Define our namespace
$namespace = "http://localhost/nusoap/WebServiceServer.php";
//$server->wsdl->schemaTargetNamespace = $namespace;
//Configure our WSDL
$server->configureWSDL("HelloWorld");
$server->wsdl->schemaTargetNamespace = $namespace;
//Register our method and argument parameters
$varname = array(
'strName' => "xsd:string",
'strEmail' => "xsd:string"
);
// Register service and method
$server->register('HelloWorld',$varname, array('return' => 'tns:ArrayOfString'));
//Add ComplexType with Array
$server->wsdl->addComplexType("ArrayOfString",
"complexType",
"array",
"",
"SOAP-ENC:Array",
array(),
array(array("ref"=>"SOAP-ENC:arrayType","wsdl:arrayType"=>"xsd:string[]")),
"xsd:string");
function HelloWorld($strName,$strEmail)
{
$arr[1] = $strName;
$arr[2] = $strEmail;
return $arr;
}
// Get our posted data if the service is being consumed
// otherwise leave this data blank.
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
exit();
error หน้า server หายไปแล้ว แต่หน้า client มันฟ้องว่า
Array ( [faultcode] => SOAP-ENV:Client [faultactor] => [faultstring] => error in msg parsing: xml was empty, didn't parse! [detail] => )
SOAP-ENV:Client
error in msg parsing: xml was empty, didn't parse!
อันนี้ต้องแก้ยังไงหรอครับ
|
 |
 |
 |
 |
Date :
2019-11-28 11:31:11 |
By :
erlnw001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|