设为首页 收藏本站
查看: 360|回复: 0

[经验分享] php soap client 链接问题

[复制链接]

尚未签到

发表于 2017-3-28 10:39:35 | 显示全部楼层 |阅读模式
1.说明
  php 调用jira的soap接口代码:
  
<?php
$server_url = "http://******.44/s3c/samples/";
$cur_url = "http://******.14/s3c/";
// Jira WSDL
$wsdl =  "http://******.14:8080/rpc/soap/jirasoapservice-v2?wsdl";
$login = "******";
$password = "******";
try{
$client = new soapclient($wsdl);
$login = $client->login( $login,$password);
$data = $_POST;
//        $userName = $_POST["sample_man"];
$userName = 'xiaye';
$sss = '';
$count = 0;
foreach($data as $key=>$value){
if(strpos($key, 'items_')!==0){
continue;
}
if($count == 0){
$sss = str_replace('items_','',$key);
}else{
$sss .= '_'.str_replace('items_','',$key);
}
$count++;
}
$jsonurl = $server_url."issues_info.json?ids=".$sss;
$json = file_get_contents($jsonurl,0,null,null);
$json = json_decode($json, true);
foreach($json as $s){
$sample = $s['sample'];
//样本文件
$sampleFiles = $s['sampleFiles'];
foreach($sampleFiles as $f){
echo $f['SampleFile']['id'];
}
create_issue($client, $login, $userName, $sample, $sampleFiles, $server_url);
}
// Log out
$logout = $client->logout($login);
if($logout ==  TRUE){
}else{
}
/* Redirect browser */
header("Location: ".$cur_url);
/* Make sure that code below does not get executed when we redirect. */
exit;

} catch (Exception $e) {
print $e->getMessage();
exit();
}
/**
* 创建工单
*/
function create_issue($client, $login, $userName, $sample, $sampleFiles, $server_url){
try{
//echo "TEST1!";
//project key
$project = "CHECKING";
//issue type
$type = 6;
$date = date('Ymd');
$detailUrl = "http://******.44/s3c/samples/view/";
$filenames = '';
foreach ( $sampleFiles as $sampleFile ) {
$filenames .= $sampleFile['SampleFile']['ins_path']."\n ";
}

$sampleName = date('Y-m-d',$sample['Sample']['report_at']/1000)."_".$sample['Sample']['id'].".sis";
//a)    样本名称
//b)    软件名称
//c)    软件UID
//d)    软件的证书颁发者
//e)    软件的证书使用者
//f)    样本中各个文件的安装路径
//g)    样本详情链接
$desc = "软件名称:".$sample['Sample']['name']."\n 软件UID:".$sample['Sample']['uid']."\n 软件的证书颁发者:".
$sample['Sample']['ca_issuer']."\n 软件的证书使用者:".$sample['Sample']['ca_subject'].
"\n样本中各个文件的安装路径:\n".$filenames."\n 样本详情链接:".
$detailUrl.$sample['Sample']['id'];
$remoteIssue = array(array ("customfieldId"=>"customfield_10050", "values"=>array ($sampleName)),
array ("customfieldId"=>"customfield_10123", "values"=>array ($desc)),
array ("customfieldId"=>"customfield_10167", "values"=>array ("手机医生")));
$issue = array(
"project" => $project,
"type" =>$type,
"summary" => $date."_".date('Y-m-d',$sample['Sample']['report_at']/1000)."_".$sample['Sample']['id'].".sis",
"assignee"=>$userName,
"reporter"=>$login,
"customFieldValues" => $remoteIssue
);

//  Create the Issue
$result = $client->createIssue( $login,$issue);
// Add attachment
$attachment_file = $sample['Sample']['sis_path'];
$jsonurl = $server_url."file_content.json?path=".$attachment_file;
$json = file_get_contents($jsonurl,0,null,null);
$attachmentName = basename($attachment_file);
$result = $client->addBase64EncodedAttachmentsToIssue($login, $result->key, array($attachmentName), array(base64_encode($json)) );
// Change status
$jsonurl = $server_url."change_status.json?id=".$sample['Sample']['id'];
$result = file_get_contents($jsonurl,0,null,null);
//print_r($result);
} catch (Exception $e) {
print $e->getMessage();
exit();
}
}
?>


2.出现错误

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://******.14:8080/rpc/soap/jirasoapservice-v2?wsdl' : failed to load external entity "http://******.14:8080/rpc/soap/jirasoapservice-v2?wsdl"


wsdl error: Getting http://******.14:8080/rpc/soap/jirasoapservice-v2?wsdl - HTTP ERROR: Couldn't open socket connection to server http://******.14:8080/rpc/soap/jirasoapservice-v2?wsdl, Error (13): Permission denied

3.解决问题
  出现此错误时,是因为httpd_can_network_connect 没有开通,通过命令打开即可。
  setsebool -P httpd_can_network_connect on
  备注:查看httpd的状态命令:/usr/sbin/getsebool -a | grep httpd
   
allow_httpd_anon_write --> off
allow_httpd_bugzilla_script_anon_write --> off
allow_httpd_mod_auth_pam --> off
allow_httpd_nagios_script_anon_write --> off
allow_httpd_squid_script_anon_write --> off
allow_httpd_sys_script_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_network_connect --> off
httpd_can_network_connect_db --> off
httpd_can_network_relay --> off
httpd_disable_trans --> off
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> on
httpd_rotatelogs_disable_trans --> off
httpd_ssi_exec --> off
httpd_suexec_disable_trans --> off
httpd_tty_comm --> on
httpd_unified --> on        


4.相关链接
  http://www.linuxforums.org/forum/redhat-fedora-linux-help/46840-fsockopen-error-13-permission-denied.html(提到httpd错误)
  http://wiki.centos.org/zh/TipsAndTricks/SelinuxBooleans
  http://fedoraproject.org/wiki/SELinux/apache
  http://oss.tresys.com/docs/refpolicy/api/tunables.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-356309-1-1.html 上篇帖子: advertising.php源代码分析 下篇帖子: php_验证码__转
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表