How to call webservice with self-created certificate in php

angryTom
Release: 2023-04-07 16:06:01
forward
2767 people have browsed it

Someone has asked this question. There is little information on this aspect on domestic websites. Let me briefly talk about it here

1. First, use various means to make apache support https.

2. Then use SoapDiscovery.class.php (Baidu, it’s everywhere) to create a webservice

3. Then we can access https://xxx/abc.php?wsdl . Note that this is one-way authentication and does not authenticate the client.

If PHP's soapclient accesses a webservice without SSL encryption, it is too simple. Nothing much to say.

What if it is after SSL?

How to write code

$context = stream_context_create(array(
    ‘ssl’ => array(
        ‘verify_peer’ => false,
        ‘allow_self_signed’ => true     //这一步很重要,代表是否允许自建证书。因为到权威机构申请证书是要钱的
    )
));
$client  = new SoapClient(null, array( 
    ‘location’ => ‘https://xxxx/abc.php?wsdl’,    //这里写你的webservice地址 
    ‘uri’ => ‘urn:czService’,   //你的wsdl文件中会有 targetNamespace 自己找找
    ‘stream_context’ => $context
));
$client->XXX    // 这里尽情的执行你的方法吧
Copy after login

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to call webservice with self-created certificate in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:www.hishenyi.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!