PHP soapclient有多个请求的问题 [英] Problem with PHP soapclient with multiple requests

查看:213
本文介绍了PHP soapclient有多个请求的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个PHP客户端来使用SOAP服务。 Web服务有很多方法,但我现在只对两个方法感兴趣。



第一个是logOn方法,接受用户名和密码。我可以让它工作得很好。它响应正文中的sessionId和响应标头中的不同sessionId。我现在正在尝试调用下一个方法validateSession并在validateSession请求的标头中传递logOn方法响应的标头中返回的sessionId。无论我做什么,我都会收到一个致命的错误回复,说明用户没有登录并且先登录。



我显然做错了什么,我对PHP和SOAP都很陌生,所以非常感谢任何帮助。



我尝试了什么:



I'm writing a PHP Client to consume a SOAP service. The web service has a number of methods however I'm really only interested in two at the moment.

The first is a logOn method, which accepts a username and password. I can get that to work fine. It responds with a sessionId in the body and a different sessionId in the header of the response. I'm now trying to call the next method validateSession and pass the sessionId returned in the header of the logOn method response, in the header of the validateSession request. No matter what I do however I keep getting a fatal error response stating that the user is not logged in and the log in first.

I'm obviously doing something wrong, I'm very new to PHP and SOAP so any assistance would be greatly appreciated.

What I have tried:

session_start(); $params = array('location' =>'ActualLocation', 'uri' => 'ActualURI', 'trace' => 1); $id_array = array('userName'=>'User', 'password'=>'Pass'); $client = new SoapClient(NULL, $params); //logOn Method------------------------------ $client->__soapCall('logOn', $id_array); //------------------------------------------ $responseCookie = $client->_cookies; $responseCookie_Parsed = $responseCookie['JSESSIONID'][0]; $client->__setCookie('JSESSIONID', $responseCookie_Parsed); $client->__soapCall('validateSession', array('sessionId'=>'abc123') ) ;//validate session.

推荐答案

params = array('location'=>'ActualLocation','uri'=>'ActualURI','trace'=> 1);
params = array('location' =>'ActualLocation', 'uri' => 'ActualURI', 'trace' => 1);


id_array = array('userName'=>'User','password'=>'Pass');
id_array = array('userName'=>'User', 'password'=>'Pass');


client = new SoapClient(NULL,
client = new SoapClient(NULL,


这篇关于PHP soapclient有多个请求的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆