灵活的 php SOAP 语法
我无法弄清楚如何提出肥皂请求。
首先我加载 wsdl 文档。
$sclient=new SoapClient('wsdl.asmx');
然后,当我查看 __getFunctions() 的返回值时,我有这个字符串
simpleFunction( simpleFunction $parameters )
在 __getTypes() 中我有这个字符串
struct simpleFunction{ string oid; string Username; string Password;}
我一直在尝试数组、SoapParams 和 SoapVars 的各种组合,但我总是收到这样的错误:
Fatal错误:未捕获的 SoapFault 异常:[soap:Server] 服务器无法处理请求。 -->你调用的对象是空的。在 C:\path.php:21 堆栈跟踪: #0 [内部函数]: SoapClient->__call('handleSimpleUse...', Array) #1 C:\path(21): SoapClient->simpleFunction(数组)
这是我最近尝试的代码
$sclient=new SoapClient('wsdl.asmx');
$params=array(
new SoapVar('aaa',XSD_STRING,'oid'),
new SoapVar('bbb',XSD_STRING,'Password'),
new SoapVar('ccc',XSD_STRING,'Username')
);
$result=$sclient->simpleFunction($params);
我应该如何正确格式化这个肥皂请求?
I am having trouble figuring out how to make soap requests.
First I load the wsdl document.
$sclient=new SoapClient('wsdl.asmx');
Then when i look in the return from __getFunctions() I have this string
simpleFunction( simpleFunction $parameters )
And in __getTypes() I have this string
struct simpleFunction{ string oid; string Username; string Password;}
I have been trying all kinds of combinations of arrays, SoapParams, and SoapVars, but I always get an error like this:
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. --> Object reference not set to an instance of an object. in C:\path.php:21 Stack trace: #0 [internal function]: SoapClient->__call('handleSimpleUse...', Array) #1 C:\path(21): SoapClient->simpleFunction(Array)
Here is the code of my latest attempt
$sclient=new SoapClient('wsdl.asmx');
$params=array(
new SoapVar('aaa',XSD_STRING,'oid'),
new SoapVar('bbb',XSD_STRING,'Password'),
new SoapVar('ccc',XSD_STRING,'Username')
);
$result=$sclient->simpleFunction($params);
How am I supposed to correctly format this soap request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过使用 http://www.urdalen.no/wsdl2php/ 生成要使用的类来解决这个问题来自 wsdl 文件。
I solved this by using http://www.urdalen.no/wsdl2php/ to generate classes to use from the wsdl file.