Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/307564-php-web-services-help/
Share on other sites

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>

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');

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.