Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once("lib/nusoap.php");
- $private_key=file_get_contents('client.pem');
- $private=der2pem($private_key);
- $local_cert = (string)$private;
- $ws = 'url/wsdl'; //wsdl file
- //define the soap server location
- $vLocation = "xxxx";
- $client = new SoapClient($ws, array(
- "location" => $vLocation,
- "trace"=>1,
- "exceptions"=>1,
- "local_cert" => $local_cert
- ));
- $username = 'username';
- $password = 'password';
- $headerbody = array('username ' => $username,
- 'password ' => $password);
- $ns = 'xxxx'; //Namespace of the web service.
- $header = new SOAPHeader($ns,'requestHeader', $headerbody,true);
- $client->__setSoapHeaders($header);
- $params=array('name'=>'monocept');
- try{
- print_r($client);
- $op=$client->authHelloWS($params);
- }
- catch (SoapFault $fault) {
- trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
- }
- function der2pem($der_data, $type='CERTIFICATE') {
- $pem = chunk_split(base64_encode($der_data), 64, "n");
- $pem = $type.$pem.$type;
- return $pem;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement