Marina111 Posted July 27, 2018 Share Posted July 27, 2018 Hi, I'm struggling to get a web service to work which we are using to integrate with a software package from Civica. Unfortunately they have sent us code in visual basic which we don't use here and I'm struggling to "translate" the visual basic into PHP. So here's the code I have so far: error_reporting(E_ALL); $client = new SoapClient('https://xxx/cx/WebService/WSTokenService?singleWsdl'); var_dump($client->__getFunctions()); The above works and I can see the functions. It's the next bit I can't get to work: $request_param = array('Password' => 'xxx', 'UserName' => 'yyy'); try { $request = $client ->GetUserWSToken($request_param); $result = $request ->GetUserWSTokenResult; print_r($result); } catch (Exception $e) { echo "<P><P>Exception Error!"; echo $e->getMessage(); } When I run the above code I get an error message "Exception Error!GetUserWSToken has service faults". The visual basic code we've been sent by the package company to use is: Dim tokenClient As New TokenService.WSTokenServiceClient Dim tokenreq As New TokenService.SecurityTokenRequest tokenreq.UserName = "usernamehere" tokenreq.Password = "passwordhere" Dim token = tokenClient.GetUserWSToken(tokenreq) Does anyone know how to translate the visual basic above into what I need to do for PHP? Thanks, Marina Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/ Share on other sites More sharing options...
requinix Posted July 27, 2018 Share Posted July 27, 2018 Can you compare the SOAP request from the VB version to what's being sent from PHP? Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/#findComment-1560083 Share on other sites More sharing options...
Marina111 Posted July 27, 2018 Author Share Posted July 27, 2018 I have a software tool called SoapUI with which I can call the web service and get it to work, but I'm obviously missing something in the PHP and having never done web services before I'm struggling. The code from SOAPUI which does work and return a value is: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:civ="http://schemas.datacontract.org/2004/07/Civica.Housing.Cx.WebServices.Contracts.DataContracts.Modules.Security"> <soapenv:Header/> <soapenv:Body> <tem:GetUserWSToken> <!--Optional:--> <tem:request> <civ:Password>xxx</civ:Password> <civ:UserName>yy</civ:UserName> </tem:request> </tem:GetUserWSToken> </soapenv:Body> </soapenv:Envelope> Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/#findComment-1560084 Share on other sites More sharing options...
requinix Posted July 27, 2018 Share Posted July 27, 2018 And how about what PHP is sending? Can you see that? class DebugSoapClient extends SoapClient { public function __doRequest($request, $location, $action, $version, $one_way = 0) { /* log $request somewhere */ return parent::__doRequest($request, $location, $action, $version, $one_way); } } $client = new DebugSoapClient('https://xxx/cx/WebService/WSTokenService?singleWsdl'); Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/#findComment-1560085 Share on other sites More sharing options...
Marina111 Posted July 27, 2018 Author Share Posted July 27, 2018 Hi - I tried the code above but I didn't get anything extra returned from it - just the same error message Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/#findComment-1560086 Share on other sites More sharing options...
Marina111 Posted July 27, 2018 Author Share Posted July 27, 2018 Sorry, tried again and got this output: DebugSoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #2 ) Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/#findComment-1560088 Share on other sites More sharing options...
requinix Posted July 27, 2018 Share Posted July 27, 2018 Seems like the "log $request somewhere" I put in there somehow turned into "dump $this". That is not what it needs to do. $request is the request. You need to see its value. Or maybe you're dumping $request after all? It's XML so it could very well be invisible. Do a View Source of the page. Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/#findComment-1560091 Share on other sites More sharing options...
Marina111 Posted July 27, 2018 Author Share Posted July 27, 2018 I think I'm a bit further forward - the parameter for GetUserWSToken needs to be a SecurityTokenRequest and the username and password are variables within SecurityTokenRequest, however I'm struggling with the syntax to get this right. Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/#findComment-1560094 Share on other sites More sharing options...
requinix Posted July 27, 2018 Share Posted July 27, 2018 I guess I can't, huh? That's alright, there are other things I could be doing right now anyways. Quote Link to comment https://forums.phpfreaks.com/topic/307564-php-web-services-help/#findComment-1560095 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.