Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. require_once("lib/nusoap.php");
  2. $private_key=file_get_contents('client.pem');
  3. $private=der2pem($private_key);
  4. $local_cert = (string)$private;
  5. $ws = 'url/wsdl'; //wsdl file
  6. //define the soap server location
  7. $vLocation = "xxxx";
  8. $client = new SoapClient($ws, array(
  9. "location" => $vLocation,
  10. "trace"=>1,
  11. "exceptions"=>1,
  12. "local_cert" => $local_cert
  13. ));
  14. $username = 'username';
  15. $password = 'password';
  16. $headerbody = array('username ' => $username,
  17. 'password ' => $password);
  18. $ns = 'xxxx'; //Namespace of the web service.
  19. $header = new SOAPHeader($ns,'requestHeader', $headerbody,true);
  20. $client->__setSoapHeaders($header);
  21. $params=array('name'=>'monocept');
  22. try{
  23. print_r($client);
  24. $op=$client->authHelloWS($params);
  25. }
  26. catch (SoapFault $fault) {
  27. trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
  28. }
  29. function der2pem($der_data, $type='CERTIFICATE') {
  30. $pem = chunk_split(base64_encode($der_data), 64, "n");
  31. $pem = $type.$pem.$type;
  32. return $pem;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement