日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

PHP人才网站对接内蒙古自治区四位一体就业服务云平台

發(fā)布時間:2024/1/18 php 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PHP人才网站对接内蒙古自治区四位一体就业服务云平台 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

2021年上半年,內(nèi)蒙古自治區(qū)人社廳發(fā)了《關(guān)于進(jìn)一步加強(qiáng)“四位一體”就業(yè)服務(wù)云平臺推廣應(yīng)用工作的通知》,要求各盟市人才網(wǎng)站與自治區(qū)四位一體就業(yè)服務(wù)云平臺實(shí)現(xiàn)以接口方式對接。通遼市率先完成通遼市人才網(wǎng)的對接工作,這里把其中涉及的PHP和SOAP相關(guān)的技術(shù)難點(diǎn)和解決方案分享給大家,共同學(xué)習(xí),共同進(jìn)步。

文章目錄

  • 前言
  • 一、PHP通過SoapClient調(diào)用服務(wù)端接口
  • 二、PHP利用wsdl創(chuàng)建標(biāo)準(zhǔn)webservice
    • 1.創(chuàng)建文件SoapDiscovery.class.php
    • 2.提供服務(wù)的類或者函數(shù)
    • 3.生成WSDL
    • 4.創(chuàng)建webservice服務(wù)端程序
    • 5.測試
  • 總結(jié)


前言

通遼市人才網(wǎng)是通遼市人社局主辦的官方招聘求職網(wǎng)站,是通遼地區(qū)最大的人才招聘門戶網(wǎng)站,我作為本次與自治區(qū)四位一體就業(yè)服務(wù)云平臺進(jìn)行api對接的技術(shù)負(fù)責(zé)人,通過本次對接,也學(xué)習(xí)了不少的內(nèi)容。上次與國家就業(yè)在線對接,難點(diǎn)主要是PHP版本的AES加密算法和HTTP CALLER以及中文亂碼的處理,而本次則是PHP版本的SOAP和WebService,每次都是新的學(xué)習(xí)內(nèi)容,讓我在體制內(nèi)也過了一把當(dāng)程序員的癮-。


提示:以下是本篇文章正文內(nèi)容,下面案例可供參考

一、PHP通過SoapClient調(diào)用服務(wù)端接口

通遼市人才網(wǎng)向自治區(qū)四位一體就業(yè)服務(wù)云平臺同步企業(yè)信息、職位信息和招聘會信息,均屬于這種模式,在本地創(chuàng)建一個SoapClient,然后調(diào)用服務(wù)端提供的同步接口,代碼如下(示例):

$soap = new SoapClient("http://xxxxxx/xxxx/xxxx/WebserviceSWYT?wsdl"); $result = $soap->setDb21($reqString);

二、PHP利用wsdl創(chuàng)建標(biāo)準(zhǔn)webservice

自治區(qū)四位一體就業(yè)服務(wù)云平臺向通遼市人才網(wǎng)同步簡歷信息,屬于這種模式,在通遼市人才網(wǎng)本地利用wsdl創(chuàng)建一個WebService,然后提供wsdl地址和對外接口給四位一體就業(yè)服務(wù)云平臺調(diào)用,代碼如下(示例):

1.創(chuàng)建文件SoapDiscovery.class.php

代碼如下(示例):

<pre name="code" class="php"><?php/*** Copyright (c) 2005, Braulio José Solano Rojas* All rights reserved.* * Redistribution and use in source and binary forms, with or without modification, are* permitted provided that the following conditions are met:* * Redistributions of source code must retain the above copyright notice, this list of* conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of* conditions and the following disclaimer in the documentation and/or other materials* provided with the distribution. * Neither the name of the Solsoft de Costa Rica S.A. nor the names of its contributors may* be used to endorse or promote products derived from this software without specific* prior written permission.* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.* ** @version $Id$* @copyright 2005 *//*** SoapDiscovery Class that provides Web Service Definition Language (WSDL).* * @package SoapDiscovery* @author Braulio José Solano Rojas* @copyright Copyright (c) 2005 Braulio José Solano Rojas* @version $Id$* @access public**/ class SoapDiscovery {private $class_name = '';private $service_name = '';/*** SoapDiscovery::__construct() SoapDiscovery class Constructor.* * @param string $class_name* @param string $service_name**/public function __construct($class_name = '', $service_name = '') {$this->class_name = $class_name;$this->service_name = $service_name;}/*** SoapDiscovery::getWSDL() Returns the WSDL of a class if the class is instantiable.* * @return string**/public function getWSDL() {if (empty($this->service_name)) {throw new Exception('No service name.');}$headerWSDL = "<?xml version=\"1.0\" ?>\n";$headerWSDL.= "<definitions name=\"$this->service_name\" targetNamespace=\"urn:$this->service_name\" xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:tns=\"urn:$this->service_name\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns=\"http://schemas.xmlsoap.org/wsdl/\">\n";$headerWSDL.= "<types xmlns=\"http://schemas.xmlsoap.org/wsdl/\" />\n";if (empty($this->class_name)) {throw new Exception('No class name.');}$class = new ReflectionClass($this->class_name);if (!$class->isInstantiable()) {throw new Exception('Class is not instantiable.');}$methods = $class->getMethods();$portTypeWSDL = '<portType name="'.$this->service_name.'Port">';$bindingWSDL = '<binding name="'.$this->service_name.'Binding" type="tns:'.$this->service_name."Port\">\n<soap:binding style=\"rpc\" transport=\"http://schemas.xmlsoap.org/soap/http\" />\n";$serviceWSDL = '<service name="'.$this->service_name."\">\n<documentation />\n<port name=\"".$this->service_name.'Port" binding="tns:'.$this->service_name."Binding\"><soap:address location=\"http://".$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['PHP_SELF']."\" />\n</port>\n</service>\n";$messageWSDL = '';foreach ($methods as $method) {if ($method->isPublic() && !$method->isConstructor()) {$portTypeWSDL.= '<operation name="'.$method->getName()."\">\n".'<input message="tns:'.$method->getName()."Request\" />\n<output message=\"tns:".$method->getName()."Response\" />\n</operation>\n";$bindingWSDL.= '<operation name="'.$method->getName()."\">\n".'<soap:operation soapAction="urn:'.$this->service_name.'#'.$this->class_name.'#'.$method->getName()."\" />\n<input><soap:body use=\"encoded\" namespace=\"urn:$this->service_name\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" />\n</input>\n<output>\n<soap:body use=\"encoded\" namespace=\"urn:$this->service_name\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" />\n</output>\n</operation>\n";$messageWSDL.= '<message name="'.$method->getName()."Request\">\n";$parameters = $method->getParameters();foreach ($parameters as $parameter) {$messageWSDL.= '<part name="'.$parameter->getName()."\" type=\"xsd:string\" />\n";}$messageWSDL.= "</message>\n";$messageWSDL.= '<message name="'.$method->getName()."Response\">\n";$messageWSDL.= '<part name="'.$method->getName()."\" type=\"xsd:string\" />\n";$messageWSDL.= "</message>\n";}}$portTypeWSDL.= "</portType>\n";$bindingWSDL.= "</binding>\n";//return sprintf('%s%s%s%s%s%s', $headerWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, $messageWSDL, '</definitions>');//生成wsdl文件,將上面的return注釋$fso = fopen($this->class_name . ".wsdl" , "w"); fwrite($fso, sprintf('%s%s%s%s%s%s', $headerWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, $messageWSDL, '</definitions>')); }/*** SoapDiscovery::getDiscovery() Returns discovery of WSDL.* * @return string**/public function getDiscovery() {return "<?xml version=\"1.0\" ?>\n<disco:discovery xmlns:disco=\"http://schemas.xmlsoap.org/disco/\" xmlns:scl=\"http://schemas.xmlsoap.org/disco/scl/\">\n<scl:contractRef ref=\"http://".$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['PHP_SELF']."?wsdl\" />\n</disco:discovery>";} }?>

2.提供服務(wù)的類或者函數(shù)

創(chuàng)建文件swyt_rcv_down_msg.class.php,里面有一個接收信息的接口dd03ByPerson

<?phpheader("content-type:text/html;charset=utf-8");class swyt_rcv_msg{public function dd03ByPerson ($strDd03){$json_data['code'] = "1"; //$json_data['message'] = "成功"; //$req['data'] = $json_data;$reqString = json_encode($req,JSON_UNESCAPED_UNICODE);return $reqString;}}

3.生成WSDL

創(chuàng)建文件swyt_server.php,運(yùn)行即可生成一個swyt_rcv_msg.wsdl文件:

<?phpheader("content-type:text/html;charset=utf-8");include("swyt_rcv_down_msg.class.php");include("SoapDiscovery.class.php");$disco = new SoapDiscovery('swyt_rcv_msg','swyt_rcv_msg');$disco->getWSDL(); ?>

4.創(chuàng)建webservice服務(wù)端程序

將swyt_server.php文件的內(nèi)容清空,復(fù)制以下代碼進(jìn)去::

<?phpheader("content-type:text/html;charset=utf-8");include("swyt_rcv_down_msg.class.php");$objSoapServer = new SoapServer("swyt_rcv_msg.wsdl");//swyt_rcv_msg.wsdl是剛創(chuàng)建的wsdl文件$objSoapServer->setClass("swyt_rcv_msg");//注冊swyt_rcv_msg類的所有方法$objSoapServer->handle();//處理請求 ?>

5.測試

代碼如下(示例),傳入地址填寫swyt_rcv_msg.wsdl文件里面這個地址:

$client = new SoapClient("傳入以上截圖位置地址信息");

總結(jié)

最后我發(fā)一下通遼市人才網(wǎng)在內(nèi)蒙古自治區(qū)四位一體就業(yè)服務(wù)云平臺上面的截圖,職位信息每天都會自動同步,極大地節(jié)約的企業(yè)的招聘成本,避免二次錄入,提高了企業(yè)的招聘效率和擴(kuò)展了企業(yè)的宣傳面。

總結(jié)

以上是生活随笔為你收集整理的PHP人才网站对接内蒙古自治区四位一体就业服务云平台的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。