 |
สอบถามเรื่องการ connect php กับ web serivce ในกรณีที่าง web serivce ไม่ได้ให้ wsdl มาค่ะ |
|
 |
|
|
 |
 |
|
ในกรณีที่ web sevice ไม่ได้ให้ wsdl มา ทางฝั่ง client จะต้องสร้าง wsdl มาเองหรือว่า ทำการเขียน เพื่อ connect เลยค่ะ
เขียนโค้ดแบบนี้
Code (PHP)
<?php
$client = new SoapClient(NULL,
array(
"location" => "http://www.education.mju.ac.th/regMjuWS/mjuStudentData.asmx",
"uri" => "urn:xmethods-delayed-quotes",
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
));
print($client->__call(
/* SOAP Method Name */
"getMisStdData",
/* Parameters */
array(
new SoapParam(
/* Parameter Value */
"ibm",
/* Parameter Name */
"symbol"
)),
/* Options */
array(
/* SOAP Method Namespace */
"uri" => "urn:xmethods-delayed-quotes",
/* SOAPAction HTTP Header for SOAP Method */
"soapaction" => "urn:xmethods-delayed-quotes#getQuote"
)). "\n");
?>
แต่ดัน connect ไมไ่ด้อ่าค่ะ เวลารัน โค้ดแล้วมัน
Code
Fatal error: Uncaught SoapFault exception: [soap:Client] System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: urn:xmethods-delayed-quotes#getQuote. at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) in C:\AppServ\www\nusoap-0.9.5\test.php:28 Stack trace: #0 C:\AppServ\www\nusoap-0.9.5\test.php(28): SoapClient->__call('getMisStdData', Array, Array) #1 {main} thrown in C:\AppServ\www\nusoap-0.9.5\test.php on line 28
แบบนี้อ่าค่ะ ในส่วน ของการเปิด php.ini ได้ทำการเปิด soap แล้วนะคะ แต่มันก็ยางไม่ได้อ่าค่ะ
Tag : PHP, CakePHP
|
|
 |
 |
 |
 |
Date :
2012-05-29 10:02:08 |
By :
thitinun-bit |
View :
1624 |
Reply :
10 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองไปขอตัวอย่างจากเว็บต้นฉบับครับ ว่าเรียกใช้งานวิธีไหนได้บ้าง
|
 |
 |
 |
 |
Date :
2012-05-29 11:50:56 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก error มันดูเหมอืนจะมีปัญหาเรื่องการ เรียกใช้ข้อมูล array แต่ตอนไปเอาลิ้งจาก เจ้าของ service เค้าบอกว่ามี password ด้วยอ่าค่ะ เลย งง ว่าจะ เชื่อมต่อยางไงอ่า
|
 |
 |
 |
 |
Date :
2012-05-29 16:00:24 |
By :
ying |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ส่วนวิธีโยนค่าดูใน Link ที่ผมบอกก็ได้ครับ
|
 |
 |
 |
 |
Date :
2012-05-29 16:41:29 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เพิ่มแบบนี้เหรอค่ะ
Code (PHP)
<?php
require_once("lib/nusoap.php");
$client = new soapclient("http://www.education.mju.ac.th/regMjuWS/mjuStudentData.asmx?wsdl");
echo '<br><br><strong>Test Connect Function getMisStdData()</strong><br>';
echo htmlspecialchars($client->getMisStdData());
?>
<s:element minOccurs="0" maxOccurs="1" name="HCODE" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="fid" type="s:string"/>
|
 |
 |
 |
 |
Date :
2012-05-30 09:59:03 |
By :
ying |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แต่มาลองเขียน แบบนี้
Code (PHP)
<?
$client = new
SoapClien(
"http://www.education.mju.ac.th/regMjuWS/mjuStudentData.asmx?wsdl"
);
print($clent->getMisStdData("weloveKING"));
?>
มันก็ฟ้อง Fatal error: Class 'SoapClien' not found in C:\AppServ\www\nusoap-0.9.5\test.php on line 4
ทั้ง ๆ ที่เปิด extension=php_soap.dll ในไฟล์ php.ini และ ลอง restart apache และ copy ไฟล์ php_soap.dll ไปไว้ใน C:\Windows\System32
แล้วค่ะ แต่ก็ยัง มี Error อยู่ค่ะ
|
 |
 |
 |
 |
Date :
2012-05-30 10:29:03 |
By :
ying |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
#8 สะกดผิดป่าวครับ
SoapClient
|
 |
 |
 |
 |
Date :
2012-05-30 12:29:57 |
By :
katwalks |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใช้ NuSoap ครับ ตาม Link ที่ผมบอกมันมีบทความอยู่ครับ
|
 |
 |
 |
 |
Date :
2012-05-30 12:45:00 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|