php webservice 的问题

llj480028 2010-03-26 11:12:26
客户端代码:
$web_clent=array(
"uri"=>'http://172.16.32.60/webservice/server1.wsdl',
"location"=>'http://172.16.32.60/webservice/index.php?wsdl',
"trace"=>true

);

$obj_client=new SoapClient("server1.wsdl",$web_clent);

try{


$result=$obj_client->returnString();

}catch(Exception $e){


}
echo $result;
print_r($obj_client->__getFunctions());
print_r($obj_client->__getTypes());
echo "<br/>";

echo $obj_client->fun_foo();
...全文
161 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
llj480028 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wisword 的回复:]
$obj_client=new SoapClient("http://172.16.32.60/webservice/index.php?wsdl");
[/Quote]
是这个样子,但是为什么我要用server 端的方法,没有返回值呢?
wisword 2010-03-26
  • 打赏
  • 举报
回复
$obj_client=new SoapClient("http://172.16.32.60/webservice/index.php?wsdl");
llj480028 2010-03-26
  • 打赏
  • 举报
回复
服务器代码:

require_once 'basic.php'; 


function fun_foo(){

return "test";

}

$arr_obj=array("uri"=>'http://172.16.32.60/webservice/server1.wsdl','encoding'=>'utf-8','soap_version' => SOAP_1_2 );

$obj_service=new SoapServer("server1.wsdl",$arr_obj);

$obj_service->setClass("Basic");
//$obj_service->addFunction("fun_foo");
$obj_service->handle();


basic.php

class Basic{

public function returnString(){


return "this is my webservice";
}
public function returnInt($a,$b){

return $a+$b;

}
public function Center_getCenterScheme($cinemacode){

return array(
"Clipuuid"=> 'uid',
"Clipname"=>'clipname',
"cliptime"=>'time'
);


server1.wsdl

<?xml version='1.0' encoding='UTF-8'?>

<!-- WSDL file generated by Zend Studio. -->

<definitions name="server1" targetNamespace="urn:server1" xmlns:typens="urn:server1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:typens0="http://localhost/webservice/">
<message name="Center_getCenterScheme">
<part name="cinemacode"/>
</message>
<message name="Center_getCenterSchemeResponse">
<part name="Center_getCenterSchemeReturn"/>
</message>
<message name="returnInt">
<part name="a"/>
<part name="b"/>
</message>
<message name="returnIntResponse">
<part name="returnIntReturn"/>
</message>
<message name="returnString"/>
<message name="returnStringResponse">
<part name="returnStringReturn"/>
</message>
<portType name="BasicPortType">
<operation name="Center_getCenterScheme">
<input message="typens:Center_getCenterScheme"/>
<output message="typens:Center_getCenterSchemeResponse"/>
</operation>
<operation name="returnInt">
<input message="typens:returnInt"/>
<output message="typens:returnIntResponse"/>
</operation>
<operation name="returnString">
<input message="typens:returnString"/>
<output message="typens:returnStringResponse"/>
</operation>
</portType>
<binding name="BasicBinding" type="typens:BasicPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Center_getCenterScheme">
<soap:operation soapAction="urn:BasicAction"/>
<input>
<soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="returnInt">
<soap:operation soapAction="urn:BasicAction"/>
<input>
<soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="returnString">
<soap:operation soapAction="urn:BasicAction"/>
<input>
<soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="server1Service">
<port name="BasicPort" binding="typens:BasicBinding">
<soap:address location="http://172.16.32.60/webservice/server1.wsdl"/>
</port>
</service>
</definitions>
llj480028 2010-03-26
  • 打赏
  • 举报
回复
错误信息:
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "server1.wsdl" in D:\Server files\www\interface\index.php on line 9

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'server1.wsdl' : failed to load external entity "server1.wsdl" in D:\Server files\www\interface\index.php:9 Stack trace: #0 D:\Server files\www\interface\index.php(9): SoapClient->SoapClient('server1.wsdl', Array) #1 {main} thrown in D:\Server files\www\interface\index.php on line 9
llj480028 2010-03-26
  • 打赏
  • 举报
回复
anyone help me ??
用 __getFunctions()能出现方法信息,但就是调用不了!!
llj480028 2010-03-26
  • 打赏
  • 举报
回复
真不简单呀!怎么搞过吗,现在这问题是不能调用server端的方法!真要命!

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧