با سلام
من می خوام یه web service بنویسم کد هاش ایناست
صفحه سمت server
[PHPS]
<?
// Pull in the NuSOAP code
require_once('nusoap.php');
include '../inc/config.inc.php';
include '../inc/opendb.php';
include '../inc/jdf.php';
include '../inc/include.inc.php';
// Create the server instance
$server = new soap_server;
// Register the method to expose
$server->register('ReadNews');
function ReadNews($id){
$query = mysql_query("SELECT * FROM `datav` WHERE id = '".$id."'");
$row = mysql_fetch_array($query);
return $row['title'];
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
[/PHPS]
صفحه سمت client
[PHPS]
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new nusoap_client('http://192.168.0.39/LovelyFoods/webService/lovelyWS.php');
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('hello', array('id' => 86));
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
?>
<?php
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
?>
[/PHPS]
ولی خروجی erorr می ده
اینم خروجی
[h=2]Error[/h]
Response not of type text/xml: text/html[h=2]Request[/h]
POST /LovelyFoods/webService/lovelyWS.php HTTP/1.0 Host: 192.168.0.39 User-Agent: NuSOAP/0.7.3 (1.114) Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "" Content-Length: 490 <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns9601:hello xmlns:ns9601="http://tempuri.org"><id xsi:type="xsd:int">86</id></ns9601:hello></SOAP-ENV:Body></SOAP-ENV:Envelope>[h=2]Response[/h]
HTTP/1.1 200 OK Date: Wed, 21 Aug 2013 11:25:27 GMT Server: Apache/2.2.6 (Win32) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.4 X-Powered-By: PHP/5.2.4 Content-Length: 2115 Connection: close Content-Type: text/html  <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">method 'hello' not defined in service</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
مشکل از کجاست؟
من می خوام یه web service بنویسم کد هاش ایناست
صفحه سمت server
[PHPS]
<?
// Pull in the NuSOAP code
require_once('nusoap.php');
include '../inc/config.inc.php';
include '../inc/opendb.php';
include '../inc/jdf.php';
include '../inc/include.inc.php';
// Create the server instance
$server = new soap_server;
// Register the method to expose
$server->register('ReadNews');
function ReadNews($id){
$query = mysql_query("SELECT * FROM `datav` WHERE id = '".$id."'");
$row = mysql_fetch_array($query);
return $row['title'];
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
[/PHPS]
صفحه سمت client
[PHPS]
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new nusoap_client('http://192.168.0.39/LovelyFoods/webService/lovelyWS.php');
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('hello', array('id' => 86));
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
?>
<?php
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
?>
[/PHPS]
ولی خروجی erorr می ده
اینم خروجی
[h=2]Error[/h]
Response not of type text/xml: text/html[h=2]Request[/h]
POST /LovelyFoods/webService/lovelyWS.php HTTP/1.0 Host: 192.168.0.39 User-Agent: NuSOAP/0.7.3 (1.114) Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "" Content-Length: 490 <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns9601:hello xmlns:ns9601="http://tempuri.org"><id xsi:type="xsd:int">86</id></ns9601:hello></SOAP-ENV:Body></SOAP-ENV:Envelope>[h=2]Response[/h]
HTTP/1.1 200 OK Date: Wed, 21 Aug 2013 11:25:27 GMT Server: Apache/2.2.6 (Win32) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.4 X-Powered-By: PHP/5.2.4 Content-Length: 2115 Connection: close Content-Type: text/html  <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\LovelyFoods\inc\config.inc.php:1) in <b>C:\xampp\htdocs\LovelyFoods\webService\nusoap.php</b> on line <b>4174</b><br /> <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">method 'hello' not defined in service</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
مشکل از کجاست؟