Yii2 测试 yii2-soap 的问题 [ 2.0 版本 ]
wsdl
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="https://store.fdimall.com/v1/apis/index?ws=1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="api.modules.v1.controllers.ApiController" targetNamespace="https://store.fdimall.com/v1/apis/index?ws=1">
<types>
<xsd:schema targetNamespace="https://store.fdimall.com/v1/apis/index?ws=1">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
</xsd:schema>
</types>
<portType name="api.modules.v1.controllers.ApiControllerPort">
<operation name="actionHello">
<input message="tns:actionHelloIn"/>
<output message="tns:actionHelloOut"/>
</operation>
</portType>
<binding name="api.modules.v1.controllers.ApiControllerBinding" type="tns:api.modules.v1.controllers.ApiControllerPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="actionHello">
<soap:operation soapAction="https://store.fdimall.com/v1/apis/index?ws=1#actionHello"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="https://store.fdimall.com/v1/apis/index?ws=1"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="https://store.fdimall.com/v1/apis/index?ws=1"/>
</output>
</operation>
</binding>
<service name="api.modules.v1.controllers.ApiControllerService">
<port name="api.modules.v1.controllers.ApiControllerPort" binding="tns:api.modules.v1.controllers.ApiControllerBinding">
<soap:address location="https://store.fdimall.com/v1/apis/index?ws=1"/>
</port>
</service>
<message name="actionHelloIn"/>
<message name="actionHelloOut">
<part name="return" type="xsd:string"/>
</message>
</definitions>
调用
public function actionHello(){
ini_set("soap.wsdl_cache_enabled", "0");
$client = new \SoapClient('https://store.fdimall.com/v1/apis/index');
return $client->hello('Alex');
}
报错提示
{
"name": "Exception",
"message": "Function (\"hello\") is not a valid method for this service",
"code": 0,
"type": "SoapFault",
"file": "/www/wwwroot/munx/api/modules/v1/controllers/GroupController.php",
"line": 48,
"stack-trace": [
"#0 /www/wwwroot/munx/api/modules/v1/controllers/GroupController.php(48): SoapClient->__call('hello', Array)",
"#1 [internal function]: api\\modules\\v1\\controllers\\GroupController->actionHello()",
"#2 /www/wwwroot/munx/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)",
"#3 /www/wwwroot/munx/vendor/yiisoft/yii2/base/Controller.php(157): yii\\base\\InlineAction->runWithParams(Array)",
"#4 /www/wwwroot/munx/vendor/yiisoft/yii2/base/Module.php(528): yii\\base\\Controller->runAction('hello', Array)",
"#5 /www/wwwroot/munx/vendor/yiisoft/yii2/web/Application.php(103): yii\\base\\Module->runAction('v1/group/hello', Array)",
"#6 /www/wwwroot/munx/vendor/yiisoft/yii2/base/Application.php(386): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))",
"#7 /www/wwwroot/munx/api/web/index.php(17): yii\\base\\Application->run()",
"#8 {main}"
]
}
munx 补充于 2019-06-06 08:16
不是wsdl缓存问题。
munx 补充于 2019-06-17 13:47
谢谢朋友的回答。
最佳答案
-
代码应该 没什么问题,很大的可能是 你的链接返回的 wsdl内容 格式不正确
https://store.fdimall.com/v1/apis/index 这个地址 不知道是不是你的 真实地址,现在是一个 报错页面,望 尽快解决
其他 0 个回答
没有找到数据。
munx
注册时间:2018-10-25
最后登录:2019-07-25
在线时长:4小时6分
最后登录:2019-07-25
在线时长:4小时6分
- 粉丝0
- 金钱30
- 威望0
- 积分70