简体   繁体   English

使用SOAP和PHP获得身份验证工作

[英]Get authentication work with SOAP and PHP

I try to connect to SOAP with php and here is my code: 我尝试使用php连接到SOAP,这是我的代码:

$wsdl = 'http://websiteservicesvplus.mpfrance.fr/WebServicesVPlus.asmx?wsdl';
$soap = new SoapClient($wsdl, $options);
$data = $soap->CheckConnection(
    array(
        'ApiKey'=>'63156585fd3e7a69d6e66c67a92b095b0b8b1478bedffc9137ba9cf8c1dc5088',
        'ApiTokenUserId'=>'5',
        'ApiTokenTypeId'=>'8'
    )
);
var_dump($data);
die;

After I run it on the browser, I got this message error only : 在浏览器上运行它之后,仅收到此消息错误:

"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:\\wamp\\www\\test\\webservices\\server1.php:23 Stack trace: #0 C:\\wamp\\www\\test\\webservices\\server1.php(23): SoapClient->__call('CheckConnection', Array) #1 C:\\wamp\\www\\test\\webservices\\server1.php(23): SoapClient->CheckConnection(Array) #2 {main} thrown in C:\\wamp\\www\\test\\webservices\\server1.php on line 23" “致命错误:未捕获的SoapFault异常:[soap:Server]服务器无法处理请求。--->对象引用未设置为对象的实例。在C:\\ wamp \\ www \\ test \\ webservices \\ server1.php中:23堆栈跟踪:#0 C:\\ wamp \\ www \\ test \\ webservices \\ server1.php(23):SoapClient-> __ call('CheckConnection',Array)#1 C:\\ wamp \\ www \\ test \\ webservices \\ server1 .php(23):SoapClient-> CheckConnection(Array)#2 {main}放在第23行的C:\\ wamp \\ www \\ test \\ webservices \\ server1.php中。

Anyone can help me? 有人可以帮助我吗?

First, I would use a WSDL to php generator to ease the SOAP Web Service consumption (like using the PackageGenerator project), 首先,我将使用WSDL到php生成器以减轻SOAP Web Service的使用(例如使用PackageGenerator项目),

Second, you're missing the SOAPHeader declared in: 其次,您缺少以下声明的SOAPHeader:

<wsdl:operation name="CheckConnection"> <soap12:operation soapAction="http://qpc.ebp.be/CheckConnection" style="document"/> <wsdl:input> <soap12:body use="literal"/> <soap12:header message="tns:CheckConnectionAuthHeader" part="AuthHeader" use="literal"/> </wsdl:input> <wsdl:output> <soap12:body use="literal"/> </wsdl:output> </wsdl:operation> . <wsdl:operation name="CheckConnection"> <soap12:operation soapAction="http://qpc.ebp.be/CheckConnection" style="document"/> <wsdl:input> <soap12:body use="literal"/> <soap12:header message="tns:CheckConnectionAuthHeader" part="AuthHeader" use="literal"/> </wsdl:input> <wsdl:output> <soap12:body use="literal"/> </wsdl:output> </wsdl:operation> Once again, using the project references before, it will be defined in the tutorial.php file in order to send it easily. 再一次使用之前的项目引用,将在tutorial.php文件中对其进行定义,以便于轻松发送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM